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