From 4e5362b7cb4160205b0b4ab2adaab73f20346b7a Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Sun, 4 Jul 2021 18:12:00 +0100 Subject: [PATCH] LibJS/Tests: Remove 'requires at least one argument' Array tests These will be removed in favour of just taking the argument and 'risking' a ToObject on null or undefined - this is how the spec does it. While that will make the message slightly less specific, it'll bring the code closer to the spec and reduce complexity, which are both preferable at the moment. Doing this is a previous, separate commit is simply an attempt to make the object rewrite commit smaller. --- .../LibJS/Tests/builtins/Array/Array.prototype.every.js | 6 ------ .../LibJS/Tests/builtins/Array/Array.prototype.filter.js | 6 ------ .../LibJS/Tests/builtins/Array/Array.prototype.find.js | 6 ------ .../Tests/builtins/Array/Array.prototype.findIndex.js | 9 --------- .../Tests/builtins/Array/Array.prototype.forEach.js | 9 --------- .../LibJS/Tests/builtins/Array/Array.prototype.map.js | 6 ------ .../LibJS/Tests/builtins/Array/Array.prototype.reduce.js | 6 ------ .../Tests/builtins/Array/Array.prototype.reduceRight.js | 9 --------- .../LibJS/Tests/builtins/Array/Array.prototype.some.js | 6 ------ 9 files changed, 63 deletions(-) diff --git a/Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype.every.js b/Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype.every.js index 0215f5b244..fc15e8dd97 100644 --- a/Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype.every.js +++ b/Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype.every.js @@ -3,12 +3,6 @@ test("length is 1", () => { }); describe("errors", () => { - test("requires at least one argument", () => { - expect(() => { - [].every(); - }).toThrowWithMessage(TypeError, "Array.prototype.every() requires at least one argument"); - }); - test("callback must be a function", () => { expect(() => { [].every(undefined); diff --git a/Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype.filter.js b/Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype.filter.js index 6f481cddb8..5703a7bb7c 100644 --- a/Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype.filter.js +++ b/Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype.filter.js @@ -3,12 +3,6 @@ test("length is 1", () => { }); describe("errors", () => { - test("requires at least one argument", () => { - expect(() => { - [].filter(); - }).toThrowWithMessage(TypeError, "Array.prototype.filter() requires at least one argument"); - }); - test("callback must be a function", () => { expect(() => { [].filter(undefined); diff --git a/Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype.find.js b/Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype.find.js index 4d12b61a11..05608ae0d3 100644 --- a/Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype.find.js +++ b/Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype.find.js @@ -3,12 +3,6 @@ test("length is 1", () => { }); describe("errors", () => { - test("requires at least one argument", () => { - expect(() => { - [].find(); - }).toThrowWithMessage(TypeError, "Array.prototype.find() requires at least one argument"); - }); - test("callback must be a function", () => { expect(() => { [].find(undefined); diff --git a/Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype.findIndex.js b/Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype.findIndex.js index 751caa64be..9163a2a4cc 100644 --- a/Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype.findIndex.js +++ b/Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype.findIndex.js @@ -3,15 +3,6 @@ test("length is 1", () => { }); describe("errors", () => { - test("requires at least one argument", () => { - expect(() => { - [].findIndex(); - }).toThrowWithMessage( - TypeError, - "Array.prototype.findIndex() requires at least one argument" - ); - }); - test("callback must be a function", () => { expect(() => { [].findIndex(undefined); diff --git a/Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype.forEach.js b/Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype.forEach.js index 8baa2d5635..ac5a0e7e6c 100644 --- a/Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype.forEach.js +++ b/Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype.forEach.js @@ -3,15 +3,6 @@ test("length is 1", () => { }); describe("errors", () => { - test("requires at least one argument", () => { - expect(() => { - [].forEach(); - }).toThrowWithMessage( - TypeError, - "Array.prototype.forEach() requires at least one argument" - ); - }); - test("callback must be a function", () => { expect(() => { [].forEach(undefined); diff --git a/Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype.map.js b/Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype.map.js index a775fa8c32..4b15e61a5e 100644 --- a/Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype.map.js +++ b/Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype.map.js @@ -3,12 +3,6 @@ test("length is 1", () => { }); describe("errors", () => { - test("requires at least one argument", () => { - expect(() => { - [].map(); - }).toThrowWithMessage(TypeError, "Array.prototype.map() requires at least one argument"); - }); - test("callback must be a function", () => { expect(() => { [].map(undefined); diff --git a/Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype.reduce.js b/Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype.reduce.js index 5f423d7fa5..110dcf8e1a 100644 --- a/Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype.reduce.js +++ b/Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype.reduce.js @@ -3,12 +3,6 @@ test("length is 1", () => { }); describe("errors", () => { - test("requires at least one argument", () => { - expect(() => { - [].reduce(); - }).toThrowWithMessage(TypeError, "Array.prototype.reduce() requires at least one argument"); - }); - test("callback must be a function", () => { expect(() => { [].reduce(undefined); diff --git a/Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype.reduceRight.js b/Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype.reduceRight.js index 394335f1c3..0a3f4acad9 100644 --- a/Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype.reduceRight.js +++ b/Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype.reduceRight.js @@ -3,15 +3,6 @@ test("length is 1", () => { }); describe("errors", () => { - test("requires at least one argument", () => { - expect(() => { - [].reduceRight(); - }).toThrowWithMessage( - TypeError, - "Array.prototype.reduceRight() requires at least one argument" - ); - }); - test("callback must be a function", () => { expect(() => { [].reduceRight(undefined); diff --git a/Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype.some.js b/Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype.some.js index ff9e62f2d1..2ddb97a1a3 100644 --- a/Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype.some.js +++ b/Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype.some.js @@ -3,12 +3,6 @@ test("length is 1", () => { }); describe("errors", () => { - test("requires at least one argument", () => { - expect(() => { - [].some(); - }).toThrowWithMessage(TypeError, "Array.prototype.some() requires at least one argument"); - }); - test("callback must be a function", () => { expect(() => { [].some(undefined);