1 module iface; 2 3 public import std.experimental.logger; 4 public import std.stdio; 5 public import std.datetime; 6 public import std.format; 7 public import std.random; 8 public import core.thread; 9 public import drmi; 10 11 interface One 12 { 13 string getTime(); 14 void printHello(); 15 double magicmath(double, double); 16 int[] getArray(int); 17 } 18 19 interface Two 20 { 21 int sum(int, int); 22 } 23 24 interface Three 25 { 26 string foo(double); 27 int bar(); 28 } 29 30 void rndSleep() 31 { 32 sleep(uniform(10, 300).msecs); 33 } 34 35 static size_t failcount; 36 37 void timeoutFail(string msg) 38 { 39 stderr.writeln(msg); 40 failcount++; 41 //exitEventLoop(); 42 } 43 44 void print(Args...)(Args args) 45 { 46 //stderr.writeln(args); 47 } 48 49 void testGetTime(One one) 50 { 51 rndSleep(); 52 try print(one.getTime()); 53 catch (RMITimeoutException e) timeoutFail(e.msg); 54 } 55 56 void testPrintHello(One one) 57 { 58 rndSleep(); 59 try one.printHello(); 60 catch (RMITimeoutException e) timeoutFail(e.msg); 61 } 62 63 void testMagicmath(One one) 64 { 65 rndSleep(); 66 auto r1 = uniform(5.0, 10.000001), r2 = uniform(1.0, 10.000001); 67 try print("(%s / %s) * %s = %s", r1, r2, r2, one.magicmath(r1, r2)); 68 catch (RMITimeoutException e) timeoutFail(e.msg); 69 } 70 71 void testGetArray(One one) 72 { 73 rndSleep(); 74 auto cnt = uniform(1, 6); 75 try print("%(%s, %)", one.getArray(cnt)); 76 catch (RMITimeoutException e) timeoutFail(e.msg); 77 } 78 79 void testSum(Two two) 80 { 81 rndSleep(); 82 auto r1 = uniform(-10, 11), r2 = uniform(-10, 11); 83 try print("%s + %s = %s", r1, r2, two.sum(r1, r2)); 84 catch (RMITimeoutException e) timeoutFail(e.msg); 85 } 86 87 void testFoo(Three three) 88 { 89 rndSleep(); 90 auto r1 = uniform!"[]"(-1.0, 1.0); 91 try print("three.foo(%s) -> %s", r1, three.foo(r1)); 92 catch (RMITimeoutException e) timeoutFail(e.msg); 93 } 94 95 void testBar(Three three) 96 { 97 rndSleep(); 98 try print("three.bar() -> %s", three.bar()); 99 catch (RMITimeoutException e) timeoutFail(e.msg); 100 }