From 5a6bdd040d8bb57a2fe75a6bf1a1e160365ba414 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Tue, 15 Sep 2020 14:33:00 -0700 Subject: [PATCH] test: improve assertions in pummel/test-timers * Timers should not fire early. Check for that. * Allow the wiggle-room to increase on subsequent iterations of intervals. PR-URL: https://github.com/nodejs/node/pull/35216 Reviewed-By: Benjamin Gruenbaum Reviewed-By: Andrey Pechkurov Reviewed-By: Anto Aravinth --- test/pummel/test-timers.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/pummel/test-timers.js b/test/pummel/test-timers.js index d5d992f7b9a552..2f5580840231e3 100644 --- a/test/pummel/test-timers.js +++ b/test/pummel/test-timers.js @@ -36,7 +36,7 @@ const WINDOW = 200; // Why does this need to be so big? assert.ok(diff > 0); console.error(`diff: ${diff}`); - assert.strictEqual(1000 - WINDOW < diff && diff < 1000 + WINDOW, true); + assert.ok(1000 <= diff && diff < 1000 + WINDOW); }), 1000); } @@ -61,7 +61,7 @@ const WINDOW = 200; // Why does this need to be so big? const t = interval_count * 1000; - assert.ok(t - WINDOW < diff && diff < t + WINDOW, `t: ${t}`); + assert.ok(t <= diff && diff < t + (WINDOW * interval_count)); assert.ok(interval_count <= 3, `interval_count: ${interval_count}`); if (interval_count === 3)