Skip to content

Commit

Permalink
test: refactoring test_error testing
Browse files Browse the repository at this point in the history
PR-URL: #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>
  • Loading branch information
himself65 authored and targos committed Aug 2, 2019
1 parent c93df0c commit c42eb5d
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions test/js-native-api/test_error/test.js
Expand Up @@ -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(),
Expand Down

0 comments on commit c42eb5d

Please sign in to comment.