From cfaec6ec4c167240960baa77cf05a3c4024ca85e Mon Sep 17 00:00:00 2001
From: Gabriel Schulhof <gabriel.schulhof@intel.com>
Date: Wed, 2 May 2018 21:02:06 -0400
Subject: [PATCH] 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
---
 test/addons-napi/test_error/test.js | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/test/addons-napi/test_error/test.js b/test/addons-napi/test_error/test.js
index f07326c202a569..d4b1d8a971ee09 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(),