mirror of
https://github.com/nodejs/node.git
synced 2026-11-26 21:58:26 -05:00
test: fix up N-API error test
Replace assert.throws() with an explicit try/catch in order to catch the thrown value and be able to compare it strictly to an expected value. Re: https://github.com/nodejs/node/pull/20428#issuecomment-386160684 PR-URL: https://github.com/nodejs/node/pull/20487 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This commit is contained in:
1 parent
6052ccc009
commit
70b2e169b4
1 file changed
+10
-3
@@ -61,9 +61,12 @@ assert.throws(() => {
|
||||
}, /^TypeError: type error$/);
|
||||
|
||||
function testThrowArbitrary(value) {
|
||||
assert.throws(() => {
|
||||
test_error.throwArbitrary(value);
|
||||
}, value);
|
||||
assert.throws(
|
||||
() => test_error.throwArbitrary(value),
|
||||
(err) => {
|
||||
assert.strictEqual(err, value);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
testThrowArbitrary(42);
|
||||
@@ -71,6 +74,10 @@ testThrowArbitrary({});
|
||||
testThrowArbitrary([]);
|
||||
testThrowArbitrary(Symbol('xyzzy'));
|
||||
testThrowArbitrary(true);
|
||||
testThrowArbitrary('ball');
|
||||
testThrowArbitrary(undefined);
|
||||
testThrowArbitrary(null);
|
||||
testThrowArbitrary(NaN);
|
||||
|
||||
common.expectsError(
|
||||
() => test_error.throwErrorCode(),
|
||||
|
||||
Reference in new issue
Block a user