Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Schulhof <gabriel.schulhof@intel.com>2018-05-03 04:02:06 +0300
committerMyles Borins <mylesborins@google.com>2018-05-09 04:26:16 +0300
commit70b2e169b4909185d5ac2e212cf969d47aaa65eb (patch)
tree1e9ae202f5962b285cd12da0ab1b57c39d94f06e /test/addons-napi
parent6052ccc0092db53f8b3b8b4f6d4863c5252dfa94 (diff)
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>
Diffstat (limited to 'test/addons-napi')
-rw-r--r--test/addons-napi/test_error/test.js13
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 f07326c202a..d4b1d8a971e 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(),