diff options
author | Gabriel Schulhof <gabriel.schulhof@intel.com> | 2018-05-02 21:02:06 -0400 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2018-05-05 13:44:03 +0200 |
commit | 3b60fc2b9b8a6b205a2b061087d2fc98d716c215 (patch) | |
tree | 72aba3f7ef43a66378ff5966adce354c7e9429b4 | |
parent | 2fda625b201c15e368a205bcf43f492ddb071cc2 (diff) | |
download | node-new-3b60fc2b9b8a6b205a2b061087d2fc98d716c215.tar.gz |
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>
-rw-r--r-- | test/addons-napi/test_error/test.js | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/test/addons-napi/test_error/test.js b/test/addons-napi/test_error/test.js index f07326c202..d4b1d8a971 100644 --- a/test/addons-napi/test_error/test.js +++ b/test/addons-napi/test_error/test.js @@ -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(), |