node/test/parallel/test-timers-this.js
Rich Trott 6cb33c0764 test: refactor test-timers-this
* 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>
2016-12-20 22:17:15 -08:00

30 lines
925 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const immediateHandler = setImmediate(common.mustCall(function() {
assert.strictEqual(this, immediateHandler);
}));
const immediateArgsHandler = setImmediate(common.mustCall(function() {
assert.strictEqual(this, immediateArgsHandler);
}), 'args ...');
const intervalHandler = setInterval(common.mustCall(function() {
clearInterval(intervalHandler);
assert.strictEqual(this, intervalHandler);
}), 1);
const intervalArgsHandler = setInterval(common.mustCall(function() {
clearInterval(intervalArgsHandler);
assert.strictEqual(this, intervalArgsHandler);
}), 1, 'args ...');
const timeoutHandler = setTimeout(common.mustCall(function() {
assert.strictEqual(this, timeoutHandler);
}), 1);
const timeoutArgsHandler = setTimeout(common.mustCall(function() {
assert.strictEqual(this, timeoutArgsHandler);
}), 1, 'args ...');