mirror of
https://github.com/nodejs/node.git
synced 2024-11-29 23:16:30 +01:00
4d893e093a
PR-URL: https://github.com/nodejs/node/pull/14659 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
50 lines
1.4 KiB
JavaScript
50 lines
1.4 KiB
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
|
|
function doSetTimeout(callback, after) {
|
|
return function() {
|
|
setTimeout(callback, after);
|
|
};
|
|
}
|
|
|
|
const errMessage = common.expectsError({
|
|
code: 'ERR_INVALID_CALLBACK',
|
|
type: TypeError
|
|
}, 18);
|
|
|
|
assert.throws(doSetTimeout('foo'), errMessage);
|
|
assert.throws(doSetTimeout({ foo: 'bar' }), errMessage);
|
|
assert.throws(doSetTimeout(), errMessage);
|
|
assert.throws(doSetTimeout(undefined, 0), errMessage);
|
|
assert.throws(doSetTimeout(null, 0), errMessage);
|
|
assert.throws(doSetTimeout(false, 0), errMessage);
|
|
|
|
|
|
function doSetInterval(callback, after) {
|
|
return function() {
|
|
setInterval(callback, after);
|
|
};
|
|
}
|
|
|
|
assert.throws(doSetInterval('foo'), errMessage);
|
|
assert.throws(doSetInterval({ foo: 'bar' }), errMessage);
|
|
assert.throws(doSetInterval(), errMessage);
|
|
assert.throws(doSetInterval(undefined, 0), errMessage);
|
|
assert.throws(doSetInterval(null, 0), errMessage);
|
|
assert.throws(doSetInterval(false, 0), errMessage);
|
|
|
|
|
|
function doSetImmediate(callback, after) {
|
|
return function() {
|
|
setImmediate(callback, after);
|
|
};
|
|
}
|
|
|
|
assert.throws(doSetImmediate('foo'), errMessage);
|
|
assert.throws(doSetImmediate({ foo: 'bar' }), errMessage);
|
|
assert.throws(doSetImmediate(), errMessage);
|
|
assert.throws(doSetImmediate(undefined, 0), errMessage);
|
|
assert.throws(doSetImmediate(null, 0), errMessage);
|
|
assert.throws(doSetImmediate(false, 0), errMessage);
|