node/test/parallel/test-timers-enroll-invalid-msecs.js
Weijia Wang d022cb1bdd lib: combine similar error codes
There two similar error codes in lib: "ERR_VALUE_OUT_OF_RANGE"
and "ERR_OUT_OF_RANGE". This change is to reduce them into
"ERR_VALUE_OUT_OF_RANGE"

Fixes: https://github.com/nodejs/node/issues/17603

PR-URL: https://github.com/nodejs/node/pull/17648
Fixes: https://github.com/nodejs/node/issues/17603
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2017-12-24 14:09:29 +08:00

38 lines
630 B
JavaScript

'use strict';
const common = require('../common');
const timers = require('timers');
[
{},
[],
'foo',
() => { },
Symbol('foo')
].forEach((val) => {
common.expectsError(
() => timers.enroll({}, val),
{
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError
}
);
});
[
-1,
Infinity,
NaN
].forEach((val) => {
common.expectsError(
() => timers.enroll({}, val),
{
code: 'ERR_OUT_OF_RANGE',
type: RangeError,
message: 'The value of "msecs" is out of range. ' +
'It must be a non-negative finite number. ' +
`Received ${val}`
}
);
});