summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhimself65 <himself65@outlook.com>2019-07-31 00:53:43 +0800
committerRich Trott <rtrott@gmail.com>2019-08-01 13:12:53 -0700
commitb32526c488dc1c059e957b0e2c38cb41cfe2bb78 (patch)
tree0018c3d9f02030b347565e33bf06a05bc14f6258
parentf53a2414474c2b1aee07ab367415b32c20e50bd9 (diff)
downloadandroid-node-v8-b32526c488dc1c059e957b0e2c38cb41cfe2bb78.tar.gz
android-node-v8-b32526c488dc1c059e957b0e2c38cb41cfe2bb78.tar.bz2
android-node-v8-b32526c488dc1c059e957b0e2c38cb41cfe2bb78.zip
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>
-rw-r--r--test/js-native-api/test_error/test.js18
1 files changed, 4 insertions, 14 deletions
diff --git a/test/js-native-api/test_error/test.js b/test/js-native-api/test_error/test.js
index e7e0ded476..e39038e805 100644
--- a/test/js-native-api/test_error/test.js
+++ b/test/js-native-api/test_error/test.js
@@ -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(),