Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: simplify WPT.assert_throws() #11126

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -600,10 +600,8 @@ exports.WPT = {
assert_equals: assert.strictEqual,
assert_true: (value, message) => assert.strictEqual(value, true, message),
assert_false: (value, message) => assert.strictEqual(value, false, message),
assert_throws: (code, func, desc) => {
assert.throws(func, (err) => {
return typeof err === 'object' && 'name' in err && err.name === code.name;
}, desc);
assert_throws: (errType, func, desc) => {
assert.throws(func, (err) => err instanceof errType, desc);
},
assert_array_equals: assert.deepStrictEqual,
assert_unreached(desc) {
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-whatwg-url-constructor.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function runURLTests(urltests) {

test(function() {
if (expected.failure) {
assert_throws(new TypeError(), function() {
assert_throws(TypeError, function() {
bURL(expected.input, expected.base)
})
return
Expand Down Expand Up @@ -97,7 +97,7 @@ function runURLSearchParamTests() {
'use strict'
var urlString = 'http://example.org'
var url = bURL(urlString)
assert_throws(TypeError(), function() { url.searchParams = new URLSearchParams(urlString) })
assert_throws(TypeError, function() { url.searchParams = new URLSearchParams(urlString) })
}, 'URL.searchParams setter, invalid values')

test(function() {
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-whatwg-url-historical.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if (!common.hasIntl) {
test(function() {
var url = new URL("./foo", "http://www.example.org");
assert_equals(url.href, "http://www.example.org/foo");
assert_throws(new TypeError(), function() {
assert_throws(TypeError, function() {
url.href = "./bar";
});
}, "Setting URL's href attribute and base URLs");
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-whatwg-url-searchparams-constructor.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ test(function() {
params = new URLSearchParams([['a', 'b'], ['c', 'd']]);
assert_equals(params.get("a"), "b");
assert_equals(params.get("c"), "d");
assert_throws(new TypeError(), function() { new URLSearchParams([[1]]); });
assert_throws(new TypeError(), function() { new URLSearchParams([[1,2,3]]); });
assert_throws(TypeError, function() { new URLSearchParams([[1]]); });
assert_throws(TypeError, function() { new URLSearchParams([[1,2,3]]); });
}, "Constructor with sequence of sequences of strings");

[
Expand Down