mirror of https://github.com/lukechilds/node.git
Browse Source
PR-URL: https://github.com/nodejs/node/pull/5882 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>process-exit-stdio-flushing
Rich Trott
9 years ago
1 changed files with 15 additions and 14 deletions
@ -1,20 +1,21 @@ |
|||||
'use strict'; |
'use strict'; |
||||
const common = require('../common'); |
const common = require('../common'); |
||||
const assert = require('assert'); |
const timers = require('timers'); |
||||
|
|
||||
// don't verify the globals for this test
|
// delete global APIs to make sure they're not relied on by the internal timers
|
||||
common.globalCheck = false; |
// 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
|
const timeoutCallback = () => { timers.clearTimeout(timeout); }; |
||||
// they're not relied on by the timers
|
const timeout = timers.setTimeout(common.mustCall(timeoutCallback), 1); |
||||
global.clearTimeout = assert.fail; |
|
||||
|
|
||||
// run timeouts/intervals through the paces
|
const intervalCallback = () => { timers.clearInterval(interval); }; |
||||
const intv = setInterval(function() {}, 1); |
const interval = timers.setInterval(common.mustCall(intervalCallback), 1); |
||||
|
|
||||
setTimeout(function() { |
|
||||
clearInterval(intv); |
|
||||
}, 100); |
|
||||
|
|
||||
setTimeout(function() {}, 2); |
|
||||
|
|
||||
|
const immediateCallback = () => { timers.clearImmediate(immediate); }; |
||||
|
const immediate = timers.setImmediate(immediateCallback); |
||||
|
Loading…
Reference in new issue