diff --git a/tests/0-timer.d b/tests/0-timer.d index 907e04b..d9564e9 100644 --- a/tests/0-timer.d +++ b/tests/0-timer.d @@ -26,8 +26,10 @@ void main() dur = Clock.currTime(UTC()) - s_startTime; } - assert(dur > 200.msecs); - assert(dur < 260.msecs); + try { + assert(dur > 200.msecs, (dur - 200.msecs).toString()); + assert(dur < 260.msecs, (dur - 200.msecs).toString()); + } catch (Exception e) assert(false, e.msg); s_startTime += dur; @@ -37,8 +39,8 @@ void main() try { auto dur = Clock.currTime(UTC()) - s_startTime; s_cnt++; - assert(dur > 100.msecs * s_cnt); - assert(dur < 100.msecs * s_cnt + 60.msecs); + assert(dur > 100.msecs * s_cnt, (dur - 100.msecs * s_cnt).toString()); + assert(dur < 100.msecs * s_cnt + 60.msecs, (dur - 100.msecs * s_cnt).toString()); assert(s_cnt <= 3); if (s_cnt == 3) { diff --git a/tests/issue-25-periodic-timers.d b/tests/issue-25-periodic-timers.d index 4477428..a783dc8 100644 --- a/tests/issue-25-periodic-timers.d +++ b/tests/issue-25-periodic-timers.d @@ -22,17 +22,17 @@ void main() // first timer: one-shot 200ms auto tm = eventDriver.timers.create(); eventDriver.timers.wait(tm, (tm) nothrow @safe { - Duration dur; - { - scope (failure) assert(false); + try { writefln("First timer"); - dur = Clock.currTime(UTC()) - s_startTime; + auto dur = Clock.currTime(UTC()) - s_startTime; + + assert(dur >= 200.msecs, (dur - 200.msecs).toString()); + assert(dur < 250.msecs, (dur - 200.msecs).toString()); + + timer1fired = true; + } catch (Exception e) { + assert(false, e.msg); } - - assert(dur >= 200.msecs); - assert(dur < 250.msecs); - - timer1fired = true; }); eventDriver.timers.set(tm, 200.msecs, 0.msecs); @@ -45,8 +45,8 @@ void main() auto dur = Clock.currTime(UTC()) - s_startTime; s_cnt++; - assert(dur > 100.msecs * s_cnt); - assert(dur < 100.msecs * s_cnt + 60.msecs); + assert(dur > 100.msecs * s_cnt, (dur - 100.msecs * s_cnt).toString()); + assert(dur < 100.msecs * s_cnt + 60.msecs, (dur - 100.msecs * s_cnt).toString()); assert(s_cnt <= 3); if (s_cnt == 3) {