diff options
author | Rich Trott <rtrott@gmail.com> | 2016-03-24 15:11:36 -0700 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2016-03-28 16:18:26 -0700 |
commit | f0367d0edc2a5ff42bf838bc50af02d38f61c006 (patch) | |
tree | 2ac6767b667419d7393153d202e45852f2e6809e /test | |
parent | 9fa25c8ca0158fec7526c7b8b3db74d2bc66fb73 (diff) | |
download | android-node-v8-f0367d0edc2a5ff42bf838bc50af02d38f61c006.tar.gz android-node-v8-f0367d0edc2a5ff42bf838bc50af02d38f61c006.tar.bz2 android-node-v8-f0367d0edc2a5ff42bf838bc50af02d38f61c006.zip |
test: confirm globals not used internally
PR-URL: https://github.com/nodejs/node/pull/5882
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-timers-api-refs.js | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/test/parallel/test-timers-api-refs.js b/test/parallel/test-timers-api-refs.js index 00d1c1355f..c062369444 100644 --- a/test/parallel/test-timers-api-refs.js +++ b/test/parallel/test-timers-api-refs.js @@ -1,20 +1,21 @@ 'use strict'; const common = require('../common'); -const assert = require('assert'); +const timers = require('timers'); -// don't verify the globals for this test -common.globalCheck = false; +// delete global APIs to make sure they're not relied on by the internal timers +// code +delete global.setTimeout; +delete global.clearTimeout; +delete global.setInterval; +delete global.clearInterval; +delete global.setImmediate; +delete global.clearImmediate; -// try overriding global APIs to make sure -// they're not relied on by the timers -global.clearTimeout = assert.fail; +const timeoutCallback = () => { timers.clearTimeout(timeout); }; +const timeout = timers.setTimeout(common.mustCall(timeoutCallback), 1); -// run timeouts/intervals through the paces -const intv = setInterval(function() {}, 1); - -setTimeout(function() { - clearInterval(intv); -}, 100); - -setTimeout(function() {}, 2); +const intervalCallback = () => { timers.clearInterval(interval); }; +const interval = timers.setInterval(common.mustCall(intervalCallback), 1); +const immediateCallback = () => { timers.clearImmediate(immediate); }; +const immediate = timers.setImmediate(immediateCallback); |