From a3af754a8769a433cc5119f5ddb3c3cf0c1e5c06 Mon Sep 17 00:00:00 2001 From: himself65 Date: Wed, 31 Jul 2019 00:53:43 +0800 Subject: [PATCH] test: refactoring test_error testing --- test/js-native-api/test_error/test.js | 18 ++++-------------- 1 file 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 e7e0ded476fe43..e39038e8056f02 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(),