test: refactoring test_error testing
PR-URL: https://github.com/nodejs/node/pull/28902 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
parent
f53a241447
commit
b32526c488
@ -60,24 +60,14 @@ assert.throws(() => {
|
||||
test_error.throwTypeError();
|
||||
}, /^TypeError: type error$/);
|
||||
|
||||
function testThrowArbitrary(value) {
|
||||
assert.throws(
|
||||
[42, {}, [], Symbol('xyzzy'), true, 'ball', undefined, null, NaN]
|
||||
.forEach((value) => assert.throws(
|
||||
() => test_error.throwArbitrary(value),
|
||||
(err) => {
|
||||
assert.strictEqual(err, value);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
testThrowArbitrary(42);
|
||||
testThrowArbitrary({});
|
||||
testThrowArbitrary([]);
|
||||
testThrowArbitrary(Symbol('xyzzy'));
|
||||
testThrowArbitrary(true);
|
||||
testThrowArbitrary('ball');
|
||||
testThrowArbitrary(undefined);
|
||||
testThrowArbitrary(null);
|
||||
testThrowArbitrary(NaN);
|
||||
}
|
||||
));
|
||||
|
||||
common.expectsError(
|
||||
() => test_error.throwErrorCode(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user