From 60aeebf66899641a6d31614bacccfe237864dd73 Mon Sep 17 00:00:00 2001 From: Eric Rosenbaum Date: Mon, 22 Jun 2020 11:56:10 -0400 Subject: [PATCH 1/2] Test that clock is reset on runtime dispose --- test/unit/io_clock.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/unit/io_clock.js b/test/unit/io_clock.js index 03ee48fb..a7248de6 100644 --- a/test/unit/io_clock.js +++ b/test/unit/io_clock.js @@ -35,3 +35,24 @@ test('cycle', t => { rt._step(); t.ok(c.projectTimer() > 0); }); + +test('reset on runtime dispose', t => { + const rt = new Runtime(); + const c = rt.ioDevices.clock; + let simulatedTime = 0; + + c._projectTimer = { + timeElapsed: () => simulatedTime, + start: () => { + simulatedTime = 0; + } + }; + + t.ok(c.projectTimer() === 0); + simulatedTime += 1000; + t.ok(c.projectTimer() === 1); + rt.dispose(); + // When the runtime is disposed, the clock should be reset + t.ok(c.projectTimer() === 0); + t.end(); +}); From 45c95f33701618f229da4c8b891c5c6bbd25f007 Mon Sep 17 00:00:00 2001 From: Eric Rosenbaum Date: Tue, 23 Jun 2020 17:13:11 -0400 Subject: [PATCH 2/2] Move test --- test/unit/engine_runtime.js | 21 +++++++++++++++++++++ test/unit/io_clock.js | 21 --------------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/test/unit/engine_runtime.js b/test/unit/engine_runtime.js index 368a5770..de5025db 100644 --- a/test/unit/engine_runtime.js +++ b/test/unit/engine_runtime.js @@ -250,3 +250,24 @@ test('Disposing the runtime emits an event', t => { t.equal(disposed, true); t.end(); }); + +test('Clock is reset on runtime dispose', t => { + const rt = new Runtime(); + const c = rt.ioDevices.clock; + let simulatedTime = 0; + + c._projectTimer = { + timeElapsed: () => simulatedTime, + start: () => { + simulatedTime = 0; + } + }; + + t.ok(c.projectTimer() === 0); + simulatedTime += 1000; + t.ok(c.projectTimer() === 1); + rt.dispose(); + // When the runtime is disposed, the clock should be reset + t.ok(c.projectTimer() === 0); + t.end(); +}); diff --git a/test/unit/io_clock.js b/test/unit/io_clock.js index a7248de6..03ee48fb 100644 --- a/test/unit/io_clock.js +++ b/test/unit/io_clock.js @@ -35,24 +35,3 @@ test('cycle', t => { rt._step(); t.ok(c.projectTimer() > 0); }); - -test('reset on runtime dispose', t => { - const rt = new Runtime(); - const c = rt.ioDevices.clock; - let simulatedTime = 0; - - c._projectTimer = { - timeElapsed: () => simulatedTime, - start: () => { - simulatedTime = 0; - } - }; - - t.ok(c.projectTimer() === 0); - simulatedTime += 1000; - t.ok(c.projectTimer() === 1); - rt.dispose(); - // When the runtime is disposed, the clock should be reset - t.ok(c.projectTimer() === 0); - t.end(); -});