-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* use common.mustCall() and eliminate exit handler * provide timer durtion of 1ms where previously omitted * var -> const PR-URL: #10315 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
- Loading branch information
1 parent
fa11f4b
commit 90a79b3
Showing
1 changed file
with
20 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,29 @@ | ||
'use strict'; | ||
require('../common'); | ||
var assert = require('assert'); | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
|
||
let immediateThis, intervalThis, timeoutThis; | ||
let immediateArgsThis, intervalArgsThis, timeoutArgsThis; | ||
const immediateHandler = setImmediate(common.mustCall(function() { | ||
assert.strictEqual(this, immediateHandler); | ||
})); | ||
|
||
var immediateHandler = setImmediate(function() { | ||
immediateThis = this; | ||
}); | ||
const immediateArgsHandler = setImmediate(common.mustCall(function() { | ||
assert.strictEqual(this, immediateArgsHandler); | ||
}), 'args ...'); | ||
|
||
var immediateArgsHandler = setImmediate(function() { | ||
immediateArgsThis = this; | ||
}, 'args ...'); | ||
|
||
var intervalHandler = setInterval(function() { | ||
const intervalHandler = setInterval(common.mustCall(function() { | ||
clearInterval(intervalHandler); | ||
assert.strictEqual(this, intervalHandler); | ||
}), 1); | ||
|
||
intervalThis = this; | ||
}); | ||
|
||
var intervalArgsHandler = setInterval(function() { | ||
const intervalArgsHandler = setInterval(common.mustCall(function() { | ||
clearInterval(intervalArgsHandler); | ||
assert.strictEqual(this, intervalArgsHandler); | ||
}), 1, 'args ...'); | ||
|
||
intervalArgsThis = this; | ||
}, 0, 'args ...'); | ||
|
||
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); | ||
const timeoutHandler = setTimeout(common.mustCall(function() { | ||
assert.strictEqual(this, timeoutHandler); | ||
}), 1); | ||
|
||
assert.strictEqual(timeoutThis, timeoutHandler); | ||
assert.strictEqual(timeoutArgsThis, timeoutArgsHandler); | ||
}); | ||
const timeoutArgsHandler = setTimeout(common.mustCall(function() { | ||
assert.strictEqual(this, timeoutArgsHandler); | ||
}), 1, 'args ...'); |