mirror of https://github.com/lukechilds/node.git
Browse Source
* use common.mustCall() and eliminate exit handler * provide timer durtion of 1ms where previously omitted * var -> const PR-URL: https://github.com/nodejs/node/pull/10315 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>v6.x
Rich Trott
8 years ago
committed by
Myles Borins
1 changed files with 20 additions and 36 deletions
@ -1,45 +1,29 @@ |
|||||
'use strict'; |
'use strict'; |
||||
require('../common'); |
const common = require('../common'); |
||||
var assert = require('assert'); |
const assert = require('assert'); |
||||
|
|
||||
let immediateThis, intervalThis, timeoutThis; |
const immediateHandler = setImmediate(common.mustCall(function() { |
||||
let immediateArgsThis, intervalArgsThis, timeoutArgsThis; |
assert.strictEqual(this, immediateHandler); |
||||
|
})); |
||||
|
|
||||
var immediateHandler = setImmediate(function() { |
const immediateArgsHandler = setImmediate(common.mustCall(function() { |
||||
immediateThis = this; |
assert.strictEqual(this, immediateArgsHandler); |
||||
}); |
}), 'args ...'); |
||||
|
|
||||
var immediateArgsHandler = setImmediate(function() { |
const intervalHandler = setInterval(common.mustCall(function() { |
||||
immediateArgsThis = this; |
|
||||
}, 'args ...'); |
|
||||
|
|
||||
var intervalHandler = setInterval(function() { |
|
||||
clearInterval(intervalHandler); |
clearInterval(intervalHandler); |
||||
|
assert.strictEqual(this, intervalHandler); |
||||
|
}), 1); |
||||
|
|
||||
intervalThis = this; |
const intervalArgsHandler = setInterval(common.mustCall(function() { |
||||
}); |
|
||||
|
|
||||
var intervalArgsHandler = setInterval(function() { |
|
||||
clearInterval(intervalArgsHandler); |
clearInterval(intervalArgsHandler); |
||||
|
assert.strictEqual(this, intervalArgsHandler); |
||||
|
}), 1, 'args ...'); |
||||
|
|
||||
intervalArgsThis = this; |
const timeoutHandler = setTimeout(common.mustCall(function() { |
||||
}, 0, 'args ...'); |
assert.strictEqual(this, timeoutHandler); |
||||
|
}), 1); |
||||
var timeoutHandler = setTimeout(function() { |
|
||||
timeoutThis = this; |
|
||||
}); |
|
||||
|
|
||||
var timeoutArgsHandler = setTimeout(function() { |
|
||||
timeoutArgsThis = this; |
|
||||
}, 0, 'args ...'); |
|
||||
|
|
||||
process.once('exit', function() { |
|
||||
assert.strictEqual(immediateThis, immediateHandler); |
|
||||
assert.strictEqual(immediateArgsThis, immediateArgsHandler); |
|
||||
|
|
||||
assert.strictEqual(intervalThis, intervalHandler); |
|
||||
assert.strictEqual(intervalArgsThis, intervalArgsHandler); |
|
||||
|
|
||||
assert.strictEqual(timeoutThis, timeoutHandler); |
const timeoutArgsHandler = setTimeout(common.mustCall(function() { |
||||
assert.strictEqual(timeoutArgsThis, timeoutArgsHandler); |
assert.strictEqual(this, timeoutArgsHandler); |
||||
}); |
}), 1, 'args ...'); |
||||
|
Loading…
Reference in new issue