1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
'use strict';
require('../common');
var assert = require('assert');
let immediateThis, intervalThis, timeoutThis;
let immediateArgsThis, intervalArgsThis, timeoutArgsThis;
var immediateHandler = setImmediate(function() {
immediateThis = this;
});
var immediateArgsHandler = setImmediate(function() {
immediateArgsThis = this;
}, 'args ...');
var intervalHandler = setInterval(function() {
clearInterval(intervalHandler);
intervalThis = this;
});
var intervalArgsHandler = setInterval(function() {
clearInterval(intervalArgsHandler);
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);
assert.strictEqual(timeoutThis, timeoutHandler);
assert.strictEqual(timeoutArgsThis, timeoutArgsHandler);
});
|