diff --git a/test/run-drun/ok/timer.drun-run.ok b/test/run-drun/ok/timer.drun-run.ok index 6d4f3fb09b3..447a2d853ad 100644 --- a/test/run-drun/ok/timer.drun-run.ok +++ b/test/run-drun/ok/timer.drun-run.ok @@ -4,11 +4,9 @@ debug.print: YEP! debug.print: DIM! debug.print: ROOK! debug.print: DIM! +debug.print: DIM! debug.print: BATT! debug.print: BATT! debug.print: BATT! -debug.print: BATT! -debug.print: BATT! -debug.print: BATT! -debug.print: {count = 10} +debug.print: {count = 8} ingress Completed: Reply: 0x4449444c0000 diff --git a/test/run-drun/ok/timer.ic-ref-run.ok b/test/run-drun/ok/timer.ic-ref-run.ok index 9b3b93f5bae..7877ebd12d5 100644 --- a/test/run-drun/ok/timer.ic-ref-run.ok +++ b/test/run-drun/ok/timer.ic-ref-run.ok @@ -7,11 +7,9 @@ debug.print: YEP! debug.print: DIM! debug.print: ROOK! debug.print: DIM! +debug.print: DIM! debug.print: BATT! debug.print: BATT! debug.print: BATT! -debug.print: BATT! -debug.print: BATT! -debug.print: BATT! -debug.print: {count = 10} +debug.print: {count = 8} <= replied: () diff --git a/test/run-drun/timer.mo b/test/run-drun/timer.mo index 3fc87295781..31f218c393e 100644 --- a/test/run-drun/timer.mo +++ b/test/run-drun/timer.mo @@ -2,6 +2,20 @@ import { debugPrint; error; setTimer; cancelTimer } = "mo:⛔"; +/* +The schedule is +| seconds | reaction | +|----|-----| +| 1.0 | YEP! | +| 2.0 | DIM! | +| 3.0 | ROOK! | +| 4.0 | DIM! | +| 6.0 | DIM! | +| 8.0 | BATT! | +| 13.0 | BATT! | +| 18.0 | BATT! | +*/ + actor { system func timer(setGlobalTimer : Nat64 -> ()) : async () { @@ -9,7 +23,7 @@ actor { }; var count = 0; - var max = 10; + var max = 8; let raw_rand = (actor "aaaaa-aa" : actor { raw_rand : () -> async Blob }).raw_rand; let second : Nat64 = 1_000_000_000; @@ -17,17 +31,17 @@ actor { var attempts = 0; let id1 = setTimer(1 * second, false, func () : async () { count += 1; debugPrint "YEP!" }); - let id2 = setTimer(2 * (second - second / 10), true, func () : async () { count += 1; debugPrint "DIM!" }); + let id2 = setTimer(2 * second, true, func () : async () { count += 1; debugPrint "DIM!" }); let id3 = setTimer(3 * second, false, func () : async () { count += 1; debugPrint "ROOK!"; - ignore setTimer(1 * second, true, func () : async () { count += 1; debugPrint "BATT!" }) + ignore setTimer(5 * second, true, func () : async () { count += 1; debugPrint "BATT!" }) }); while (count < max) { ignore await raw_rand(); // yield to scheduler attempts += 1; - if (count > 5) { cancelTimer id2 }; + if (count >= 5) { cancelTimer id2 }; if (attempts >= 200 and count == 0) throw error("he's dead Jim"); };