diff --git a/test/parallel/test-regress-GH-897.js b/test/parallel/test-regress-GH-897.js new file mode 100644 index 00000000000000..911ad6b6b2e112 --- /dev/null +++ b/test/parallel/test-regress-GH-897.js @@ -0,0 +1,20 @@ +'use strict'; + +// Test for bug where a timer duration greater than 0 ms but less than 1 ms +// resulted in the duration being set for 1000 ms. The expected behavior is +// that the timeout would be set for 1 ms, and thus fire before timers set +// with values greater than 1ms. +// +// Ref: https://github.com/nodejs/node-v0.x-archive/pull/897 + +const common = require('../common'); + +let timer; + +setTimeout(function() { + clearTimeout(timer); +}, 0.1); // 0.1 should be treated the same as 1, not 1000... + +timer = setTimeout(function() { + common.fail('timers fired out of order'); +}, 2); // ...so this timer should fire second. diff --git a/test/sequential/test-regress-GH-897.js b/test/sequential/test-regress-GH-897.js deleted file mode 100644 index 7b1297efd5a1b7..00000000000000 --- a/test/sequential/test-regress-GH-897.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; - -// Test for bug where a timer duration greater than 0 ms but less than 1 ms -// resulted in the duration being set for 1000 ms. The expected behavior is -// that the timeout would be set for 1 ms, and thus fire more-or-less -// immediately. -// -// Ref: https://github.com/nodejs/node-v0.x-archive/pull/897 - -const common = require('../common'); -const assert = require('assert'); - -const t = Date.now(); -setTimeout(common.mustCall(function() { - const diff = Date.now() - t; - assert.ok(diff < 100, `timer fired after ${diff} ms`); -}), 0.1);