From 81a3f4d67bd9e6e1b4b8afb80668d7aaf6120c64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Wed, 8 Dec 2021 16:47:05 +0100 Subject: [PATCH 01/86] Add `change-array-by-copy` feature flag --- features.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/features.txt b/features.txt index 47f33885118..30feb0436e0 100644 --- a/features.txt +++ b/features.txt @@ -284,6 +284,11 @@ regexp-duplicate-named-groups # https://github.com/tc39/proposal-symbols-as-weakmap-keys symbols-as-weakmap-keys +# Array.prototype.toReversed, Array.prototype.toSorted, Array.prototype.toSpliced, +# Array.prototype.with and the equivalent TypedArray methods. +# https://github.com/tc39/proposal-change-array-by-copy/ +change-array-by-copy + ## Standard language features # # Language features that have been included in a published version of the From d4011b10dc7177afc410f8f866a4daca7f9edfba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Thu, 9 Dec 2021 11:59:49 +0100 Subject: [PATCH 02/86] Add `Array.prototype.toReversed` tests --- .../prototype/toReversed/frozen-this-value.js | 15 ++++++++ .../toReversed/get-descending-order.js | 38 +++++++++++++++++++ .../toReversed/holes-not-preserved.js | 28 ++++++++++++++ .../prototype/toReversed/ignores-species.js | 31 +++++++++++++++ .../Array/prototype/toReversed/immutable.js | 14 +++++++ .../toReversed/length-casted-to-zero.js | 19 ++++++++++ .../length-decreased-while-iterating.js | 31 +++++++++++++++ .../length-exceeding-array-length-limit.js | 38 +++++++++++++++++++ .../length-increased-while-iterating.js | 29 ++++++++++++++ .../toReversed/length-integer-string.js | 28 ++++++++++++++ .../prototype/toReversed/metadata/length.js | 30 +++++++++++++++ .../prototype/toReversed/metadata/name.js | 28 ++++++++++++++ .../metadata/property-descriptor.js | 25 ++++++++++++ .../prototype/toReversed/not-a-constructor.js | 33 ++++++++++++++++ .../toReversed/this-value-boolean.js | 18 +++++++++ .../toReversed/this-value-nullish.js | 22 +++++++++++ .../toReversed/zero-or-one-element.js | 19 ++++++++++ 17 files changed, 446 insertions(+) create mode 100644 test/built-ins/Array/prototype/toReversed/frozen-this-value.js create mode 100644 test/built-ins/Array/prototype/toReversed/get-descending-order.js create mode 100644 test/built-ins/Array/prototype/toReversed/holes-not-preserved.js create mode 100644 test/built-ins/Array/prototype/toReversed/ignores-species.js create mode 100644 test/built-ins/Array/prototype/toReversed/immutable.js create mode 100644 test/built-ins/Array/prototype/toReversed/length-casted-to-zero.js create mode 100644 test/built-ins/Array/prototype/toReversed/length-decreased-while-iterating.js create mode 100644 test/built-ins/Array/prototype/toReversed/length-exceeding-array-length-limit.js create mode 100644 test/built-ins/Array/prototype/toReversed/length-increased-while-iterating.js create mode 100644 test/built-ins/Array/prototype/toReversed/length-integer-string.js create mode 100644 test/built-ins/Array/prototype/toReversed/metadata/length.js create mode 100644 test/built-ins/Array/prototype/toReversed/metadata/name.js create mode 100644 test/built-ins/Array/prototype/toReversed/metadata/property-descriptor.js create mode 100644 test/built-ins/Array/prototype/toReversed/not-a-constructor.js create mode 100644 test/built-ins/Array/prototype/toReversed/this-value-boolean.js create mode 100644 test/built-ins/Array/prototype/toReversed/this-value-nullish.js create mode 100644 test/built-ins/Array/prototype/toReversed/zero-or-one-element.js diff --git a/test/built-ins/Array/prototype/toReversed/frozen-this-value.js b/test/built-ins/Array/prototype/toReversed/frozen-this-value.js new file mode 100644 index 00000000000..6b2bfcb6aba --- /dev/null +++ b/test/built-ins/Array/prototype/toReversed/frozen-this-value.js @@ -0,0 +1,15 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toReversed +description: > + Array.prototype.toReversed works on frozen objects +features: [change-array-by-copy] +---*/ + +var arr = Object.freeze([0, 1, 2]); +arr.toReversed(); + +var arrayLike = Object.freeze({ length: 3, 0: 0, 1: 1, 2: 2 }); +Array.prototype.toReversed.call(arrayLike); diff --git a/test/built-ins/Array/prototype/toReversed/get-descending-order.js b/test/built-ins/Array/prototype/toReversed/get-descending-order.js new file mode 100644 index 00000000000..3ece167551d --- /dev/null +++ b/test/built-ins/Array/prototype/toReversed/get-descending-order.js @@ -0,0 +1,38 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toReversed +description: > + Array.prototype.toReversed gets the array elements from the last one to the first one. +info: | + Array.prototype.toReversed ( ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + ... + 5. Repeat, while k < len + a. Let from be ! ToString(𝔽(len - k - 1)). + ... + c. Let fromValue be ? Get(O, from). + ... +features: [change-array-by-copy] +---*/ + +var order = []; +var arrayLike = { + length: 3, + get 0() { + order.push(0); + }, + get 1() { + order.push(1); + }, + get 2() { + order.push(2); + }, +}; + +Array.prototype.toReversed.call(arrayLike); + +assert.deepEqual(order, [2, 1, 0]); diff --git a/test/built-ins/Array/prototype/toReversed/holes-not-preserved.js b/test/built-ins/Array/prototype/toReversed/holes-not-preserved.js new file mode 100644 index 00000000000..44e9371a8bf --- /dev/null +++ b/test/built-ins/Array/prototype/toReversed/holes-not-preserved.js @@ -0,0 +1,28 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toReversed +description: > + Array.prototype.toReversed does not preserve holes in the array +info: | + Array.prototype.toReversed ( ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + ... + 5. Repeat, while k < len + a. Let from be ! ToString(𝔽(len - k - 1)). + ... + c. Let fromValue be ? Get(O, from). + d. Perform ? CreateDataPropertyOrThrow(A, Pk, fromValue). + ... +features: [change-array-by-copy] +---*/ + +var arr = [0, /* hole */, 2, /* hole */, 4]; +Array.prototype[3] = 3; + +var reversed = arr.toReversed(); +assert.deepEqual(reversed, [4, 3, 2, undefined, 0]); +assert(reversed.hasOwnProperty(3)); diff --git a/test/built-ins/Array/prototype/toReversed/ignores-species.js b/test/built-ins/Array/prototype/toReversed/ignores-species.js new file mode 100644 index 00000000000..29328c1e955 --- /dev/null +++ b/test/built-ins/Array/prototype/toReversed/ignores-species.js @@ -0,0 +1,31 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toReversed +description: > + Array.prototype.toReversed ignores @@species +info: | + Array.prototype.toReversed ( ) + + ... + 3. Let A be ? ArrayCreate(𝔽(len)). + ... +features: [change-array-by-copy] +---*/ + +var a = []; +a.constructor = {}; +a.constructor[Symbol.species] = function () {} + +assert.sameValue(Object.getPrototypeOf(a.toReversed()), Array.prototype); + +var b = []; + +Object.defineProperty(b, "constructor", { + get() { + throw new Test262Error("Should not get .constructor"); + } +}); + +b.toReversed(); diff --git a/test/built-ins/Array/prototype/toReversed/immutable.js b/test/built-ins/Array/prototype/toReversed/immutable.js new file mode 100644 index 00000000000..98f885b6f79 --- /dev/null +++ b/test/built-ins/Array/prototype/toReversed/immutable.js @@ -0,0 +1,14 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toReversed +description: > + Array.prototype.toReversed does not mutate its this value +features: [change-array-by-copy] +---*/ + +var arr = [0, 1, 2]; +arr.toReversed(); + +assert.deepEqual(arr, [0, 1, 2]); diff --git a/test/built-ins/Array/prototype/toReversed/length-casted-to-zero.js b/test/built-ins/Array/prototype/toReversed/length-casted-to-zero.js new file mode 100644 index 00000000000..2ba470c9f13 --- /dev/null +++ b/test/built-ins/Array/prototype/toReversed/length-casted-to-zero.js @@ -0,0 +1,19 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toReversed +description: > + Array.prototype.toReversed creates an empty array if the this value .length is not a positive integer. +info: | + Array.prototype.toReversed ( ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + ... +features: [change-array-by-copy] +---*/ + +assert.deepEqual(Array.prototype.toReversed.call({ length: -2 }), []); +assert.deepEqual(Array.prototype.toReversed.call({ length: "dog" }), []); +assert.deepEqual(Array.prototype.toReversed.call({ length: NaN }), []); diff --git a/test/built-ins/Array/prototype/toReversed/length-decreased-while-iterating.js b/test/built-ins/Array/prototype/toReversed/length-decreased-while-iterating.js new file mode 100644 index 00000000000..0cecbd92e27 --- /dev/null +++ b/test/built-ins/Array/prototype/toReversed/length-decreased-while-iterating.js @@ -0,0 +1,31 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toReversed +description: > + Array.prototype.toReversed caches the length getting the array elements. +info: | + Array.prototype.toReversed ( ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + ... + 5. Repeat, while k < len + ... + c. Let fromValue be ? Get(O, from). + ... +features: [change-array-by-copy] +---*/ + +var arr = [0, 1, 2, 3, 4]; +Array.prototype[4] = 5; + +Object.defineProperty(arr, "2", { + get() { + arr.length = 1; + return 2; + } +}); + +assert.deepEqual(arr.toReversed(), [5, undefined, 2, 1, 0]); diff --git a/test/built-ins/Array/prototype/toReversed/length-exceeding-array-length-limit.js b/test/built-ins/Array/prototype/toReversed/length-exceeding-array-length-limit.js new file mode 100644 index 00000000000..b60b1f7933a --- /dev/null +++ b/test/built-ins/Array/prototype/toReversed/length-exceeding-array-length-limit.js @@ -0,0 +1,38 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toReversed +description: > + Array.prototype.toReversed limits the length to 2 ** 53 - 1 +info: | + Array.prototype.toReversed ( ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + 3. Let A be ? ArrayCreate(𝔽(len)). + ... + + ArrayCreate ( length [, proto ] ) + + 1. If length > 2 ** 31 - 1, throw a RangeError exception. +features: [change-array-by-copy] +---*/ + +// Object with large "length" property +var arrayLike = { + get "0"() { + throw new Test262Error("Get 0"); + }, + get "2147483647" () { // 2 ** 31 - 1 + throw new Test262Error("Get 2147483648"); + }, + get "2147483648" () { // 2 ** 31 + throw new Test262Error("Get 2147483648"); + }, + length: 2 ** 31 +}; + +assert.throws(TypeError, function() { + Array.prototype.toReversed.call(arrayLike); +}); diff --git a/test/built-ins/Array/prototype/toReversed/length-increased-while-iterating.js b/test/built-ins/Array/prototype/toReversed/length-increased-while-iterating.js new file mode 100644 index 00000000000..357178acf93 --- /dev/null +++ b/test/built-ins/Array/prototype/toReversed/length-increased-while-iterating.js @@ -0,0 +1,29 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toReversed +description: > + Array.prototype.toReversed caches the length getting the array elements. +info: | + Array.prototype.toReversed ( ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + ... + 5. Repeat, while k < len + ... + c. Let fromValue be ? Get(O, from). + ... +features: [change-array-by-copy] +---*/ + +var arr = [0, 1, 2]; +Object.defineProperty(arr, "0", { + get() { + arr.push(4); + return 0; + } +}); + +assert.deepEqual(arr.toReversed(), [2, 1, 0]); diff --git a/test/built-ins/Array/prototype/toReversed/length-integer-string.js b/test/built-ins/Array/prototype/toReversed/length-integer-string.js new file mode 100644 index 00000000000..08b54db90ac --- /dev/null +++ b/test/built-ins/Array/prototype/toReversed/length-integer-string.js @@ -0,0 +1,28 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toReversed +description: > + Array.prototype.toReversed converts the this value length to a number. +info: | + Array.prototype.toReversed ( ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + ... +features: [change-array-by-copy] +---*/ + +assert.deepEqual(Array.prototype.toReversed.call({ length: "2", 0: 1, 1: 2, 2: 3 }), [2, 1]); + +var arrayLike = { + length: { + valueOf: () => 2 + }, + 0: 1, + 1: 2, + 2: 3, +}; + +assert.deepEqual(Array.prototype.toReversed.call(arrayLike), [2, 1]); diff --git a/test/built-ins/Array/prototype/toReversed/metadata/length.js b/test/built-ins/Array/prototype/toReversed/metadata/length.js new file mode 100644 index 00000000000..85d98a69da3 --- /dev/null +++ b/test/built-ins/Array/prototype/toReversed/metadata/length.js @@ -0,0 +1,30 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toReversed +description: > + The "length" property of Array.prototype.toReversed +info: | + 17 ECMAScript Standard Built-in Objects + + Every built-in function object, including constructors, has a length property + whose value is an integer. Unless otherwise specified, this value is equal to + the largest number of named arguments shown in the subclause headings for the + function description. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are shown using the form Β«...nameΒ») are not + included in the default argument count. + + Unless otherwise specified, the length property of a built-in function object + has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [change-array-by-copy] +---*/ + +verifyProperty(Array.prototype.toReversed, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true, +}); diff --git a/test/built-ins/Array/prototype/toReversed/metadata/name.js b/test/built-ins/Array/prototype/toReversed/metadata/name.js new file mode 100644 index 00000000000..7ed3e9ad922 --- /dev/null +++ b/test/built-ins/Array/prototype/toReversed/metadata/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toReversed +description: > + Array.prototype.toReversed.name is "toReversed". +info: | + Array.prototype.toReversed ( ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [change-array-by-copy] +---*/ + +verifyProperty(Array.prototype.toReversed, "name", { + value: "toReversed", + writable: false, + enumerable: false, + configurable: true, +}); diff --git a/test/built-ins/Array/prototype/toReversed/metadata/property-descriptor.js b/test/built-ins/Array/prototype/toReversed/metadata/property-descriptor.js new file mode 100644 index 00000000000..f8c0979d9dc --- /dev/null +++ b/test/built-ins/Array/prototype/toReversed/metadata/property-descriptor.js @@ -0,0 +1,25 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toReversed +description: > + "toReversed" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +features: [change-array-by-copy] +---*/ + +assert.sameValue(typeof Array.prototype.toReversed, "function", "typeof"); + +verifyProperty(Array.prototype, "toReversed", { + value: Array.prototype.toReversed, + writable: true, + enumerable: false, + configurable: true, +}); diff --git a/test/built-ins/Array/prototype/toReversed/not-a-constructor.js b/test/built-ins/Array/prototype/toReversed/not-a-constructor.js new file mode 100644 index 00000000000..898b65486bd --- /dev/null +++ b/test/built-ins/Array/prototype/toReversed/not-a-constructor.js @@ -0,0 +1,33 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Array.prototype.toReversed does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [change-array-by-copy] +---*/ + +assert.sameValue( + isConstructor(Array.prototype.toReversed), + false, + 'isConstructor(Array.prototype.toReversed) must return false' +); + +assert.throws(TypeError, () => { + new Array.prototype.toReversed(); +}, '`new Array.prototype.toReversed()` throws TypeError'); + diff --git a/test/built-ins/Array/prototype/toReversed/this-value-boolean.js b/test/built-ins/Array/prototype/toReversed/this-value-boolean.js new file mode 100644 index 00000000000..23366c74e48 --- /dev/null +++ b/test/built-ins/Array/prototype/toReversed/this-value-boolean.js @@ -0,0 +1,18 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toReversed +description: > + Array.prototype.toReversed throws if the receiver is null or undefined +info: | + Array.prototype.toReversed ( ) + + 1. Let O be ? ToObject(this value). + 2. Let len be ? LengthOfArrayLike(O). + ... +features: [change-array-by-copy] +---*/ + +assert.deepEqual(Array.prototype.toReversed.call(true), []); +assert.deepEqual(Array.prototype.toReversed.call(false), []); diff --git a/test/built-ins/Array/prototype/toReversed/this-value-nullish.js b/test/built-ins/Array/prototype/toReversed/this-value-nullish.js new file mode 100644 index 00000000000..41371b57c63 --- /dev/null +++ b/test/built-ins/Array/prototype/toReversed/this-value-nullish.js @@ -0,0 +1,22 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toReversed +description: > + Array.prototype.toReversed throws if the receiver is null or undefined +info: | + Array.prototype.toReversed ( ) + + 1. Let O be ? ToObject(this value). + ... +features: [change-array-by-copy] +---*/ + +assert.throws(TypeError, () => { + Array.prototype.toReversed.call(null); +}, '`Array.prototype.toReversed.call(null)` throws TypeError'); + +assert.throws(TypeError, () => { + Array.prototype.toReversed.call(undefined); +}, '`Array.prototype.toReversed.call(undefined)` throws TypeError'); diff --git a/test/built-ins/Array/prototype/toReversed/zero-or-one-element.js b/test/built-ins/Array/prototype/toReversed/zero-or-one-element.js new file mode 100644 index 00000000000..e76a809697e --- /dev/null +++ b/test/built-ins/Array/prototype/toReversed/zero-or-one-element.js @@ -0,0 +1,19 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toReversed +description: > + Array.prototype.toReversed returns a new array even if it has zero or one elements +features: [change-array-by-copy] +---*/ + +var zero = []; +var zeroReversed = zero.toReversed(); +assert.notSameValue(zero, zeroReversed); +assert.deepEqual(zero, zeroReversed); + +var one = [1]; +var oneReversed = one.toReversed(); +assert.notSameValue(one, oneReversed); +assert.deepEqual(one, oneReversed); From d3978b6a4581a3b8428bce9c2c3cb3a56c400d7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Fri, 10 Dec 2021 13:00:35 +0100 Subject: [PATCH 03/86] Add `Array.prototype.toSorted` tests --- .../comparefn-called-after-get-elements.js | 43 +++++++++++++++++ .../toSorted/comparefn-not-a-function.js | 33 +++++++++++++ .../toSorted/comparefn-stop-after-error.js | 46 +++++++++++++++++++ .../prototype/toSorted/frozen-this-value.js | 15 ++++++ .../prototype/toSorted/holes-not-preserved.js | 29 ++++++++++++ .../prototype/toSorted/ignores-species.js | 30 ++++++++++++ .../Array/prototype/toSorted/immutable.js | 14 ++++++ .../toSorted/length-casted-to-zero.js | 19 ++++++++ .../length-decreased-while-iterating.js | 32 +++++++++++++ .../length-exceeding-array-length-limit.js | 39 ++++++++++++++++ .../length-increased-while-iterating.js | 30 ++++++++++++ .../toSorted/length-integer-string.js | 28 +++++++++++ .../prototype/toSorted/metadata/length.js | 30 ++++++++++++ .../Array/prototype/toSorted/metadata/name.js | 28 +++++++++++ .../toSorted/metadata/property-descriptor.js | 25 ++++++++++ .../prototype/toSorted/not-a-constructor.js | 33 +++++++++++++ .../prototype/toSorted/this-value-boolean.js | 18 ++++++++ .../prototype/toSorted/this-value-nullish.js | 22 +++++++++ .../prototype/toSorted/zero-or-one-element.js | 19 ++++++++ 19 files changed, 533 insertions(+) create mode 100644 test/built-ins/Array/prototype/toSorted/comparefn-called-after-get-elements.js create mode 100644 test/built-ins/Array/prototype/toSorted/comparefn-not-a-function.js create mode 100644 test/built-ins/Array/prototype/toSorted/comparefn-stop-after-error.js create mode 100644 test/built-ins/Array/prototype/toSorted/frozen-this-value.js create mode 100644 test/built-ins/Array/prototype/toSorted/holes-not-preserved.js create mode 100644 test/built-ins/Array/prototype/toSorted/ignores-species.js create mode 100644 test/built-ins/Array/prototype/toSorted/immutable.js create mode 100644 test/built-ins/Array/prototype/toSorted/length-casted-to-zero.js create mode 100644 test/built-ins/Array/prototype/toSorted/length-decreased-while-iterating.js create mode 100644 test/built-ins/Array/prototype/toSorted/length-exceeding-array-length-limit.js create mode 100644 test/built-ins/Array/prototype/toSorted/length-increased-while-iterating.js create mode 100644 test/built-ins/Array/prototype/toSorted/length-integer-string.js create mode 100644 test/built-ins/Array/prototype/toSorted/metadata/length.js create mode 100644 test/built-ins/Array/prototype/toSorted/metadata/name.js create mode 100644 test/built-ins/Array/prototype/toSorted/metadata/property-descriptor.js create mode 100644 test/built-ins/Array/prototype/toSorted/not-a-constructor.js create mode 100644 test/built-ins/Array/prototype/toSorted/this-value-boolean.js create mode 100644 test/built-ins/Array/prototype/toSorted/this-value-nullish.js create mode 100644 test/built-ins/Array/prototype/toSorted/zero-or-one-element.js diff --git a/test/built-ins/Array/prototype/toSorted/comparefn-called-after-get-elements.js b/test/built-ins/Array/prototype/toSorted/comparefn-called-after-get-elements.js new file mode 100644 index 00000000000..7ee184c87b5 --- /dev/null +++ b/test/built-ins/Array/prototype/toSorted/comparefn-called-after-get-elements.js @@ -0,0 +1,43 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSorted +description: > + Array.prototype.toSorted reads all the array elements before calling compareFn +info: | + Array.prototype.toSorted ( compareFn ) + + ... + 6. Repeat, while k < len, + a. Let Pk be ! ToString(𝔽(k)). + b. Let kValue be ? Get(O, Pk). + c. Append kValue to items. + d. Set k to k + 1. + 7. Sort items using an implementation-defined sequence of + calls to SortCompare. If any such call returns an abrupt + completion, stop before performing any further calls to + SortCompare or steps in this algorithm and return that completion. + ... +features: [change-array-by-copy] +---*/ + +var getCalls = []; + +var arrayLike = { + length: 3, + get 0() { getCalls.push(0); return 2; }, + get 1() { getCalls.push(1); return 1; }, + get 2() { getCalls.push(2); return 3; }, + +} + +function StopToSorted() {} + +assert.throws(StopToSorted, function() { + Array.prototype.toSorted.call(arrayLike, () => { + throw new StopToSorted(); + }); +}); + +assert.deepEqual(getCalls, [0, 1, 2]); diff --git a/test/built-ins/Array/prototype/toSorted/comparefn-not-a-function.js b/test/built-ins/Array/prototype/toSorted/comparefn-not-a-function.js new file mode 100644 index 00000000000..ce51b4724c9 --- /dev/null +++ b/test/built-ins/Array/prototype/toSorted/comparefn-not-a-function.js @@ -0,0 +1,33 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSorted +description: > + Array.prototype.toSorted verifies that the comparator is callable before reading the length. +info: | + Array.prototype.toSorted ( compareFn ) + + 1. If comparefn is not undefined and IsCallable(comparefn) is false, throw a TypeError exception. + 2. ... + 3. Let len be ? LengthOfArrayLike(O). +features: [change-array-by-copy] +---*/ + +var getLengthThrow = { + get length() { + throw new Test262Error("IsCallable(comparefn) should be observed before this.length"); + } +}; + +var invalidComparators = [null, true, false, "", /a/g, 42, [], {}, Symbol()]; + +for (var i = 0; i < invalidComparators.length; i++) { + assert.throws(TypeError, function() { + [1].toSorted(invalidComparators[i]); + }, invalidComparators[i]); + + assert.throws(TypeError, function() { + Array.prototype.toSorted.call(getLengthThrow, invalidComparators[i]); + }, invalidComparators[i]); +} diff --git a/test/built-ins/Array/prototype/toSorted/comparefn-stop-after-error.js b/test/built-ins/Array/prototype/toSorted/comparefn-stop-after-error.js new file mode 100644 index 00000000000..40e89830ccb --- /dev/null +++ b/test/built-ins/Array/prototype/toSorted/comparefn-stop-after-error.js @@ -0,0 +1,46 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSorted +description: > + Array.prototype.toSorted doesn't call copmareFn if there is an error +info: | + Array.prototype.toSorted ( compareFn ) + + ... + 7. Sort items using an implementation-defined sequence of + calls to SortCompare. If any such call returns an abrupt + completion, stop before performing any further calls to + SortCompare or steps in this algorithm and return that completion. + ... +features: [change-array-by-copy] +---*/ + +function StopToSorted() {} + +var arrayLike = { + length: 1, + get 0() { throw new StopToSorted(); }, +}; + +var called = false; +assert.throws(StopToSorted, function() { + Array.prototype.toSorted.call(arrayLike, () => { + called = true; + }); +}); +assert.sameValue(called, false); + +called = false; +assert.throws(StopToSorted, function() { + var first = true; + [1, 2, 3].toSorted(() => { + if (first) { + first = false; + throw new StopToSorted(); + } + called = true; + }); +}); +assert.sameValue(called, false); diff --git a/test/built-ins/Array/prototype/toSorted/frozen-this-value.js b/test/built-ins/Array/prototype/toSorted/frozen-this-value.js new file mode 100644 index 00000000000..03ef85084ae --- /dev/null +++ b/test/built-ins/Array/prototype/toSorted/frozen-this-value.js @@ -0,0 +1,15 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSorted +description: > + Array.prototype.toSorted works on frozen objects +features: [change-array-by-copy] +---*/ + +var arr = Object.freeze([2, 0, 1]); +arr.toSorted(); + +var arrayLike = Object.freeze({ length: 3, 0: 2, 1: 0, 2: 1 }); +Array.prototype.toSorted.call(arrayLike); diff --git a/test/built-ins/Array/prototype/toSorted/holes-not-preserved.js b/test/built-ins/Array/prototype/toSorted/holes-not-preserved.js new file mode 100644 index 00000000000..3d6121b3887 --- /dev/null +++ b/test/built-ins/Array/prototype/toSorted/holes-not-preserved.js @@ -0,0 +1,29 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSorted +description: > + Array.prototype.toSorted does not preserve holes in the array +info: | + Array.prototype.toSorted ( compareFn ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + 4. Let items be a new empty List. + 5. Let k be 0. + 6. Repeat, while k < len, + a. Let Pk be ! ToString(𝔽(k)). + b. Let kValue be ? Get(O, Pk). + c. Append kValue to items. + d. Set k to k + 1. + ... +features: [change-array-by-copy] +---*/ + +var arr = [3, /* hole */, 4, /* hole */, 1]; +Array.prototype[3] = 2; + +var sorted = arr.toSorted(); +assert.deepEqual(sorted, [1, 2, 3, 4, undefined]); +assert(sorted.hasOwnProperty(4)); diff --git a/test/built-ins/Array/prototype/toSorted/ignores-species.js b/test/built-ins/Array/prototype/toSorted/ignores-species.js new file mode 100644 index 00000000000..18ca34229c4 --- /dev/null +++ b/test/built-ins/Array/prototype/toSorted/ignores-species.js @@ -0,0 +1,30 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSorted +description: > + Array.prototype.toSorted throws if the receiver is null or undefined +info: | + Array.prototype.toSorted ( compareFn ) + + ... + 8. Let A be ? ArrayCreate(𝔽(len)). + ... +features: [change-array-by-copy] +---*/ + +var a = []; +a.constructor = {}; +a.constructor[Symbol.species] = function () {} + +assert.sameValue(Object.getPrototypeOf(a.toSorted()), Array.prototype); + +var b = []; +Object.defineProperty(b, "constructor", { + get() { + throw new Test262Error("Should not get .constructor"); + } +}); + +b.toSorted(); diff --git a/test/built-ins/Array/prototype/toSorted/immutable.js b/test/built-ins/Array/prototype/toSorted/immutable.js new file mode 100644 index 00000000000..535625ed2d7 --- /dev/null +++ b/test/built-ins/Array/prototype/toSorted/immutable.js @@ -0,0 +1,14 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSorted +description: > + Array.prototype.toSorted does not mutate its this value +features: [change-array-by-copy] +---*/ + +var arr = [2, 0, 1]; +arr.toSorted(); + +assert.deepEqual(arr, [2, 0, 1]); diff --git a/test/built-ins/Array/prototype/toSorted/length-casted-to-zero.js b/test/built-ins/Array/prototype/toSorted/length-casted-to-zero.js new file mode 100644 index 00000000000..ee6ce838424 --- /dev/null +++ b/test/built-ins/Array/prototype/toSorted/length-casted-to-zero.js @@ -0,0 +1,19 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSorted +description: > + Array.prototype.toSorted creates an empty array if the this value .length is not a positive integer. +info: | + Array.prototype.toSorted ( compareFn ) + + ... + 3. Let len be ? LengthOfArrayLike(O). + ... +features: [change-array-by-copy] +---*/ + +assert.deepEqual(Array.prototype.toSorted.call({ length: -2 }), []); +assert.deepEqual(Array.prototype.toSorted.call({ length: "dog" }), []); +assert.deepEqual(Array.prototype.toSorted.call({ length: NaN }), []); diff --git a/test/built-ins/Array/prototype/toSorted/length-decreased-while-iterating.js b/test/built-ins/Array/prototype/toSorted/length-decreased-while-iterating.js new file mode 100644 index 00000000000..bca16ed204e --- /dev/null +++ b/test/built-ins/Array/prototype/toSorted/length-decreased-while-iterating.js @@ -0,0 +1,32 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSorted +description: > + Array.prototype.toSorted caches the length getting the array elements. +info: | + Array.prototype.toSorted ( compareFn ) + + ... + 3. Let len be ? LengthOfArrayLike(O). + ... + 5. Let k be 0. + 6. Repeat, while k < len, + a. Let Pk be ! ToString(𝔽(k)). + b. Let kValue be ? Get(O, Pk). + ... +features: [change-array-by-copy] +---*/ + +var arr = [5, 1, 4, 6, 3]; +Array.prototype[3] = 2; + +Object.defineProperty(arr, "2", { + get() { + arr.length = 1; + return 4; + } +}); + +assert.deepEqual(arr.toSorted(), [1, 2, 4, 5]); diff --git a/test/built-ins/Array/prototype/toSorted/length-exceeding-array-length-limit.js b/test/built-ins/Array/prototype/toSorted/length-exceeding-array-length-limit.js new file mode 100644 index 00000000000..7ef4db6a684 --- /dev/null +++ b/test/built-ins/Array/prototype/toSorted/length-exceeding-array-length-limit.js @@ -0,0 +1,39 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSorted +description: > + Array.prototype.toSorted limits the length to 2 ** 53 - 1 +info: | + Array.prototype.toSorted ( compareFn ) + + ... + 3. Let len be ? LengthOfArrayLike(O). + ... + 8. Let A be ? ArrayCreate(𝔽(len)). + ... + + ArrayCreate ( length [, proto ] ) + + 1. If length > 2 ** 31 - 1, throw a RangeError exception. +features: [change-array-by-copy] +---*/ + +// Object with large "length" property +var arrayLike = { + get "0"() { + throw new Test262Error("Get 0"); + }, + get "2147483647" () { // 2 ** 31 - 1 + throw new Test262Error("Get 2147483648"); + }, + get "2147483648" () { // 2 ** 31 + throw new Test262Error("Get 2147483648"); + }, + length: 2 ** 31 +}; + +assert.throws(TypeError, function() { + Array.prototype.toSorted.call(arrayLike); +}); diff --git a/test/built-ins/Array/prototype/toSorted/length-increased-while-iterating.js b/test/built-ins/Array/prototype/toSorted/length-increased-while-iterating.js new file mode 100644 index 00000000000..f7c798b053d --- /dev/null +++ b/test/built-ins/Array/prototype/toSorted/length-increased-while-iterating.js @@ -0,0 +1,30 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSorted +description: > + Array.prototype.toSorted caches the length getting the array elements. +info: | + Array.prototype.toSorted ( compareFn ) + + ... + 3. Let len be ? LengthOfArrayLike(O). + ... + 5. Let k be 0. + 6. Repeat, while k < len, + a. Let Pk be ! ToString(𝔽(k)). + b. Let kValue be ? Get(O, Pk). + ... +features: [change-array-by-copy] +---*/ + +var arr = [5, 0, 3]; +Object.defineProperty(arr, "0", { + get() { + arr.push(1); + return 5; + } +}); + +assert.deepEqual(arr.toSorted(), [0, 3, 5]); diff --git a/test/built-ins/Array/prototype/toSorted/length-integer-string.js b/test/built-ins/Array/prototype/toSorted/length-integer-string.js new file mode 100644 index 00000000000..d294c03dd8a --- /dev/null +++ b/test/built-ins/Array/prototype/toSorted/length-integer-string.js @@ -0,0 +1,28 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSorted +description: > + Array.prototype.toSorted converts the this value length to a number. +info: | + Array.prototype.toSorted ( compareFn ) + + ... + 3. Let len be ? LengthOfArrayLike(O). + ... +features: [change-array-by-copy] +---*/ + +assert.deepEqual(Array.prototype.toSorted.call({ length: "2", 0: 4, 1: 0, 2: 1 }), [0, 4]); + +var arrayLike = { + length: { + valueOf: () => 2 + }, + 0: 4, + 1: 0, + 2: 1, +}; + +assert.deepEqual(Array.prototype.toSorted.call(arrayLike), [0, 4]); diff --git a/test/built-ins/Array/prototype/toSorted/metadata/length.js b/test/built-ins/Array/prototype/toSorted/metadata/length.js new file mode 100644 index 00000000000..34bac5998be --- /dev/null +++ b/test/built-ins/Array/prototype/toSorted/metadata/length.js @@ -0,0 +1,30 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSorted +description: > + The "length" property of Array.prototype.toSorted +info: | + 17 ECMAScript Standard Built-in Objects + + Every built-in function object, including constructors, has a length property + whose value is an integer. Unless otherwise specified, this value is equal to + the largest number of named arguments shown in the subclause headings for the + function description. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are shown using the form Β«...nameΒ») are not + included in the default argument count. + + Unless otherwise specified, the length property of a built-in function object + has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [change-array-by-copy] +---*/ + +verifyProperty(Array.prototype.toSorted, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true, +}); diff --git a/test/built-ins/Array/prototype/toSorted/metadata/name.js b/test/built-ins/Array/prototype/toSorted/metadata/name.js new file mode 100644 index 00000000000..a5ca772efeb --- /dev/null +++ b/test/built-ins/Array/prototype/toSorted/metadata/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSorted +description: > + Array.prototype.toSorted.name is "toSorted". +info: | + Array.prototype.toSorted ( compareFn ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [change-array-by-copy] +---*/ + +verifyProperty(Array.prototype.toSorted, "name", { + value: "toSorted", + writable: false, + enumerable: false, + configurable: true, +}); diff --git a/test/built-ins/Array/prototype/toSorted/metadata/property-descriptor.js b/test/built-ins/Array/prototype/toSorted/metadata/property-descriptor.js new file mode 100644 index 00000000000..27b2e108766 --- /dev/null +++ b/test/built-ins/Array/prototype/toSorted/metadata/property-descriptor.js @@ -0,0 +1,25 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSorted +description: > + "toSorted" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +features: [change-array-by-copy] +---*/ + +assert.sameValue(typeof Array.prototype.toSorted, "function", "typeof"); + +verifyProperty(Array.prototype, "toSorted", { + value: Array.prototype.toSorted, + writable: true, + enumerable: false, + configurable: true, +}); diff --git a/test/built-ins/Array/prototype/toSorted/not-a-constructor.js b/test/built-ins/Array/prototype/toSorted/not-a-constructor.js new file mode 100644 index 00000000000..13f729d417b --- /dev/null +++ b/test/built-ins/Array/prototype/toSorted/not-a-constructor.js @@ -0,0 +1,33 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Array.prototype.toSorted does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [change-array-by-copy] +---*/ + +assert.sameValue( + isConstructor(Array.prototype.toSorted), + false, + 'isConstructor(Array.prototype.toSorted) must return false' +); + +assert.throws(TypeError, () => { + new Array.prototype.toSorted(); +}, '`new Array.prototype.toSorted()` throws TypeError'); + diff --git a/test/built-ins/Array/prototype/toSorted/this-value-boolean.js b/test/built-ins/Array/prototype/toSorted/this-value-boolean.js new file mode 100644 index 00000000000..492dd9f5b6a --- /dev/null +++ b/test/built-ins/Array/prototype/toSorted/this-value-boolean.js @@ -0,0 +1,18 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSorted +description: > + Array.prototype.toSorted throws if the receiver is null or undefined +info: | + Array.prototype.toSorted ( compareFn ) + + 1. Let O be ? ToObject(this value). + 2. Let len be ? LengthOfArrayLike(O). + ... +features: [change-array-by-copy] +---*/ + +assert.deepEqual(Array.prototype.toSorted.call(true), []); +assert.deepEqual(Array.prototype.toSorted.call(false), []); diff --git a/test/built-ins/Array/prototype/toSorted/this-value-nullish.js b/test/built-ins/Array/prototype/toSorted/this-value-nullish.js new file mode 100644 index 00000000000..2e5b58e22fc --- /dev/null +++ b/test/built-ins/Array/prototype/toSorted/this-value-nullish.js @@ -0,0 +1,22 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSorted +description: > + Array.prototype.toSorted throws if the receiver is null or undefined +info: | + Array.prototype.toSorted ( compareFn ) + + 1. Let O be ? ToObject(this value). + ... +features: [change-array-by-copy] +---*/ + +assert.throws(TypeError, () => { + Array.prototype.toSorted.call(null); +}, '`Array.prototype.toSorted.call(null)` throws TypeError'); + +assert.throws(TypeError, () => { + Array.prototype.toSorted.call(undefined); +}, '`Array.prototype.toSorted.call(undefined)` throws TypeError'); diff --git a/test/built-ins/Array/prototype/toSorted/zero-or-one-element.js b/test/built-ins/Array/prototype/toSorted/zero-or-one-element.js new file mode 100644 index 00000000000..46d121c0f49 --- /dev/null +++ b/test/built-ins/Array/prototype/toSorted/zero-or-one-element.js @@ -0,0 +1,19 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSorted +description: > + Array.prototype.toSorted returns a new array even if it has zero or one elements +features: [change-array-by-copy] +---*/ + +var zero = []; +var zeroReversed = zero.toSorted(); +assert.notSameValue(zero, zeroReversed); +assert.deepEqual(zero, zeroReversed); + +var one = [1]; +var oneReversed = one.toSorted(); +assert.notSameValue(one, oneReversed); +assert.deepEqual(one, oneReversed); From 2a2dbd212f83767caea923d63a330d5994de8270 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Mon, 13 Dec 2021 15:00:49 +0100 Subject: [PATCH 04/86] Add `Array.prototype.toSpliced` tests --- ...lamped-between-zero-and-remaining-count.js | 35 +++++++++ .../toSpliced/deleteCount-missing.js | 18 +++++ .../toSpliced/deleteCount-undefined.js | 24 +++++++ .../toSpliced/discarded-element-not-read.js | 31 ++++++++ .../toSpliced/elements-read-in-order.js | 35 +++++++++ .../prototype/toSpliced/frozen-this-value.js | 16 +++++ .../toSpliced/holes-not-preserved.js | 38 ++++++++++ .../prototype/toSpliced/ignores-species.js | 30 ++++++++ .../Array/prototype/toSpliced/immutable.js | 14 ++++ .../toSpliced/length-casted-to-zero.js | 19 +++++ .../length-clamped-to-2pow53minus1.js | 72 +++++++++++++++++++ .../length-decreased-while-iterating.js | 43 +++++++++++ .../length-exceeding-array-length-limit.js | 45 ++++++++++++ .../length-increased-while-iterating.js | 36 ++++++++++ .../toSpliced/length-integer-string.js | 28 ++++++++ .../prototype/toSpliced/metadata/length.js | 30 ++++++++ .../prototype/toSpliced/metadata/name.js | 28 ++++++++ .../toSpliced/metadata/property-descriptor.js | 25 +++++++ .../prototype/toSpliced/not-a-constructor.js | 33 +++++++++ .../start-and-deleteCount-missing.js | 22 ++++++ .../start-and-deleteCount-undefineds.js | 24 +++++++ .../toSpliced/start-bigger-than-length.js | 22 ++++++ .../toSpliced/start-neg-infinity-is-zero.js | 21 ++++++ ...tart-neg-less-than-minus-length-is-zero.js | 21 ++++++ .../start-neg-subtracted-from-length.js | 21 ++++++ ...start-undefined-and-deleteCount-missing.js | 24 +++++++ .../prototype/toSpliced/this-value-boolean.js | 18 +++++ .../prototype/toSpliced/this-value-nullish.js | 22 ++++++ .../Array/prototype/toSpliced/unmodified.js | 14 ++++ 29 files changed, 809 insertions(+) create mode 100644 test/built-ins/Array/prototype/toSpliced/deleteCount-clamped-between-zero-and-remaining-count.js create mode 100644 test/built-ins/Array/prototype/toSpliced/deleteCount-missing.js create mode 100644 test/built-ins/Array/prototype/toSpliced/deleteCount-undefined.js create mode 100644 test/built-ins/Array/prototype/toSpliced/discarded-element-not-read.js create mode 100644 test/built-ins/Array/prototype/toSpliced/elements-read-in-order.js create mode 100644 test/built-ins/Array/prototype/toSpliced/frozen-this-value.js create mode 100644 test/built-ins/Array/prototype/toSpliced/holes-not-preserved.js create mode 100644 test/built-ins/Array/prototype/toSpliced/ignores-species.js create mode 100644 test/built-ins/Array/prototype/toSpliced/immutable.js create mode 100644 test/built-ins/Array/prototype/toSpliced/length-casted-to-zero.js create mode 100644 test/built-ins/Array/prototype/toSpliced/length-clamped-to-2pow53minus1.js create mode 100644 test/built-ins/Array/prototype/toSpliced/length-decreased-while-iterating.js create mode 100644 test/built-ins/Array/prototype/toSpliced/length-exceeding-array-length-limit.js create mode 100644 test/built-ins/Array/prototype/toSpliced/length-increased-while-iterating.js create mode 100644 test/built-ins/Array/prototype/toSpliced/length-integer-string.js create mode 100644 test/built-ins/Array/prototype/toSpliced/metadata/length.js create mode 100644 test/built-ins/Array/prototype/toSpliced/metadata/name.js create mode 100644 test/built-ins/Array/prototype/toSpliced/metadata/property-descriptor.js create mode 100644 test/built-ins/Array/prototype/toSpliced/not-a-constructor.js create mode 100644 test/built-ins/Array/prototype/toSpliced/start-and-deleteCount-missing.js create mode 100644 test/built-ins/Array/prototype/toSpliced/start-and-deleteCount-undefineds.js create mode 100644 test/built-ins/Array/prototype/toSpliced/start-bigger-than-length.js create mode 100644 test/built-ins/Array/prototype/toSpliced/start-neg-infinity-is-zero.js create mode 100644 test/built-ins/Array/prototype/toSpliced/start-neg-less-than-minus-length-is-zero.js create mode 100644 test/built-ins/Array/prototype/toSpliced/start-neg-subtracted-from-length.js create mode 100644 test/built-ins/Array/prototype/toSpliced/start-undefined-and-deleteCount-missing.js create mode 100644 test/built-ins/Array/prototype/toSpliced/this-value-boolean.js create mode 100644 test/built-ins/Array/prototype/toSpliced/this-value-nullish.js create mode 100644 test/built-ins/Array/prototype/toSpliced/unmodified.js diff --git a/test/built-ins/Array/prototype/toSpliced/deleteCount-clamped-between-zero-and-remaining-count.js b/test/built-ins/Array/prototype/toSpliced/deleteCount-clamped-between-zero-and-remaining-count.js new file mode 100644 index 00000000000..1504c27655a --- /dev/null +++ b/test/built-ins/Array/prototype/toSpliced/deleteCount-clamped-between-zero-and-remaining-count.js @@ -0,0 +1,35 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: deleteCount is clamped between zero and len - actualStart +info: | + 22.1.3.25 Array.prototype.toSpliced (start, deleteCount , ...items ) + + ... + 10. Else, + a. Let actualDeleteCount be len - actualStart. + b. Let actualDeleteCount be the result of clamping dc between 0 and len - actualStart. + ... +---*/ + +assert.deepEqual( + [0, 1, 2, 3, 4, 5].toSpliced(2, -1), + [0, 1, 2, 3, 4, 5] +); + +assert.deepEqual( + [0, 1, 2, 3, 4, 5].toSpliced(-4, -1), + [0, 1, 2, 3, 4, 5] +); + +assert.deepEqual( + [0, 1, 2, 3, 4, 5].toSpliced(2, 6), + [0, 1] +); + +assert.deepEqual( + [0, 1, 2, 3, 4, 5].toSpliced(-4, 6), + [0, 1] +); diff --git a/test/built-ins/Array/prototype/toSpliced/deleteCount-missing.js b/test/built-ins/Array/prototype/toSpliced/deleteCount-missing.js new file mode 100644 index 00000000000..658ef436fad --- /dev/null +++ b/test/built-ins/Array/prototype/toSpliced/deleteCount-missing.js @@ -0,0 +1,18 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: Array.prototype.toSpliced deletes the elements after start when called with one argument +info: | + 22.1.3.25 Array.prototype.toSpliced (start, deleteCount , ...items ) + + ... + 9. Else if deleteCount is not present, then + a. Let actualDeleteCount be len - actualStart. + ... +---*/ + +var result = ["first", "second", "third"].toSpliced(1); + +assert.deepEqual(result, ["first"]); diff --git a/test/built-ins/Array/prototype/toSpliced/deleteCount-undefined.js b/test/built-ins/Array/prototype/toSpliced/deleteCount-undefined.js new file mode 100644 index 00000000000..53fe720f4be --- /dev/null +++ b/test/built-ins/Array/prototype/toSpliced/deleteCount-undefined.js @@ -0,0 +1,24 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: Array.prototype.toSpliced(number, undefined) returns a copy of the original array +info: | + 22.1.3.25 Array.prototype.toSpliced (start, deleteCount , ...items ) + + ... + 3. Let relativeStart be ? ToIntegerOrInfinity(start). + ... + 6. Else, let actualStart be min(relativeStart, len). + ... + 8. If start is not present, then + a. Let actualDeleteCount be 0. + 8. Else if deleteCount is not present, then + a. Let actualDeleteCount be len - actualStart. + ... +---*/ + +var result = ["first", "second", "third"].toSpliced(1, undefined); + +assert.deepEqual(result, ["first", "second", "third"]); diff --git a/test/built-ins/Array/prototype/toSpliced/discarded-element-not-read.js b/test/built-ins/Array/prototype/toSpliced/discarded-element-not-read.js new file mode 100644 index 00000000000..1743fdb740e --- /dev/null +++ b/test/built-ins/Array/prototype/toSpliced/discarded-element-not-read.js @@ -0,0 +1,31 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: Array.prototype.toSpliced(undefined, undefined) returns a copy of the original array +info: | + 22.1.3.25 Array.prototype.toSpliced (start, deleteCount , ...items ) + + ... + 3. Let relativeStart be ? ToIntegerOrInfinity(start). + ... + 6. Else, let actualStart be min(relativeStart, len). + ... + 8. If start is not present, then + a. Let actualDeleteCount be 0. + 8. Else if deleteCount is not present, then + a. Let actualDeleteCount be len - actualStart. + ... +---*/ + +var arrayLike = { + 0: "a", + 1: "b", + get 2() { throw new Test262Error(); }, + 3: "c", + length: 4, +}; + +var result = Array.prototype.toSpliced.call(arrayLike, 2, 1); +assert.deepEqual(result, ["a", "b", "c"]); diff --git a/test/built-ins/Array/prototype/toSpliced/elements-read-in-order.js b/test/built-ins/Array/prototype/toSpliced/elements-read-in-order.js new file mode 100644 index 00000000000..f8d6458c068 --- /dev/null +++ b/test/built-ins/Array/prototype/toSpliced/elements-read-in-order.js @@ -0,0 +1,35 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: Array.prototype.toSpliced(undefined, undefined) returns a copy of the original array +info: | + 22.1.3.25 Array.prototype.toSpliced (start, deleteCount , ...items ) + + ... + 3. Let relativeStart be ? ToIntegerOrInfinity(start). + ... + 6. Else, let actualStart be min(relativeStart, len). + ... + 8. If start is not present, then + a. Let actualDeleteCount be 0. + 8. Else if deleteCount is not present, then + a. Let actualDeleteCount be len - actualStart. + ... +---*/ + +var order = []; + +var arrayLike = { + get 0() { order.push(0); return "a" }, + get 1() { order.push(1); return "b" }, + 2: "none", + get 3() { order.push(3); return "c" }, + length: 4, +}; + +var result = Array.prototype.toSpliced.call(arrayLike, 2, 1); +assert.deepEqual(result, ["a", "b", "c"]); + +assert.deepEqual(order, [0, 1, 3]); diff --git a/test/built-ins/Array/prototype/toSpliced/frozen-this-value.js b/test/built-ins/Array/prototype/toSpliced/frozen-this-value.js new file mode 100644 index 00000000000..c68fa35b142 --- /dev/null +++ b/test/built-ins/Array/prototype/toSpliced/frozen-this-value.js @@ -0,0 +1,16 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced works on frozen objects +features: [change-array-by-copy] +---*/ + +var arr = Object.freeze([2, 0, 1]); +arr.toSpliced(); + +var arrayLike = Object.freeze({ length: 3, 0: 0, 1: 1, 2: 2 }); + +assert.deepEqual(Array.prototype.toSpliced.call(1, 1, 4, 5), [0, 4, 5, 2]); diff --git a/test/built-ins/Array/prototype/toSpliced/holes-not-preserved.js b/test/built-ins/Array/prototype/toSpliced/holes-not-preserved.js new file mode 100644 index 00000000000..9bb44bcf0cd --- /dev/null +++ b/test/built-ins/Array/prototype/toSpliced/holes-not-preserved.js @@ -0,0 +1,38 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced does not preserve holes in the array +info: | + Array.prototype.toSpliced ( start, deleteCount, ...items ) + + ... + 13. Let k be 0. + 14. Repeat, while k < actualStart, + a. Let Pk be ! ToString(𝔽(k)). + b. Let kValue be ? Get(O, Pk). + c. Perform ? CreateDataPropertyOrThrow(A, Pk, kValue). + d. Set k to k + 1. + ... + 16. Repeat, while k < newLen, + a. Let Pk be ! ToString(𝔽(k)). + b. Let from be ! ToString(𝔽(k + actualDeleteCount - insertCount)). + c. Let fromValue be ? Get(O, from). + d. Perform ? CreateDataPropertyOrThrow(A, Pk, fromValue). + e. Set k to k + 1. + ... +features: [change-array-by-copy] +---*/ + +var arr = [0, /* hole */, 2, /* hole */, 4]; +Array.prototype[3] = 3; + +var spliced = arr.toSpliced(0, 0); +assert.deepEqual(spliced, [0, undefined, 2, 3, 4]); +assert(spliced.hasOwnProperty(1)); +assert(spliced.hasOwnProperty(3)); + +spliced = arr.toSpliced(0, 0, -1); +assert.deepEqual(spliced, [0, -1, undefined, 2, 3, 4]); diff --git a/test/built-ins/Array/prototype/toSpliced/ignores-species.js b/test/built-ins/Array/prototype/toSpliced/ignores-species.js new file mode 100644 index 00000000000..1343096e0af --- /dev/null +++ b/test/built-ins/Array/prototype/toSpliced/ignores-species.js @@ -0,0 +1,30 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced throws if the receiver is null or undefined +info: | + Array.prototype.toSpliced ( start, deleteCount, ...items ) + + ... + 12. Let A be ? ArrayCreate(𝔽(newLen)). + ... +features: [change-array-by-copy] +---*/ + +var a = []; +a.constructor = {}; +a.constructor[Symbol.species] = function () {} + +assert.sameValue(Object.getPrototypeOf(a.toSpliced(0, 0)), Array.prototype); + +var b = []; +Object.defineProperty(b, "constructor", { + get() { + throw new Test262Error("Should not get .constructor"); + } +}); + +b.toSpliced(0, 0); diff --git a/test/built-ins/Array/prototype/toSpliced/immutable.js b/test/built-ins/Array/prototype/toSpliced/immutable.js new file mode 100644 index 00000000000..2a12ad38a03 --- /dev/null +++ b/test/built-ins/Array/prototype/toSpliced/immutable.js @@ -0,0 +1,14 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced does not mutate its this value +features: [change-array-by-copy] +---*/ + +var arr = [2, 0, 1]; +arr.toSpliced(0, 0, -1); + +assert.deepEqual(arr, [2, 0, 1]); diff --git a/test/built-ins/Array/prototype/toSpliced/length-casted-to-zero.js b/test/built-ins/Array/prototype/toSpliced/length-casted-to-zero.js new file mode 100644 index 00000000000..86635417b91 --- /dev/null +++ b/test/built-ins/Array/prototype/toSpliced/length-casted-to-zero.js @@ -0,0 +1,19 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced creates an empty array if the this value .length is not a positive integer. +info: | + Array.prototype.toSpliced ( start, deleteCount, ...items ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + ... +features: [change-array-by-copy] +---*/ + +assert.deepEqual(Array.prototype.toSpliced.call({ length: -2 }, 0, 0, 2, 3), [2, 3]); +assert.deepEqual(Array.prototype.toSpliced.call({ length: "dog" }, 0, 0, 2, 3), [2, 3]); +assert.deepEqual(Array.prototype.toSpliced.call({ length: NaN }, 0, 0, 2, 3), [2, 3]); diff --git a/test/built-ins/Array/prototype/toSpliced/length-clamped-to-2pow53minus1.js b/test/built-ins/Array/prototype/toSpliced/length-clamped-to-2pow53minus1.js new file mode 100644 index 00000000000..6281e892bcd --- /dev/null +++ b/test/built-ins/Array/prototype/toSpliced/length-clamped-to-2pow53minus1.js @@ -0,0 +1,72 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced caches the length getting the array elements. +info: | + Array.prototype.toSpliced ( start, deleteCount, ...items ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + ... + 11. Let newLen be len + insertCount - actualDeleteCount. + ... + 13. Let k be 0. + 14. Repeat, while k < actualStart, + a. Let Pk be ! ToString(𝔽(k)). + b. Let kValue be ? Get(O, Pk). + c. Perform ? CreateDataPropertyOrThrow(A, Pk, kValue). + d. Set k to k + 1. + ... + 16. Repeat, while k < newLen, + a. Let Pk be ! ToString(𝔽(k)). + b. Let from be ! ToString(𝔽(k + actualDeleteCount - insertCount)). + c. Let fromValue be ? Get(O, from). + d. Perform ? CreateDataPropertyOrThrow(A, Pk, fromValue). + e. Set k to k + 1. + ... + + + ToLength ( argument ) + + 1. Let len be ? ToIntegerOrInfinity(argument). + 2. If len ≀ 0, return +0𝔽. + 3. Return 𝔽(min(len, 253 - 1)). +features: [change-array-by-copy] +---*/ + +// Copyright (C) 2017 AndrΓ© Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: > + Length is clamped to 2^53-1 when they exceed the integer limit. +info: | + ... + 2. Let len be ? LengthOfArrayLike(O). + ... + + ToLength ( argument ) + + 1. Let len be ? ToIntegerOrInfinity(argument). + 2. If len ≀ 0, return +0𝔽. + 3. Return 𝔽(min(len, 253 - 1)) + +includes: [compareArray.js] +---*/ + +var arrayLike = { + "9007199254740990": 2 ** 53 - 2, + "9007199254740991": 2 ** 53 - 1, + "9007199254740992": 2 ** 53, + "9007199254740994": 2 ** 53 + 2, // NOTE: 2 ** 53 + 1 is 2 ** 53 + length: 2 ** 53 + 20, +}; + +var result = Array.prototype.splice.call(arrayLike, 0, 2 ** 53 - 3); + +assert.sameValue(result.length, 2); +assert.deepEqual(result, [2 ** 5 - 2, 2 ** 5 - 1]); diff --git a/test/built-ins/Array/prototype/toSpliced/length-decreased-while-iterating.js b/test/built-ins/Array/prototype/toSpliced/length-decreased-while-iterating.js new file mode 100644 index 00000000000..19d281d30b2 --- /dev/null +++ b/test/built-ins/Array/prototype/toSpliced/length-decreased-while-iterating.js @@ -0,0 +1,43 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced caches the length getting the array elements. +info: | + Array.prototype.toSpliced ( start, deleteCount, ...items ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + ... + 11. Let newLen be len + insertCount - actualDeleteCount. + ... + 13. Let k be 0. + 14. Repeat, while k < actualStart, + a. Let Pk be ! ToString(𝔽(k)). + b. Let kValue be ? Get(O, Pk). + c. Perform ? CreateDataPropertyOrThrow(A, Pk, kValue). + d. Set k to k + 1. + ... + 16. Repeat, while k < newLen, + a. Let Pk be ! ToString(𝔽(k)). + b. Let from be ! ToString(𝔽(k + actualDeleteCount - insertCount)). + c. Let fromValue be ? Get(O, from). + d. Perform ? CreateDataPropertyOrThrow(A, Pk, fromValue). + e. Set k to k + 1. + ... +features: [change-array-by-copy] +---*/ + +var arr = [0, 1, 2, 3, 4, 5]; +Array.prototype[3] = 6; + +Object.defineProperty(arr, "2", { + get() { + arr.length = 1; + return 2; + } +}); + +assert.deepEqual(arr.toSpliced(0, 0), [0, 1, 2, 6, undefined, undefined]); diff --git a/test/built-ins/Array/prototype/toSpliced/length-exceeding-array-length-limit.js b/test/built-ins/Array/prototype/toSpliced/length-exceeding-array-length-limit.js new file mode 100644 index 00000000000..be0f1a45d3b --- /dev/null +++ b/test/built-ins/Array/prototype/toSpliced/length-exceeding-array-length-limit.js @@ -0,0 +1,45 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced limits the length to 2 ** 53 - 1 +info: | + Array.prototype.toSpliced ( start, deleteCount, ...items ) + + ... + 3. Let len be ? LengthOfArrayLike(O). + ... + 11. Let newLen be len + insertCount - actualDeleteCount. + 12. Let A be ? ArrayCreate(𝔽(newLen)). + ... + + ArrayCreate ( length [, proto ] ) + + 1. If length > 2 ** 31 - 1, throw a RangeError exception. +features: [change-array-by-copy] +---*/ + +// Object with large "length" property +var arrayLike = { + get "0" () { + throw new Test262Error("Get 0"); + }, + get "2147483647" () { // 2 ** 31 - 1 + throw new Test262Error("Get 2147483648"); + }, + get "2147483648" () { // 2 ** 31 + throw new Test262Error("Get 2147483648"); + }, + length: 2 ** 31 +}; + +assert.throws(TypeError, function() { + Array.prototype.toSpliced.call(arrayLike, 0, 0); +}); + +arrayLike.length = 2 ** 31 - 1; +assert.throws(TypeError, function() { + Array.prototype.toSpliced.call(arrayLike, 0, 0, 1); +}); diff --git a/test/built-ins/Array/prototype/toSpliced/length-increased-while-iterating.js b/test/built-ins/Array/prototype/toSpliced/length-increased-while-iterating.js new file mode 100644 index 00000000000..f59d305cc7c --- /dev/null +++ b/test/built-ins/Array/prototype/toSpliced/length-increased-while-iterating.js @@ -0,0 +1,36 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced caches the length getting the array elements. +info: | + Array.prototype.toSpliced ( start, deleteCount, ...items ) + + ... + 3. Let len be ? LengthOfArrayLike(O). + ... + 5. Let k be 0. + 6. Repeat, while k < len, + a. Let Pk be ! ToString(𝔽(k)). + b. Let kValue be ? Get(O, Pk). + ... +features: [change-array-by-copy] +---*/ + +var arr = [0, 1, 2]; +Object.defineProperty(arr, "0", { + get() { + arr.push(10); + return 0; + } +}); +Object.defineProperty(arr, "2", { + get() { + arr.push(11); + return 2; + } +}); + +assert.deepEqual(arr.toSpliced(1, 0, 0.5), [0, 0.5, 1, 2]); diff --git a/test/built-ins/Array/prototype/toSpliced/length-integer-string.js b/test/built-ins/Array/prototype/toSpliced/length-integer-string.js new file mode 100644 index 00000000000..53a38c4614b --- /dev/null +++ b/test/built-ins/Array/prototype/toSpliced/length-integer-string.js @@ -0,0 +1,28 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced converts the this value length to a number. +info: | + Array.prototype.toSpliced ( start, deleteCount, ...items ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + ... +features: [change-array-by-copy] +---*/ + +assert.deepEqual(Array.prototype.toSpliced.call({ length: "2", 0: 0, 1: 1, 2: 2 }, 0, 0), [0, 1]); + +var arrayLike = { + length: { + valueOf: () => 2 + }, + 0: 0, + 1: 1, + 2: 2, +}; + +assert.deepEqual(Array.prototype.toSpliced.call(arrayLike, 0, 0), [0, 1]); diff --git a/test/built-ins/Array/prototype/toSpliced/metadata/length.js b/test/built-ins/Array/prototype/toSpliced/metadata/length.js new file mode 100644 index 00000000000..6f570711c14 --- /dev/null +++ b/test/built-ins/Array/prototype/toSpliced/metadata/length.js @@ -0,0 +1,30 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: > + The "length" property of Array.prototype.toSpliced +info: | + 17 ECMAScript Standard Built-in Objects + + Every built-in function object, including constructors, has a length property + whose value is an integer. Unless otherwise specified, this value is equal to + the largest number of named arguments shown in the subclause headings for the + function description. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are shown using the form Β«...nameΒ») are not + included in the default argument count. + + Unless otherwise specified, the length property of a built-in function object + has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [change-array-by-copy] +---*/ + +verifyProperty(Array.prototype.toSpliced, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true, +}); diff --git a/test/built-ins/Array/prototype/toSpliced/metadata/name.js b/test/built-ins/Array/prototype/toSpliced/metadata/name.js new file mode 100644 index 00000000000..2acd12356bb --- /dev/null +++ b/test/built-ins/Array/prototype/toSpliced/metadata/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced.name is "toSpliced". +info: | + Array.prototype.toSpliced ( start, deleteCount, ...items ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [change-array-by-copy] +---*/ + +verifyProperty(Array.prototype.toSpliced, "name", { + value: "toSpliced", + writable: false, + enumerable: false, + configurable: true, +}); diff --git a/test/built-ins/Array/prototype/toSpliced/metadata/property-descriptor.js b/test/built-ins/Array/prototype/toSpliced/metadata/property-descriptor.js new file mode 100644 index 00000000000..a75b933dbc2 --- /dev/null +++ b/test/built-ins/Array/prototype/toSpliced/metadata/property-descriptor.js @@ -0,0 +1,25 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: > + "toSpliced" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +features: [change-array-by-copy] +---*/ + +assert.sameValue(typeof Array.prototype.toSpliced, "function", "typeof"); + +verifyProperty(Array.prototype, "toSpliced", { + value: Array.prototype.toSpliced, + writable: true, + enumerable: false, + configurable: true, +}); diff --git a/test/built-ins/Array/prototype/toSpliced/not-a-constructor.js b/test/built-ins/Array/prototype/toSpliced/not-a-constructor.js new file mode 100644 index 00000000000..bcdc2c08304 --- /dev/null +++ b/test/built-ins/Array/prototype/toSpliced/not-a-constructor.js @@ -0,0 +1,33 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Array.prototype.toSpliced does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [change-array-by-copy] +---*/ + +assert.sameValue( + isConstructor(Array.prototype.toSpliced), + false, + 'isConstructor(Array.prototype.toSpliced) must return false' +); + +assert.throws(TypeError, () => { + new Array.prototype.toSpliced(); +}, '`new Array.prototype.toSpliced()` throws TypeError'); + diff --git a/test/built-ins/Array/prototype/toSpliced/start-and-deleteCount-missing.js b/test/built-ins/Array/prototype/toSpliced/start-and-deleteCount-missing.js new file mode 100644 index 00000000000..73d8bcbda4f --- /dev/null +++ b/test/built-ins/Array/prototype/toSpliced/start-and-deleteCount-missing.js @@ -0,0 +1,22 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: Array.prototype.toSpliced returns a copy of the array if called with zero arguments +info: | + 22.1.3.25 Array.prototype.toSpliced (start, deleteCount , ...items ) + + ... + 3. Let relativeStart be ? ToIntegerOrInfinity(start). + ... + 6. Else, let actualStart be min(relativeStart, len). + ... + 8. If start is not present, then + a. Let actualDeleteCount be 0. + ... +---*/ + +var result = ["first", "second", "third"].toSpliced(); + +assert.deepEqual(result, ["first", "second", "third"]); diff --git a/test/built-ins/Array/prototype/toSpliced/start-and-deleteCount-undefineds.js b/test/built-ins/Array/prototype/toSpliced/start-and-deleteCount-undefineds.js new file mode 100644 index 00000000000..404eaae2354 --- /dev/null +++ b/test/built-ins/Array/prototype/toSpliced/start-and-deleteCount-undefineds.js @@ -0,0 +1,24 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: Array.prototype.toSpliced(undefined, undefined) returns a copy of the original array +info: | + 22.1.3.25 Array.prototype.toSpliced (start, deleteCount , ...items ) + + ... + 3. Let relativeStart be ? ToIntegerOrInfinity(start). + ... + 6. Else, let actualStart be min(relativeStart, len). + ... + 8. If start is not present, then + a. Let actualDeleteCount be 0. + 8. Else if deleteCount is not present, then + a. Let actualDeleteCount be len - actualStart. + ... +---*/ + +var result = ["first", "second", "third"].toSpliced(undefined, undefined); + +assert.deepEqual(result, ["first", "second", "third"]); diff --git a/test/built-ins/Array/prototype/toSpliced/start-bigger-than-length.js b/test/built-ins/Array/prototype/toSpliced/start-bigger-than-length.js new file mode 100644 index 00000000000..de58f48f228 --- /dev/null +++ b/test/built-ins/Array/prototype/toSpliced/start-bigger-than-length.js @@ -0,0 +1,22 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced converts the this value length to a number. +info: | + Array.prototype.toSpliced ( start, deleteCount, ...items ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + 3. Let relativeStart be ? ToIntegerOrInfinity(start). + 4. If relativeStart is -∞, let actualStart be 0. + 5. Else if relativeStart < 0, let actualStart be max(len + relativeStart, 0). + 6. Else, let actualStart be min(relativeStart, len). + ... +features: [change-array-by-copy] +---*/ + +var result = [0, 1, 2, 3, 4].toSpliced(10, 1, 5, 6); +assert.deepEqual(result, [5, 6]); diff --git a/test/built-ins/Array/prototype/toSpliced/start-neg-infinity-is-zero.js b/test/built-ins/Array/prototype/toSpliced/start-neg-infinity-is-zero.js new file mode 100644 index 00000000000..5ea54c8df3a --- /dev/null +++ b/test/built-ins/Array/prototype/toSpliced/start-neg-infinity-is-zero.js @@ -0,0 +1,21 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced converts the this value length to a number. +info: | + Array.prototype.toSpliced ( start, deleteCount, ...items ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + 3. Let relativeStart be ? ToIntegerOrInfinity(start). + 4. If relativeStart is -∞, let actualStart be 0. + 5. Else if relativeStart < 0, let actualStart be max(len + relativeStart, 0). + ... +features: [change-array-by-copy] +---*/ + +var result = [0, 1, 2, 3, 4].toSpliced(-Infinity, 2); +assert.deepEqual(result, [2, 3, 4]); diff --git a/test/built-ins/Array/prototype/toSpliced/start-neg-less-than-minus-length-is-zero.js b/test/built-ins/Array/prototype/toSpliced/start-neg-less-than-minus-length-is-zero.js new file mode 100644 index 00000000000..093c04282ad --- /dev/null +++ b/test/built-ins/Array/prototype/toSpliced/start-neg-less-than-minus-length-is-zero.js @@ -0,0 +1,21 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced converts the this value length to a number. +info: | + Array.prototype.toSpliced ( start, deleteCount, ...items ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + 3. Let relativeStart be ? ToIntegerOrInfinity(start). + 4. If relativeStart is -∞, let actualStart be 0. + 5. Else if relativeStart < 0, let actualStart be max(len + relativeStart, 0). + ... +features: [change-array-by-copy] +---*/ + +var result = [0, 1, 2, 3, 4].toSpliced(-20, 2); +assert.deepEqual(result, [2, 3, 4]); diff --git a/test/built-ins/Array/prototype/toSpliced/start-neg-subtracted-from-length.js b/test/built-ins/Array/prototype/toSpliced/start-neg-subtracted-from-length.js new file mode 100644 index 00000000000..dd212d9b6c8 --- /dev/null +++ b/test/built-ins/Array/prototype/toSpliced/start-neg-subtracted-from-length.js @@ -0,0 +1,21 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced converts the this value length to a number. +info: | + Array.prototype.toSpliced ( start, deleteCount, ...items ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + 3. Let relativeStart be ? ToIntegerOrInfinity(start). + 4. If relativeStart is -∞, let actualStart be 0. + 5. Else if relativeStart < 0, let actualStart be max(len + relativeStart, 0). + ... +features: [change-array-by-copy] +---*/ + +var result = [0, 1, 2, 3, 4].toSpliced(-3, 2); +assert.deepEqual(result, [0, 1, 4]); diff --git a/test/built-ins/Array/prototype/toSpliced/start-undefined-and-deleteCount-missing.js b/test/built-ins/Array/prototype/toSpliced/start-undefined-and-deleteCount-missing.js new file mode 100644 index 00000000000..529fa17f676 --- /dev/null +++ b/test/built-ins/Array/prototype/toSpliced/start-undefined-and-deleteCount-missing.js @@ -0,0 +1,24 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: Array.prototype.toSpliced(undefined) returns an empty array +info: | + 22.1.3.25 Array.prototype.toSpliced (start, deleteCount , ...items ) + + ... + 3. Let relativeStart be ? ToIntegerOrInfinity(start). + ... + 6. Else, let actualStart be min(relativeStart, len). + ... + 8. If start is not present, then + a. Let actualDeleteCount be 0. + 8. Else if deleteCount is not present, then + a. Let actualDeleteCount be len - actualStart. + ... +---*/ + +var result = ["first", "second", "third"].toSpliced(undefined); + +assert.deepEqual(result, []); diff --git a/test/built-ins/Array/prototype/toSpliced/this-value-boolean.js b/test/built-ins/Array/prototype/toSpliced/this-value-boolean.js new file mode 100644 index 00000000000..e9db963f550 --- /dev/null +++ b/test/built-ins/Array/prototype/toSpliced/this-value-boolean.js @@ -0,0 +1,18 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced throws if the receiver is null or undefined +info: | + Array.prototype.toSpliced ( start, deleteCount, ...items ) + + 1. Let O be ? ToObject(this value). + 2. Let len be ? LengthOfArrayLike(O). + ... +features: [change-array-by-copy] +---*/ + +assert.deepEqual(Array.prototype.toSpliced.call(true, 0, 0), []); +assert.deepEqual(Array.prototype.toSpliced.call(false, 0, 0), []); diff --git a/test/built-ins/Array/prototype/toSpliced/this-value-nullish.js b/test/built-ins/Array/prototype/toSpliced/this-value-nullish.js new file mode 100644 index 00000000000..a9190743844 --- /dev/null +++ b/test/built-ins/Array/prototype/toSpliced/this-value-nullish.js @@ -0,0 +1,22 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced throws if the receiver is null or undefined +info: | + Array.prototype.toSpliced ( start, deleteCount, ...items ) + + 1. Let O be ? ToObject(this value). + ... +features: [change-array-by-copy] +---*/ + +assert.throws(TypeError, () => { + Array.prototype.toSpliced.call(null, 0, 0); +}, '`Array.prototype.toSpliced.call(null)` throws TypeError'); + +assert.throws(TypeError, () => { + Array.prototype.toSpliced.call(undefined, 0, 0); +}, '`Array.prototype.toSpliced.call(undefined)` throws TypeError'); diff --git a/test/built-ins/Array/prototype/toSpliced/unmodified.js b/test/built-ins/Array/prototype/toSpliced/unmodified.js new file mode 100644 index 00000000000..fd1dc309d23 --- /dev/null +++ b/test/built-ins/Array/prototype/toSpliced/unmodified.js @@ -0,0 +1,14 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced returns a new array even if it the result is equal to the original array +features: [change-array-by-copy] +---*/ + +var arr = [1, 2, 3]; +var spliced = arr.toSpliced(1, 0); +assert.notSameValue(arr, spliced); +assert.deepEqual(arr, spliced); From 81df178675c5e8b4ee98e63b32a36c8473f1031f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Mon, 13 Dec 2021 16:34:53 +0100 Subject: [PATCH 05/86] Add `Array.prototype.with` tests --- .../Array/prototype/with/frozen-this-value.js | 17 ++++++++ .../prototype/with/holes-not-preserved.js | 29 ++++++++++++++ .../Array/prototype/with/ignores-species.js | 30 ++++++++++++++ .../Array/prototype/with/immutable.js | 14 +++++++ .../with/index-bigger-or-eq-than-length.js | 37 ++++++++++++++++++ .../prototype/with/index-casted-to-number.js | 26 +++++++++++++ .../Array/prototype/with/index-negative.js | 26 +++++++++++++ .../with/index-smaller-than-minus-length.js | 39 +++++++++++++++++++ .../with/length-decreased-while-iterating.js | 34 ++++++++++++++++ .../length-exceeding-array-length-limit.js | 39 +++++++++++++++++++ .../with/length-increased-while-iterating.js | 31 +++++++++++++++ .../prototype/with/length-integer-string.js | 29 ++++++++++++++ .../Array/prototype/with/metadata/length.js | 30 ++++++++++++++ .../Array/prototype/with/metadata/name.js | 28 +++++++++++++ .../with/metadata/property-descriptor.js | 25 ++++++++++++ .../prototype/with/no-get-replaced-index.js | 29 ++++++++++++++ .../Array/prototype/with/not-a-constructor.js | 33 ++++++++++++++++ .../prototype/with/this-value-boolean.js | 22 +++++++++++ .../prototype/with/this-value-nullish.js | 22 +++++++++++ 19 files changed, 540 insertions(+) create mode 100644 test/built-ins/Array/prototype/with/frozen-this-value.js create mode 100644 test/built-ins/Array/prototype/with/holes-not-preserved.js create mode 100644 test/built-ins/Array/prototype/with/ignores-species.js create mode 100644 test/built-ins/Array/prototype/with/immutable.js create mode 100644 test/built-ins/Array/prototype/with/index-bigger-or-eq-than-length.js create mode 100644 test/built-ins/Array/prototype/with/index-casted-to-number.js create mode 100644 test/built-ins/Array/prototype/with/index-negative.js create mode 100644 test/built-ins/Array/prototype/with/index-smaller-than-minus-length.js create mode 100644 test/built-ins/Array/prototype/with/length-decreased-while-iterating.js create mode 100644 test/built-ins/Array/prototype/with/length-exceeding-array-length-limit.js create mode 100644 test/built-ins/Array/prototype/with/length-increased-while-iterating.js create mode 100644 test/built-ins/Array/prototype/with/length-integer-string.js create mode 100644 test/built-ins/Array/prototype/with/metadata/length.js create mode 100644 test/built-ins/Array/prototype/with/metadata/name.js create mode 100644 test/built-ins/Array/prototype/with/metadata/property-descriptor.js create mode 100644 test/built-ins/Array/prototype/with/no-get-replaced-index.js create mode 100644 test/built-ins/Array/prototype/with/not-a-constructor.js create mode 100644 test/built-ins/Array/prototype/with/this-value-boolean.js create mode 100644 test/built-ins/Array/prototype/with/this-value-nullish.js diff --git a/test/built-ins/Array/prototype/with/frozen-this-value.js b/test/built-ins/Array/prototype/with/frozen-this-value.js new file mode 100644 index 00000000000..8052cf2338a --- /dev/null +++ b/test/built-ins/Array/prototype/with/frozen-this-value.js @@ -0,0 +1,17 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.with +description: > + Array.prototype.with works on frozen objects +features: [change-array-by-copy] +---*/ + +var arr = Object.freeze([0, 1, 2]); +var result = arr.with(1, 3); +assert.deepEqual(result, [0, 3, 2]); + +var arrayLike = Object.freeze({ length: 3, 0: 0, 1: 1, 2: 2 }); +var result2 = Array.prototype.with.call(arrayLike); +assert.deepEqual(result2, [0, 3, 2]); diff --git a/test/built-ins/Array/prototype/with/holes-not-preserved.js b/test/built-ins/Array/prototype/with/holes-not-preserved.js new file mode 100644 index 00000000000..1145cacbe26 --- /dev/null +++ b/test/built-ins/Array/prototype/with/holes-not-preserved.js @@ -0,0 +1,29 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.with +description: > + Array.prototype.with does not preserve holes in the array +info: | + Array.prototype.with ( ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + ... + 5. Repeat, while k < len + a. Let Pk be ! ToString(𝔽(k)). + b. If k is actualIndex, let fromValue be value. + c. Else, let fromValue be ? Get(O, Pk). + d. Perform ? CreateDataPropertyOrThrow(A, Pk, fromValue). + e. Set k to k + 1. +features: [change-array-by-copy] +---*/ + +var arr = [0, /* hole */, 2, /* hole */, 4]; +Array.prototype[3] = 3; + +var result = arr.with(2, 6); +assert.deepEqual(result, [0, undefined, 6, 3, 4]); +assert(result.hasOwnProperty(1)); +assert(result.hasOwnProperty(3)); diff --git a/test/built-ins/Array/prototype/with/ignores-species.js b/test/built-ins/Array/prototype/with/ignores-species.js new file mode 100644 index 00000000000..e4c6c3c61dd --- /dev/null +++ b/test/built-ins/Array/prototype/with/ignores-species.js @@ -0,0 +1,30 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.with +description: > + Array.prototype.with ignores @@species +info: | + Array.prototype.with ( ) + + ... + 8. Let A be ? ArrayCreate(𝔽(len)). + ... +features: [change-array-by-copy] +---*/ + +var a = []; +a.constructor = {}; +a.constructor[Symbol.species] = function () {} + +assert.sameValue(Object.getPrototypeOf(a.with(0, 0)), Array.prototype); + +var b = []; +Object.defineProperty(b, "constructor", { + get() { + throw new Test262Error("Should not get .constructor"); + } +}); + +b.with(0, 0); diff --git a/test/built-ins/Array/prototype/with/immutable.js b/test/built-ins/Array/prototype/with/immutable.js new file mode 100644 index 00000000000..31ff27c1c74 --- /dev/null +++ b/test/built-ins/Array/prototype/with/immutable.js @@ -0,0 +1,14 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.with +description: > + Array.prototype.with does not mutate its this value +features: [change-array-by-copy] +---*/ + +var arr = [0, 1, 2]; +arr.with(1, 3); + +assert.deepEqual(arr, [0, 1, 2]); diff --git a/test/built-ins/Array/prototype/with/index-bigger-or-eq-than-length.js b/test/built-ins/Array/prototype/with/index-bigger-or-eq-than-length.js new file mode 100644 index 00000000000..082935341c6 --- /dev/null +++ b/test/built-ins/Array/prototype/with/index-bigger-or-eq-than-length.js @@ -0,0 +1,37 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.with +description: > + Array.prototype.with throws if the index is bigger than or equal to the array length. +info: | + Array.prototype.with ( index, value ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + 3. Let relativeIndex be ? ToIntegerOrInfinity(index). + 4. If index >= 0, let actualIndex be relativeIndex. + 5. Else, let actualIndex be len + relativeIndex. + 6. If actualIndex >= len or actualIndex < 0, throw a *RangeError* exception. + ... +features: [change-array-by-copy] +---*/ + +var arr = [0, 1, 2]; + +assert.throws(RangeError, function() { + [0, 1, 2].with(3, 7); +}); + +assert.throws(RangeError, function() { + [0, 1, 2].with(10, 7); +}); + +assert.throws(RangeError, function() { + [0, 1, 2].with(2 ** 53 + 2, 7); +}); + +assert.throws(RangeError, function() { + [0, 1, 2].with(Infinity, 7); +}); diff --git a/test/built-ins/Array/prototype/with/index-casted-to-number.js b/test/built-ins/Array/prototype/with/index-casted-to-number.js new file mode 100644 index 00000000000..966af65a73a --- /dev/null +++ b/test/built-ins/Array/prototype/with/index-casted-to-number.js @@ -0,0 +1,26 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.with +description: > + Array.prototype.with casts the index to an integer. +info: | + Array.prototype.with ( index, value ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + 3. Let relativeIndex be ? ToIntegerOrInfinity(index). + 4. If index >= 0, let actualIndex be relativeIndex. + 5. Else, let actualIndex be len + relativeIndex. + ... +features: [change-array-by-copy] +---*/ + +var arr = [0, 4, 16]; + +assert.deepEqual(arr.with(1.2, 7), [0, 7, 16]); +assert.deepEqual(arr.with("1", 3), [0, 3, 16]); +assert.deepEqual(arr.with("-1", 5), [1, 5, 6]); +assert.deepEqual(arr.with(NaN, 2), [2, 4, 16]); +assert.deepEqual(arr.with("dog", "cat"), ["cat", 4, 16]); diff --git a/test/built-ins/Array/prototype/with/index-negative.js b/test/built-ins/Array/prototype/with/index-negative.js new file mode 100644 index 00000000000..c16e3b62a94 --- /dev/null +++ b/test/built-ins/Array/prototype/with/index-negative.js @@ -0,0 +1,26 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.with +description: > + Array.prototype.with adds length to index if it's negative. +info: | + Array.prototype.with ( index, value ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + 3. Let relativeIndex be ? ToIntegerOrInfinity(index). + 4. If index >= 0, let actualIndex be relativeIndex. + 5. Else, let actualIndex be len + relativeIndex. + ... +features: [change-array-by-copy] +---*/ + +var arr = [0, 1, 2]; + +assert.deepEqual(arr.with(-1, 4), [0, 1, 4]); +assert.deepEqual(arr.with(-3, 4), [4, 1, 2]); + +// -0 is not < 0 +assert.deepEqual(arr.with(-0, 4), [4, 1, 2]); diff --git a/test/built-ins/Array/prototype/with/index-smaller-than-minus-length.js b/test/built-ins/Array/prototype/with/index-smaller-than-minus-length.js new file mode 100644 index 00000000000..1f2f3a4a01b --- /dev/null +++ b/test/built-ins/Array/prototype/with/index-smaller-than-minus-length.js @@ -0,0 +1,39 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.with +description: > + Array.prototype.with throws if the (negative) index is smaller than -length. +info: | + Array.prototype.with ( index, value ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + 3. Let relativeIndex be ? ToIntegerOrInfinity(index). + 4. If index >= 0, let actualIndex be relativeIndex. + 5. Else, let actualIndex be len + relativeIndex. + 6. If actualIndex >= len or actualIndex < 0, throw a *RangeError* exception. + ... +features: [change-array-by-copy] +---*/ + +var arr = [0, 1, 2]; + +[0, 1, 2].with(-3, 7); + +assert.throws(RangeError, function() { + [0, 1, 2].with(-4, 7); +}); + +assert.throws(RangeError, function() { + [0, 1, 2].with(-10, 7); +}); + +assert.throws(RangeError, function() { + [0, 1, 2].with(-(2 ** 53) - 2, 7); +}); + +assert.throws(RangeError, function() { + [0, 1, 2].with(-Infinity, 7); +}); diff --git a/test/built-ins/Array/prototype/with/length-decreased-while-iterating.js b/test/built-ins/Array/prototype/with/length-decreased-while-iterating.js new file mode 100644 index 00000000000..5738a486ece --- /dev/null +++ b/test/built-ins/Array/prototype/with/length-decreased-while-iterating.js @@ -0,0 +1,34 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.with +description: > + Array.prototype.with caches the length getting the array elements. +info: | + Array.prototype.with ( index, value ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + ... + 5. Repeat, while k < len + a. Let Pk be ! ToString(𝔽(k)). + b. If k is actualIndex, let fromValue be value. + c. Else, let fromValue be ? Get(O, Pk). + d. Perform ? CreateDataPropertyOrThrow(A, Pk, fromValue). + e. Set k to k + 1. +features: [change-array-by-copy] +---*/ + +var arr = [0, 1, 2, 3, 4]; +Array.prototype[4] = 5; + +Object.defineProperty(arr, "1", { + get() { + arr.length = 1; + return 1; + } +}); + +assert.deepEqual(arr.with(2, 7), [0, 1, 7, undefined, 5]); +assert.deepEqual(arr.with(0, 7), [7, 1, undefined, undefined, 5]); diff --git a/test/built-ins/Array/prototype/with/length-exceeding-array-length-limit.js b/test/built-ins/Array/prototype/with/length-exceeding-array-length-limit.js new file mode 100644 index 00000000000..b2e8fe29d8c --- /dev/null +++ b/test/built-ins/Array/prototype/with/length-exceeding-array-length-limit.js @@ -0,0 +1,39 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toReversed +description: > + Array.prototype.toReversed limits the length to 2 ** 53 - 1 +info: | + Array.prototype.toReversed ( ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + ... + 8. Let A be ? ArrayCreate(𝔽(len)). + ... + + ArrayCreate ( length [, proto ] ) + + 1. If length > 2 ** 31 - 1, throw a RangeError exception. +features: [change-array-by-copy] +---*/ + +// Object with large "length" property +var arrayLike = { + get "0" () { + throw new Test262Error("Get 0"); + }, + get "2147483647" () { // 2 ** 31 - 1 + throw new Test262Error("Get 2147483648"); + }, + get "2147483648" () { // 2 ** 31 + throw new Test262Error("Get 2147483648"); + }, + length: 2 ** 31 +}; + +assert.throws(TypeError, function() { + Array.prototype.with.call(arrayLike, 0, 0); +}); diff --git a/test/built-ins/Array/prototype/with/length-increased-while-iterating.js b/test/built-ins/Array/prototype/with/length-increased-while-iterating.js new file mode 100644 index 00000000000..da69ec13f00 --- /dev/null +++ b/test/built-ins/Array/prototype/with/length-increased-while-iterating.js @@ -0,0 +1,31 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.with +description: > + Array.prototype.with caches the length getting the array elements. +info: | + Array.prototype.with ( index, value ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + ... + 5. Repeat, while k < len + a. Let Pk be ! ToString(𝔽(k)). + b. If k is actualIndex, let fromValue be value. + c. Else, let fromValue be ? Get(O, Pk). + d. Perform ? CreateDataPropertyOrThrow(A, Pk, fromValue). + e. Set k to k + 1. +features: [change-array-by-copy] +---*/ + +var arr = [0, 1, 2]; +Object.defineProperty(arr, "0", { + get() { + arr.push(4); + return 0; + } +}); + +assert.deepEqual(arr.with(1, 4), [0, 4, 2]); diff --git a/test/built-ins/Array/prototype/with/length-integer-string.js b/test/built-ins/Array/prototype/with/length-integer-string.js new file mode 100644 index 00000000000..0d8d756e0be --- /dev/null +++ b/test/built-ins/Array/prototype/with/length-integer-string.js @@ -0,0 +1,29 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.with +description: > + Array.prototype.with converts the this value length to a number. +info: | + Array.prototype.with ( index, value ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + ... +features: [change-array-by-copy] +---*/ + +var arrayLike = { length: "2", 0: 1, 1: 2, 2: 3 }; +assert.deepEqual(Array.prototype.with.call(arrayLike, 0, 4), [4, 2]); + +var arrayLike = { + length: { + valueOf: () => 2 + }, + 0: 1, + 1: 2, + 2: 3, +}; + +assert.deepEqual(Array.prototype.with.call(arrayLike, 0, 4), [4, 2]); diff --git a/test/built-ins/Array/prototype/with/metadata/length.js b/test/built-ins/Array/prototype/with/metadata/length.js new file mode 100644 index 00000000000..8646fa60211 --- /dev/null +++ b/test/built-ins/Array/prototype/with/metadata/length.js @@ -0,0 +1,30 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.with +description: > + The "length" property of Array.prototype.with +info: | + 17 ECMAScript Standard Built-in Objects + + Every built-in function object, including constructors, has a length property + whose value is an integer. Unless otherwise specified, this value is equal to + the largest number of named arguments shown in the subclause headings for the + function description. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are shown using the form Β«...nameΒ») are not + included in the default argument count. + + Unless otherwise specified, the length property of a built-in function object + has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [change-array-by-copy] +---*/ + +verifyProperty(Array.prototype.with, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true, +}); diff --git a/test/built-ins/Array/prototype/with/metadata/name.js b/test/built-ins/Array/prototype/with/metadata/name.js new file mode 100644 index 00000000000..d1fc9e04088 --- /dev/null +++ b/test/built-ins/Array/prototype/with/metadata/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.with +description: > + Array.prototype.with.name is "with". +info: | + Array.prototype.with ( index, value ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [change-array-by-copy] +---*/ + +verifyProperty(Array.prototype.with, "name", { + value: "with", + writable: false, + enumerable: false, + configurable: true, +}); diff --git a/test/built-ins/Array/prototype/with/metadata/property-descriptor.js b/test/built-ins/Array/prototype/with/metadata/property-descriptor.js new file mode 100644 index 00000000000..2f341d2b1d8 --- /dev/null +++ b/test/built-ins/Array/prototype/with/metadata/property-descriptor.js @@ -0,0 +1,25 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.with +description: > + "with" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +features: [change-array-by-copy] +---*/ + +assert.sameValue(typeof Array.prototype.with, "function", "typeof"); + +verifyProperty(Array.prototype, "with", { + value: Array.prototype.with, + writable: true, + enumerable: false, + configurable: true, +}); diff --git a/test/built-ins/Array/prototype/with/no-get-replaced-index.js b/test/built-ins/Array/prototype/with/no-get-replaced-index.js new file mode 100644 index 00000000000..f3dcd24ed8a --- /dev/null +++ b/test/built-ins/Array/prototype/with/no-get-replaced-index.js @@ -0,0 +1,29 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.with +description: > + Array.prototype.with does not [[Get]] the value in the replaced position +info: | + Array.prototype.with ( ) + + ... + 5. Repeat, while k < len + a. Let Pk be ! ToString(𝔽(k)). + b. If k is actualIndex, let fromValue be value. + c. Else, let fromValue be ? Get(O, Pk). + d. Perform ? CreateDataPropertyOrThrow(A, Pk, fromValue). + e. Set k to k + 1. +features: [change-array-by-copy] +---*/ + +var arr = [0, 1, 2, 3]; +Object.defineProperty(arr, "2", { + get() { + throw new Test262Error("Should not get '2'"); + } +}); + +var result = arr.with(2, 6); +assert.deepEqual(result, [0, 1, 6, 3]); diff --git a/test/built-ins/Array/prototype/with/not-a-constructor.js b/test/built-ins/Array/prototype/with/not-a-constructor.js new file mode 100644 index 00000000000..8e07261c89b --- /dev/null +++ b/test/built-ins/Array/prototype/with/not-a-constructor.js @@ -0,0 +1,33 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Array.prototype.with does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [change-array-by-copy] +---*/ + +assert.sameValue( + isConstructor(Array.prototype.with), + false, + 'isConstructor(Array.prototype.with) must return false' +); + +assert.throws(TypeError, () => { + new Array.prototype.with(); +}, '`new Array.prototype.with()` throws TypeError'); + diff --git a/test/built-ins/Array/prototype/with/this-value-boolean.js b/test/built-ins/Array/prototype/with/this-value-boolean.js new file mode 100644 index 00000000000..b274dd7362d --- /dev/null +++ b/test/built-ins/Array/prototype/with/this-value-boolean.js @@ -0,0 +1,22 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.with +description: > + Array.prototype.with casts primitive receivers to objects +info: | + Array.prototype.with ( index, value ) + + 1. Let O be ? ToObject(this value). + 2. Let len be ? LengthOfArrayLike(O). + ... +features: [change-array-by-copy] +---*/ + +Boolean.prototype.length = 2; +Boolean.prototype[0] = 0; +Boolean.prototype[1] = 1; + +assert.deepEqual(Array.prototype.with.call(true, 0, 2), [2, 1]); +assert.deepEqual(Array.prototype.with.call(false, 0, 2), [2, 1]); diff --git a/test/built-ins/Array/prototype/with/this-value-nullish.js b/test/built-ins/Array/prototype/with/this-value-nullish.js new file mode 100644 index 00000000000..283ff8087d6 --- /dev/null +++ b/test/built-ins/Array/prototype/with/this-value-nullish.js @@ -0,0 +1,22 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.with +description: > + Array.prototype.with throws if the receiver is null or undefined +info: | + Array.prototype.with ( index, value ) + + 1. Let O be ? ToObject(this value). + ... +features: [change-array-by-copy] +---*/ + +assert.throws(TypeError, () => { + Array.prototype.with.call(null, 0, 0); +}, '`Array.prototype.with.call(null, 0, 0)` throws TypeError'); + +assert.throws(TypeError, () => { + Array.prototype.with.call(undefined, 0, 0); +}, '`Array.prototype.with.call(undefined, 0, 0)` throws TypeError'); From 5ec6cfb8adc98f2de7f358bd00d69b9cf7d3e104 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Mon, 13 Dec 2021 16:38:20 +0100 Subject: [PATCH 06/86] Add new `Array.prototype[Symbol.unscopables]` test --- .../change-array-by-copy.js | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 test/built-ins/Array/prototype/Symbol.unscopables/change-array-by-copy.js diff --git a/test/built-ins/Array/prototype/Symbol.unscopables/change-array-by-copy.js b/test/built-ins/Array/prototype/Symbol.unscopables/change-array-by-copy.js new file mode 100644 index 00000000000..4582b535228 --- /dev/null +++ b/test/built-ins/Array/prototype/Symbol.unscopables/change-array-by-copy.js @@ -0,0 +1,36 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype-@@unscopables +description: > + Initial value of `Symbol.unscopables` property +info: | + 22.1.3.32 Array.prototype [ @@unscopables ] + + ... + 11. Perform ! CreateDataPropertyOrThrow(unscopableList, "toReversed", true). + 12. Perform ! CreateDataPropertyOrThrow(unscopableList, "toSorted", true). + 13. Perform ! CreateDataPropertyOrThrow(unscopableList, "toSpliced", true). + ... +includes: [propertyHelper.js] +features: [Symbol.unscopables, change-array-by-copy] +---*/ + +var unscopables = Array.prototype[Symbol.unscopables]; + +assert.sameValue(unscopables.toReversed, true, '`toReversed` property value'); +verifyEnumerable(unscopables, 'toReversed'); +verifyWritable(unscopables, 'toReversed'); +verifyConfigurable(unscopables, 'toReversed'); + +assert.sameValue(unscopables.toSorted, true, '`toSorted` property value'); +verifyEnumerable(unscopables, 'toSorted'); +verifyWritable(unscopables, 'toSorted'); +verifyConfigurable(unscopables, 'toSorted'); + +assert.sameValue(unscopables.toSpliced, true, "`toSpliced` property value"); +verifyEnumerable(unscopables, "toSpliced"); +verifyWritable(unscopables, "toSpliced"); +verifyConfigurable(unscopables, "toSpliced"); + +assert.sameValue(Object.hasOwnProperty.call(unscopables, "with"), false, "does not have `with`"); From 4ddf0c9025948326d1e76b2553c000c723392244 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Mon, 13 Dec 2021 19:29:49 +0100 Subject: [PATCH 07/86] Add tests for `%TypedArray%.prototype.toReversed` --- .../prototype/toReversed/frozen-this-value.js | 17 ++++++++ .../prototype/toReversed/ignores-species.js | 42 +++++++++++++++++++ .../prototype/toReversed/immutable.js | 17 ++++++++ .../toReversed/length-property-ignored.js | 41 ++++++++++++++++++ .../prototype/toReversed/metadata/length.js | 30 +++++++++++++ .../prototype/toReversed/metadata/name.js | 28 +++++++++++++ .../metadata/property-descriptor.js | 25 +++++++++++ .../prototype/toReversed/not-a-constructor.js | 33 +++++++++++++++ .../toReversed/this-value-invalid.js | 35 ++++++++++++++++ 9 files changed, 268 insertions(+) create mode 100644 test/built-ins/TypedArray/prototype/toReversed/frozen-this-value.js create mode 100644 test/built-ins/TypedArray/prototype/toReversed/ignores-species.js create mode 100644 test/built-ins/TypedArray/prototype/toReversed/immutable.js create mode 100644 test/built-ins/TypedArray/prototype/toReversed/length-property-ignored.js create mode 100644 test/built-ins/TypedArray/prototype/toReversed/metadata/length.js create mode 100644 test/built-ins/TypedArray/prototype/toReversed/metadata/name.js create mode 100644 test/built-ins/TypedArray/prototype/toReversed/metadata/property-descriptor.js create mode 100644 test/built-ins/TypedArray/prototype/toReversed/not-a-constructor.js create mode 100644 test/built-ins/TypedArray/prototype/toReversed/this-value-invalid.js diff --git a/test/built-ins/TypedArray/prototype/toReversed/frozen-this-value.js b/test/built-ins/TypedArray/prototype/toReversed/frozen-this-value.js new file mode 100644 index 00000000000..268ee4e9673 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/toReversed/frozen-this-value.js @@ -0,0 +1,17 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.toReversed +description: > + TypedArray.prototype.toReversed works on frozen TAs +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +testWithTypedArrayConstructors(TA => { + var ta = Object.freeze(new TA([1, 2, 3])); + + var result = ta.toReversed(); + assert.compareArray(result, [3, 2, 1]); +}); diff --git a/test/built-ins/TypedArray/prototype/toReversed/ignores-species.js b/test/built-ins/TypedArray/prototype/toReversed/ignores-species.js new file mode 100644 index 00000000000..91f5527e58e --- /dev/null +++ b/test/built-ins/TypedArray/prototype/toReversed/ignores-species.js @@ -0,0 +1,42 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.toReversed +description: > + TypedArray.prototype.toReversed ignores @@species +info: | + TypedArray.prototype.toReversed ( ) + + ... + 5. Let A be ? TypedArraySpeciesCreate(O, Β« 𝔽(len) Β», true). + ... + + TypedArraySpeciesCreate ( exemplar, argumentList [ , noSpeciesOverride ] ) + ... + 2. Let defaultConstructor be the intrinsic object listed in column one of Table 63 for exemplar.[[TypedArrayName]]. + 3. If noSpeciesOverride is true, let constructor be defaultConstructor. + ... +includes: [testTypedArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +testWithTypedArrayConstructors(TA => { + var ta = new TA(); + ta.constructor = TA === Uint8Array ? Int32Array : Uint8Array; + assert.sameValue(Object.getPrototypeOf(ta.toReversed()), TA.prototype); + + ta = new TA(); + ta.constructor = { + [Symbol.species]: TA === Uint8Array ? Int32Array : Uint8Array, + }; + assert.sameValue(Object.getPrototypeOf(ta.toReversed()), TA.prototype); + + ta = new TA(); + Object.defineProperty(ta, "constructor", { + get() { + throw new Test262Error("Should not get .constructor"); + } + }); + ta.toReversed(); +}); diff --git a/test/built-ins/TypedArray/prototype/toReversed/immutable.js b/test/built-ins/TypedArray/prototype/toReversed/immutable.js new file mode 100644 index 00000000000..e598850e235 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/toReversed/immutable.js @@ -0,0 +1,17 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.toReversed +description: > + TypedArray.prototype.toReversed does not mutate its this value +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +testWithTypedArrayConstructors(TA => { + var ta = new TA([0, 1, 2]); + ta.toReversed(); + + assert.compareArray(ta, [0, 1, 2]); +}); diff --git a/test/built-ins/TypedArray/prototype/toReversed/length-property-ignored.js b/test/built-ins/TypedArray/prototype/toReversed/length-property-ignored.js new file mode 100644 index 00000000000..f24c9db24d9 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/toReversed/length-property-ignored.js @@ -0,0 +1,41 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.toReversed +description: > + TypedArray.prototype.toReversed creates an empty array if the this value .length is not a positive integer. +info: | + TypedArray.prototype.toReversed ( ) + + ... + 3. Let len be O.[[ArrayLength]]. + ... +includes: [testTypedArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +testWithTypedArrayConstructors(TA => { + var ta = new TA([0, 1, 2]); + Object.defineProperty(ta, "length", { value: 2 }) + assert.compareArray(ta.toReversed(), [2, 1, 0]); + + ta = new TA([0, 1, 2]); + Object.defineProperty(ta, "length", { value: 5 }); + assert.compareArray(ta.toReversed(), [2, 1, 0]); +}); + +var length; +Object.defineProperty(TypedArray.prototype, "length", { + get: () => length, +}); + +testWithTypedArrayConstructors(TA => { + var ta = new TA([0, 1, 2]); + + length = 2; + assert.compareArray(ta.toReversed(), [2, 1, 0]); + + length = 5; + assert.compareArray(ta.toReversed(), [2, 1, 0]); +}); diff --git a/test/built-ins/TypedArray/prototype/toReversed/metadata/length.js b/test/built-ins/TypedArray/prototype/toReversed/metadata/length.js new file mode 100644 index 00000000000..5d97f3823ff --- /dev/null +++ b/test/built-ins/TypedArray/prototype/toReversed/metadata/length.js @@ -0,0 +1,30 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-typedarray.prototype.toReversed +description: > + The "length" property of TypedTypedArray.prototype.toReversed +info: | + 17 ECMAScript Standard Built-in Objects + + Every built-in function object, including constructors, has a length property + whose value is an integer. Unless otherwise specified, this value is equal to + the largest number of named arguments shown in the subclause headings for the + function description. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are shown using the form Β«...nameΒ») are not + included in the default argument count. + + Unless otherwise specified, the length property of a built-in function object + has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +includes: [propertyHelper.js, testTypedArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +verifyProperty(TypedTypedArray.prototype.toReversed, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true, +}); diff --git a/test/built-ins/TypedArray/prototype/toReversed/metadata/name.js b/test/built-ins/TypedArray/prototype/toReversed/metadata/name.js new file mode 100644 index 00000000000..df33804ed37 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/toReversed/metadata/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-typedarray.prototype.toReversed +description: > + TypedTypedArray.prototype.toReversed.name is "toReversed". +info: | + TypedTypedArray.prototype.toReversed ( ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js, testTypedArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +verifyProperty(TypedTypedArray.prototype.toReversed, "name", { + value: "toReversed", + writable: false, + enumerable: false, + configurable: true, +}); diff --git a/test/built-ins/TypedArray/prototype/toReversed/metadata/property-descriptor.js b/test/built-ins/TypedArray/prototype/toReversed/metadata/property-descriptor.js new file mode 100644 index 00000000000..9f89760c4a3 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/toReversed/metadata/property-descriptor.js @@ -0,0 +1,25 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-typedarray.prototype.toReversed +description: > + "toReversed" property of TypedArray.prototype +info: | + 17 ECMAScript Standard Built-in Objects + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js, testTypedArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +assert.sameValue(typeof TypedTypedArray.prototype.toReversed, "function", "typeof"); + +verifyProperty(TypedArray.prototype, "toReversed", { + value: TypedTypedArray.prototype.toReversed, + writable: true, + enumerable: false, + configurable: true, +}); diff --git a/test/built-ins/TypedArray/prototype/toReversed/not-a-constructor.js b/test/built-ins/TypedArray/prototype/toReversed/not-a-constructor.js new file mode 100644 index 00000000000..76743ab163e --- /dev/null +++ b/test/built-ins/TypedArray/prototype/toReversed/not-a-constructor.js @@ -0,0 +1,33 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + TypedArray.prototype.toReversed does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js, testTypedArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +assert.sameValue( + isConstructor(TypedArray.prototype.toReversed), + false, + 'isConstructor(TypedArray.prototype.toReversed) must return false' +); + +assert.throws(TypeError, () => { + new TypedArray.prototype.toReversed(); +}, '`new TypedArray.prototype.toReversed()` throws TypeError'); + diff --git a/test/built-ins/TypedArray/prototype/toReversed/this-value-invalid.js b/test/built-ins/TypedArray/prototype/toReversed/this-value-invalid.js new file mode 100644 index 00000000000..e6102e6dba3 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/toReversed/this-value-invalid.js @@ -0,0 +1,35 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.toReversed +description: > + TypedArray.prototype.toReversed throws if the receiver is null or undefined +info: | + TypedArray.prototype.toReversed ( ) + + 1. Let O be the this value. + 2. Perform ? ValidateTypedArray(O). + ... +includes: [testTypedArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +var invalidValues = { + 'null': null, + 'undefined': undefined, + 'true': true, + '"abc"': "abc", + '12': 12, + 'Symbol()': Symbol(), + '[1, 2, 3]': [1, 2, 3], + '{ 0: 1, 1: 2, 2: 3, length: 3 }': { 0: 1, 1: 2, 2: 3, length: 3 }, + 'Uint8Array.prototype': Uint8Array.prototype, +}; + +Object.keys(invalidValues).forEach(desc => { + var value = invalidValues[desc]; + assert.throws(TypeError, () => { + TypedArray.prototype.toReversed.call(value); + }, `${desc} is not a valid TypedArray`); +}); From a37b2a3a3310f9eae4362382aac9330af6023123 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Mon, 20 Dec 2021 16:37:48 +0100 Subject: [PATCH 08/86] Add `%TypedArray%.prototype.toSorted` tests --- .../toSorted/comparefn-not-a-function.js | 27 +++++++++++ .../toSorted/comparefn-stop-after-error.js | 36 +++++++++++++++ .../prototype/toSorted/frozen-this-value.js | 17 +++++++ .../prototype/toSorted/ignores-species.js | 42 +++++++++++++++++ .../prototype/toSorted/immutable.js | 17 +++++++ .../length-decreased-while-comparing.js | 43 ++++++++++++++++++ .../length-increased-while-comparing.js | 45 +++++++++++++++++++ .../toSorted/length-property-ignored.js | 41 +++++++++++++++++ .../prototype/toSorted/metadata/length.js | 30 +++++++++++++ .../prototype/toSorted/metadata/name.js | 28 ++++++++++++ .../toSorted/metadata/property-descriptor.js | 25 +++++++++++ .../prototype/toSorted/not-a-constructor.js | 33 ++++++++++++++ .../prototype/toSorted/this-value-invalid.js | 35 +++++++++++++++ 13 files changed, 419 insertions(+) create mode 100644 test/built-ins/TypedArray/prototype/toSorted/comparefn-not-a-function.js create mode 100644 test/built-ins/TypedArray/prototype/toSorted/comparefn-stop-after-error.js create mode 100644 test/built-ins/TypedArray/prototype/toSorted/frozen-this-value.js create mode 100644 test/built-ins/TypedArray/prototype/toSorted/ignores-species.js create mode 100644 test/built-ins/TypedArray/prototype/toSorted/immutable.js create mode 100644 test/built-ins/TypedArray/prototype/toSorted/length-decreased-while-comparing.js create mode 100644 test/built-ins/TypedArray/prototype/toSorted/length-increased-while-comparing.js create mode 100644 test/built-ins/TypedArray/prototype/toSorted/length-property-ignored.js create mode 100644 test/built-ins/TypedArray/prototype/toSorted/metadata/length.js create mode 100644 test/built-ins/TypedArray/prototype/toSorted/metadata/name.js create mode 100644 test/built-ins/TypedArray/prototype/toSorted/metadata/property-descriptor.js create mode 100644 test/built-ins/TypedArray/prototype/toSorted/not-a-constructor.js create mode 100644 test/built-ins/TypedArray/prototype/toSorted/this-value-invalid.js diff --git a/test/built-ins/TypedArray/prototype/toSorted/comparefn-not-a-function.js b/test/built-ins/TypedArray/prototype/toSorted/comparefn-not-a-function.js new file mode 100644 index 00000000000..df7b69f0edf --- /dev/null +++ b/test/built-ins/TypedArray/prototype/toSorted/comparefn-not-a-function.js @@ -0,0 +1,27 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.toSorted +description: > + %TypedArray%.prototype.toSorted verifies that the comparator is callable before reading the length. +info: | + %TypedArray%.prototype.toSorted ( comparefn ) + + 1. If comparefn is not undefined and IsCallable(comparefn) is false, throw a TypeError exception. + 2. ... + 3. Let len be ? LengthOfArrayLike(O). +includes: [testTypedArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +var invalidComparators = [null, true, false, "", /a/g, 42, [], {}, Symbol()]; + +testWithTypedArrayConstructors(TA => { + const ta = new TA([1]); + for (var i = 0; i < invalidComparators.length; i++) { + assert.throws(TypeError, function() { + ta.toSorted(invalidComparators[i]); + }, invalidComparators[i]); + } +}); diff --git a/test/built-ins/TypedArray/prototype/toSorted/comparefn-stop-after-error.js b/test/built-ins/TypedArray/prototype/toSorted/comparefn-stop-after-error.js new file mode 100644 index 00000000000..5d3d53ff13b --- /dev/null +++ b/test/built-ins/TypedArray/prototype/toSorted/comparefn-stop-after-error.js @@ -0,0 +1,36 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.toSorted +description: > + %TypedArray%.prototype.toSorted doesn't call copmareFn if there is an error +info: | + %TypedArray%.prototype.toSorted ( compareFn ) + + ... + 9. Sort items using an implementation-defined sequence of + calls to SortCompare. If any such call returns an abrupt + completion, stop before performing any further calls to + SortCompare or steps in this algorithm and return that completion. + ... +includes: [testTypedArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +function StopToSorted() {} + +var called = false; + +testWithTypedArrayConstructors(TA => { + var called = false; + var ta = new TA([3, 1, 2]); + ta.toSorted(() => { + if (first) { + first = false; + throw new StopToSorted(); + } + called = true; + }); + assert.sameValue(called, false, "compareFn is not called after an error"); +}); diff --git a/test/built-ins/TypedArray/prototype/toSorted/frozen-this-value.js b/test/built-ins/TypedArray/prototype/toSorted/frozen-this-value.js new file mode 100644 index 00000000000..7d30c658471 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/toSorted/frozen-this-value.js @@ -0,0 +1,17 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.toReversed +description: > + TypedArray.prototype.toReversed works on frozen TAs +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +testWithTypedArrayConstructors(TA => { + var ta = Object.freeze(new TA([3, 1, 2])); + + var result = ta.toSorted(); + assert.compareArray(result, [1, 2, 3]); +}); diff --git a/test/built-ins/TypedArray/prototype/toSorted/ignores-species.js b/test/built-ins/TypedArray/prototype/toSorted/ignores-species.js new file mode 100644 index 00000000000..e0d42026cc1 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/toSorted/ignores-species.js @@ -0,0 +1,42 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.toSorted +description: > + TypedArray.prototype.toSorted ignores @@species +info: | + TypedArray.prototype.toSorted ( comparefn ) + + ... + 5. Let A be ? TypedArraySpeciesCreate(O, Β« 𝔽(len) Β», true). + ... + + TypedArraySpeciesCreate ( exemplar, argumentList [ , noSpeciesOverride ] ) + ... + 2. Let defaultConstructor be the intrinsic object listed in column one of Table 63 for exemplar.[[TypedArrayName]]. + 3. If noSpeciesOverride is true, let constructor be defaultConstructor. + ... +includes: [testTypedArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +testWithTypedArrayConstructors(TA => { + var ta = new TA(); + ta.constructor = TA === Uint8Array ? Int32Array : Uint8Array; + assert.sameValue(Object.getPrototypeOf(ta.toSorted()), TA.prototype); + + ta = new TA(); + ta.constructor = { + [Symbol.species]: TA === Uint8Array ? Int32Array : Uint8Array, + }; + assert.sameValue(Object.getPrototypeOf(ta.toSorted()), TA.prototype); + + ta = new TA(); + Object.defineProperty(ta, "constructor", { + get() { + throw new Test262Error("Should not get .constructor"); + } + }); + ta.toSorted(); +}); diff --git a/test/built-ins/TypedArray/prototype/toSorted/immutable.js b/test/built-ins/TypedArray/prototype/toSorted/immutable.js new file mode 100644 index 00000000000..719f41a7f44 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/toSorted/immutable.js @@ -0,0 +1,17 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.toSorted +description: > + TypedArray.prototype.toSorted does not mutate its this value +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +testWithTypedArrayConstructors(TA => { + var ta = new TA([3, 1, 2]); + ta.toSorted(); + + assert.compareArray(ta, [3, 1, 2]); +}); diff --git a/test/built-ins/TypedArray/prototype/toSorted/length-decreased-while-comparing.js b/test/built-ins/TypedArray/prototype/toSorted/length-decreased-while-comparing.js new file mode 100644 index 00000000000..178b1cf4bee --- /dev/null +++ b/test/built-ins/TypedArray/prototype/toSorted/length-decreased-while-comparing.js @@ -0,0 +1,43 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.toSorted +description: > + %TypedArray%.prototype.toSorted caches the length getting the %typedarray% elements. +info: | + %TypedArray%.prototype.toSorted ( compareFn ) + + ... + 4. Let len be O.[[ArrayLength]]. + ... + 5. Let items be a new empty List. + 7. Let k be 0. + 8. Repeat, while k < len, + a. Let Pk be ! ToString(𝔽(k)). + b. Let kValue be ? Get(O, Pk). + c. Append kValue to items. + d. Set k to k + 1. + 9. Sort items using an implementation-defined sequence of calls + to SortCompare. If any such call returns an abrupt completion, + stop before performing any further calls to SortCompare or + steps in this algorithm and return that completion. + ... +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, change-%typedarray%-by-copy] +---*/ + +testWithTypedArrayConstructors(TA => { + var ta = new TA([3, 1, 2]); + + var popped = false; + + var sorted = ta.toSorted((a, b) => { + if (!popped) ta.pop(); + popped = true; + return 1; + }); + + assert.compareArray(sorted, [3, 1, 2]); + assert.compareArray(ta, [3, 1]); +}); diff --git a/test/built-ins/TypedArray/prototype/toSorted/length-increased-while-comparing.js b/test/built-ins/TypedArray/prototype/toSorted/length-increased-while-comparing.js new file mode 100644 index 00000000000..674835efe1e --- /dev/null +++ b/test/built-ins/TypedArray/prototype/toSorted/length-increased-while-comparing.js @@ -0,0 +1,45 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.toSorted +description: > + %TypedArray%.prototype.toSorted caches the length getting the %typedarray% elements. +info: | + %TypedArray%.prototype.toSorted ( compareFn ) + + ... + 4. Let len be O.[[ArrayLength]]. + ... + 5. Let items be a new empty List. + 7. Let k be 0. + 8. Repeat, while k < len, + a. Let Pk be ! ToString(𝔽(k)). + b. Let kValue be ? Get(O, Pk). + c. Append kValue to items. + d. Set k to k + 1. + 9. Sort items using an implementation-defined sequence of calls + to SortCompare. If any such call returns an abrupt completion, + stop before performing any further calls to SortCompare or + steps in this algorithm and return that completion. + ... +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, change-%typedarray%-by-copy] +---*/ + +testWithTypedArrayConstructors(TA => { + var ta = new TA([3, 1, 2]); + + var sorted = ta.toSorted((a, b) => { + ta.push(10); + return 1; + }); + + assert.compareArray(sorted, [3, 1, 2]); + + assert(ta.length > 3); + assert.sameValue(ta[0], 3); + assert.sameValue(ta[1], 1); + assert.sameValue(ta[2], 2); + assert.sameValue(ta[3], 10); +}); diff --git a/test/built-ins/TypedArray/prototype/toSorted/length-property-ignored.js b/test/built-ins/TypedArray/prototype/toSorted/length-property-ignored.js new file mode 100644 index 00000000000..2f08ee1219e --- /dev/null +++ b/test/built-ins/TypedArray/prototype/toSorted/length-property-ignored.js @@ -0,0 +1,41 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.toSorted +description: > + TypedArray.prototype.toSorted creates an empty array if the this value .length is not a positive integer. +info: | + TypedArray.prototype.toSorted ( comparefn ) + + ... + 4. Let len be O.[[ArrayLength]]. + ... +includes: [testTypedArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +testWithTypedArrayConstructors(TA => { + var ta = new TA([3, 1, 2]); + Object.defineProperty(ta, "length", { value: 2 }) + assert.compareArray(ta.toSorted(), [1, 2, 3]); + + ta = new TA([3, 1, 2]); + Object.defineProperty(ta, "length", { value: 5 }); + assert.compareArray(ta.toSorted(), [1, 2, 3]); +}); + +var length; +Object.defineProperty(TypedArray.prototype, "length", { + get: () => length, +}); + +testWithTypedArrayConstructors(TA => { + var ta = new TA([3, 1, 2]); + + length = 2; + assert.compareArray(ta.toSorted(), [1, 2, 3]); + + length = 5; + assert.compareArray(ta.toSorted(), [1, 2, 3]); +}); diff --git a/test/built-ins/TypedArray/prototype/toSorted/metadata/length.js b/test/built-ins/TypedArray/prototype/toSorted/metadata/length.js new file mode 100644 index 00000000000..acca03d1413 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/toSorted/metadata/length.js @@ -0,0 +1,30 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-typedarray.prototype.toSorted +description: > + The "length" property of TypedTypedArray.prototype.toSorted +info: | + 17 ECMAScript Standard Built-in Objects + + Every built-in function object, including constructors, has a length property + whose value is an integer. Unless otherwise specified, this value is equal to + the largest number of named arguments shown in the subclause headings for the + function description. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are shown using the form Β«...nameΒ») are not + included in the default argument count. + + Unless otherwise specified, the length property of a built-in function object + has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +includes: [propertyHelper.js, testTypedArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +verifyProperty(TypedTypedArray.prototype.toSorted, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true, +}); diff --git a/test/built-ins/TypedArray/prototype/toSorted/metadata/name.js b/test/built-ins/TypedArray/prototype/toSorted/metadata/name.js new file mode 100644 index 00000000000..7616e91eb08 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/toSorted/metadata/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-typedarray.prototype.toSorted +description: > + TypedTypedArray.prototype.toSorted.name is "toSorted". +info: | + TypedTypedArray.prototype.toSorted ( comparefn ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js, testTypedArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +verifyProperty(TypedTypedArray.prototype.toSorted, "name", { + value: "toSorted", + writable: false, + enumerable: false, + configurable: true, +}); diff --git a/test/built-ins/TypedArray/prototype/toSorted/metadata/property-descriptor.js b/test/built-ins/TypedArray/prototype/toSorted/metadata/property-descriptor.js new file mode 100644 index 00000000000..e436f0a8f31 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/toSorted/metadata/property-descriptor.js @@ -0,0 +1,25 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-typedarray.prototype.toSorted +description: > + "toSorted" property of TypedArray.prototype +info: | + 17 ECMAScript Standard Built-in Objects + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js, testTypedArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +assert.sameValue(typeof TypedArray.prototype.toSorted, "function", "typeof"); + +verifyProperty(TypedArray.prototype, "toSorted", { + value: TypedTypedArray.prototype.toSorted, + writable: true, + enumerable: false, + configurable: true, +}); diff --git a/test/built-ins/TypedArray/prototype/toSorted/not-a-constructor.js b/test/built-ins/TypedArray/prototype/toSorted/not-a-constructor.js new file mode 100644 index 00000000000..54bd24a1611 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/toSorted/not-a-constructor.js @@ -0,0 +1,33 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + TypedArray.prototype.toSorted does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js, testTypedArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +assert.sameValue( + isConstructor(TypedArray.prototype.toSorted), + false, + 'isConstructor(TypedArray.prototype.toSorted) must return false' +); + +assert.throws(TypeError, () => { + new TypedArray.prototype.toSorted(); +}, '`new TypedArray.prototype.toSorted()` throws TypeError'); + diff --git a/test/built-ins/TypedArray/prototype/toSorted/this-value-invalid.js b/test/built-ins/TypedArray/prototype/toSorted/this-value-invalid.js new file mode 100644 index 00000000000..192aebdd8b5 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/toSorted/this-value-invalid.js @@ -0,0 +1,35 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.toSorted +description: > + TypedArray.prototype.toSorted throws if the receiver is null or undefined +info: | + TypedArray.prototype.toSorted ( ) + + 1. Let O be the this value. + 2. Perform ? ValidateTypedArray(O). + ... +includes: [testTypedArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +var invalidValues = { + 'null': null, + 'undefined': undefined, + 'true': true, + '"abc"': "abc", + '12': 12, + 'Symbol()': Symbol(), + '[1, 2, 3]': [1, 2, 3], + '{ 0: 1, 1: 2, 2: 3, length: 3 }': { 0: 1, 1: 2, 2: 3, length: 3 }, + 'Uint8Array.prototype': Uint8Array.prototype, +}; + +Object.keys(invalidValues).forEach(desc => { + var value = invalidValues[desc]; + assert.throws(TypeError, () => { + TypedArray.prototype.toSorted.call(value); + }, `${desc} is not a valid TypedArray`); +}); From 3dbcddacad8a22c83374508d12a2cfa07ff887c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Tue, 21 Dec 2021 15:28:53 +0100 Subject: [PATCH 09/86] Add `TypedArray%.prototype.toSpliced` tests --- ...lamped-between-zero-and-remaining-count.js | 40 ++++++++++++++++++ .../toSpliced/deleteCount-missing.js | 24 +++++++++++ .../toSpliced/deleteCount-undefined.js | 27 ++++++++++++ .../prototype/toSpliced/frozen-this-value.js | 17 ++++++++ .../prototype/toSpliced/ignores-species.js | 42 +++++++++++++++++++ .../prototype/toSpliced/immutable.js | 17 ++++++++ .../prototype/toSpliced/metadata/length.js | 30 +++++++++++++ .../prototype/toSpliced/metadata/name.js | 28 +++++++++++++ .../toSpliced/metadata/property-descriptor.js | 25 +++++++++++ .../prototype/toSpliced/not-a-constructor.js | 33 +++++++++++++++ .../start-and-deleteCount-missing.js | 25 +++++++++++ .../start-and-deleteCount-undefineds.js | 29 +++++++++++++ .../toSpliced/start-bigger-than-length.js | 25 +++++++++++ .../toSpliced/start-neg-infinity-is-zero.js | 24 +++++++++++ ...tart-neg-less-than-minus-length-is-zero.js | 24 +++++++++++ .../start-neg-subtracted-from-length.js | 24 +++++++++++ ...start-undefined-and-deleteCount-missing.js | 29 +++++++++++++ .../prototype/toSpliced/this-value-invalid.js | 35 ++++++++++++++++ 18 files changed, 498 insertions(+) create mode 100644 test/built-ins/TypedArray/prototype/toSpliced/deleteCount-clamped-between-zero-and-remaining-count.js create mode 100644 test/built-ins/TypedArray/prototype/toSpliced/deleteCount-missing.js create mode 100644 test/built-ins/TypedArray/prototype/toSpliced/deleteCount-undefined.js create mode 100644 test/built-ins/TypedArray/prototype/toSpliced/frozen-this-value.js create mode 100644 test/built-ins/TypedArray/prototype/toSpliced/ignores-species.js create mode 100644 test/built-ins/TypedArray/prototype/toSpliced/immutable.js create mode 100644 test/built-ins/TypedArray/prototype/toSpliced/metadata/length.js create mode 100644 test/built-ins/TypedArray/prototype/toSpliced/metadata/name.js create mode 100644 test/built-ins/TypedArray/prototype/toSpliced/metadata/property-descriptor.js create mode 100644 test/built-ins/TypedArray/prototype/toSpliced/not-a-constructor.js create mode 100644 test/built-ins/TypedArray/prototype/toSpliced/start-and-deleteCount-missing.js create mode 100644 test/built-ins/TypedArray/prototype/toSpliced/start-and-deleteCount-undefineds.js create mode 100644 test/built-ins/TypedArray/prototype/toSpliced/start-bigger-than-length.js create mode 100644 test/built-ins/TypedArray/prototype/toSpliced/start-neg-infinity-is-zero.js create mode 100644 test/built-ins/TypedArray/prototype/toSpliced/start-neg-less-than-minus-length-is-zero.js create mode 100644 test/built-ins/TypedArray/prototype/toSpliced/start-neg-subtracted-from-length.js create mode 100644 test/built-ins/TypedArray/prototype/toSpliced/start-undefined-and-deleteCount-missing.js create mode 100644 test/built-ins/TypedArray/prototype/toSpliced/this-value-invalid.js diff --git a/test/built-ins/TypedArray/prototype/toSpliced/deleteCount-clamped-between-zero-and-remaining-count.js b/test/built-ins/TypedArray/prototype/toSpliced/deleteCount-clamped-between-zero-and-remaining-count.js new file mode 100644 index 00000000000..5e823469b26 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/toSpliced/deleteCount-clamped-between-zero-and-remaining-count.js @@ -0,0 +1,40 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.toSpliced +description: deleteCount is clamped between zero and len - actualStart +info: | + 22.1.3.25 %TypedArray%.prototype.toSpliced (start, deleteCount , ...items ) + + ... + 10. Else, + a. Let insertCount be the number of elements in items. + b. Let dc be ? ToIntegerOrInfinity(deleteCount). + c. Let actualDeleteCount be the result of clamping dc between 0 and len - actualStart. + ... +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +withTypedArrayConstructors((TA) => { + assert.compareArray( + new TA([0, 1, 2, 3, 4, 5]).toSpliced(2, -1), + [0, 1, 2, 3, 4, 5] + ); + + assert.compareArray( + new TA([0, 1, 2, 3, 4, 5]).toSpliced(-4, -1), + [0, 1, 2, 3, 4, 5] + ); + + assert.compareArray( + new TA([0, 1, 2, 3, 4, 5]).toSpliced(2, 6), + [0, 1] + ); + + assert.compareArray( + new TA([0, 1, 2, 3, 4, 5]).toSpliced(-4, 6), + [0, 1] + ); +}); diff --git a/test/built-ins/TypedArray/prototype/toSpliced/deleteCount-missing.js b/test/built-ins/TypedArray/prototype/toSpliced/deleteCount-missing.js new file mode 100644 index 00000000000..23e19388d81 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/toSpliced/deleteCount-missing.js @@ -0,0 +1,24 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.toSpliced +description: %TypedArray%.prototype.toSpliced deletes the elements after start when called with one argument +info: | + 22.1.3.25 %TypedArray%.prototype.toSpliced (start, deleteCount , ...items ) + + ... + 9. Else if deleteCount is not present, then + a. Let insertCount be 0. + b. Let actualDeleteCount be len - actualStart. + ... +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +withTypedArrayConstructors((TA) => { + assert.compareArray( + new TA([1, 2, 3]).toSpliced(1), + [1] + ); +}); diff --git a/test/built-ins/TypedArray/prototype/toSpliced/deleteCount-undefined.js b/test/built-ins/TypedArray/prototype/toSpliced/deleteCount-undefined.js new file mode 100644 index 00000000000..70f7b1ef9fe --- /dev/null +++ b/test/built-ins/TypedArray/prototype/toSpliced/deleteCount-undefined.js @@ -0,0 +1,27 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: Array.prototype.toSpliced(number, undefined) returns a copy of the original array +info: | + 22.1.3.25 Array.prototype.toSpliced (start, deleteCount , ...items ) + + ... + 4. Let relativeStart be ? ToIntegerOrInfinity(start). + ... + 7. Else, let actualStart be min(relativeStart, len). + 8. If start is not present, then + ... + 9. Else if deleteCount is not present, then + a. Let insertCount be 0. + b. Let actualDeleteCount be len - actualStart. + ... +---*/ + +withTypedArrayConstructors((TA) => { + assert.compareArray( + new TA([1, 2, 3]).toSpliced(1, undefined), + [1, 2, 3] + ); +}); diff --git a/test/built-ins/TypedArray/prototype/toSpliced/frozen-this-value.js b/test/built-ins/TypedArray/prototype/toSpliced/frozen-this-value.js new file mode 100644 index 00000000000..6290929ed65 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/toSpliced/frozen-this-value.js @@ -0,0 +1,17 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.toSpliced +description: > + %TypedArray%.prototype.toSpliced works on frozen TAs +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +testWithTypedArrayConstructors(TA => { + var ta = Object.freeze(new TA([3, 1, 2])); + + var result = ta.toSpliced(0, 2, 4); + assert.compareArray(result, [4, 3]); +}); diff --git a/test/built-ins/TypedArray/prototype/toSpliced/ignores-species.js b/test/built-ins/TypedArray/prototype/toSpliced/ignores-species.js new file mode 100644 index 00000000000..ae963456d6a --- /dev/null +++ b/test/built-ins/TypedArray/prototype/toSpliced/ignores-species.js @@ -0,0 +1,42 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.toSpliced +description: > + %TypedArray%.prototype.toSpliced ignores @@species +info: | + %TypedArray%.prototype.toSpliced ( start, deleteCount, ...items ) + + ... + 12. Let A be ? TypedArraySpeciesCreate(O, Β« 𝔽(len) Β», true). + ... + + TypedArraySpeciesCreate ( exemplar, argumentList [ , noSpeciesOverride ] ) + ... + 2. Let defaultConstructor be the intrinsic object listed in column one of Table 63 for exemplar.[[TypedArrayName]]. + 3. If noSpeciesOverride is true, let constructor be defaultConstructor. + ... +includes: [testTypedArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +testWithTypedArrayConstructors(TA => { + var ta = new TA([1, 2, 3]); + ta.constructor = TA === Uint8Array ? Int32Array : Uint8Array; + assert.sameValue(Object.getPrototypeOf(ta.toSpliced(0, 2)), TA.prototype); + + ta = new TA([1, 2, 3]); + ta.constructor = { + [Symbol.species]: TA === Uint8Array ? Int32Array : Uint8Array, + }; + assert.sameValue(Object.getPrototypeOf(ta.toSpliced(0, 2)), TA.prototype); + + ta = new TA(); + Object.defineProperty(ta, "constructor", { + get() { + throw new Test262Error("Should not get .constructor"); + } + }); + ta.toSpliced(0, 2); +}); diff --git a/test/built-ins/TypedArray/prototype/toSpliced/immutable.js b/test/built-ins/TypedArray/prototype/toSpliced/immutable.js new file mode 100644 index 00000000000..ed3b6a9622e --- /dev/null +++ b/test/built-ins/TypedArray/prototype/toSpliced/immutable.js @@ -0,0 +1,17 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.toSpliced +description: > + %TypedArray%.prototype.toSpliced does not mutate its this value +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +testWithTypedArrayConstructors(TA => { + var ta = new TA([3, 1, 2]); + ta.toSpliced(0, 2); + + assert.compareArray(ta, [3, 1, 2]); +}); diff --git a/test/built-ins/TypedArray/prototype/toSpliced/metadata/length.js b/test/built-ins/TypedArray/prototype/toSpliced/metadata/length.js new file mode 100644 index 00000000000..a4cc4bbc742 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/toSpliced/metadata/length.js @@ -0,0 +1,30 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.toSpliced +description: > + The "length" property of %TypedArray%.prototype.toSpliced +info: | + 17 ECMAScript Standard Built-in Objects + + Every built-in function object, including constructors, has a length property + whose value is an integer. Unless otherwise specified, this value is equal to + the largest number of named arguments shown in the subclause headings for the + function description. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are shown using the form Β«...nameΒ») are not + included in the default argument count. + + Unless otherwise specified, the length property of a built-in function object + has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +verifyProperty(TypedArray.prototype.toSpliced, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true, +}); diff --git a/test/built-ins/TypedArray/prototype/toSpliced/metadata/name.js b/test/built-ins/TypedArray/prototype/toSpliced/metadata/name.js new file mode 100644 index 00000000000..db192733f9c --- /dev/null +++ b/test/built-ins/TypedArray/prototype/toSpliced/metadata/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.toSpliced +description: > + %TypedArray%.prototype.toSpliced.name is "toSpliced". +info: | + %TypedArray%.prototype.toSpliced ( start, deleteCount, ...items ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +verifyProperty(TypedArray.prototype.toSpliced, "name", { + value: "toSpliced", + writable: false, + enumerable: false, + configurable: true, +}); diff --git a/test/built-ins/TypedArray/prototype/toSpliced/metadata/property-descriptor.js b/test/built-ins/TypedArray/prototype/toSpliced/metadata/property-descriptor.js new file mode 100644 index 00000000000..aa63aedfb3f --- /dev/null +++ b/test/built-ins/TypedArray/prototype/toSpliced/metadata/property-descriptor.js @@ -0,0 +1,25 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.toSpliced +description: > + "toSpliced" property of %TypedArray%.prototype +info: | + 17 ECMAScript Standard Built-in Objects + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +assert.sameValue(typeof TypedArray.prototype.toSpliced, "function", "typeof"); + +verifyProperty(TypedArray.prototype, "toSpliced", { + value: TypedArray.prototype.toSpliced, + writable: true, + enumerable: false, + configurable: true, +}); diff --git a/test/built-ins/TypedArray/prototype/toSpliced/not-a-constructor.js b/test/built-ins/TypedArray/prototype/toSpliced/not-a-constructor.js new file mode 100644 index 00000000000..1bb781bee05 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/toSpliced/not-a-constructor.js @@ -0,0 +1,33 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + %TypedArray%.prototype.toSpliced does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js, testTypedArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +assert.sameValue( + isConstructor(TypedArray.prototype.toSpliced), + false, + 'isConstructor(TypedArray.prototype.toSpliced) must return false' +); + +assert.throws(TypeError, () => { + new TypedArray.prototype.toSpliced(); +}, '`new %TypedArray%.prototype.toSpliced()` throws TypeError'); + diff --git a/test/built-ins/TypedArray/prototype/toSpliced/start-and-deleteCount-missing.js b/test/built-ins/TypedArray/prototype/toSpliced/start-and-deleteCount-missing.js new file mode 100644 index 00000000000..b4911a95909 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/toSpliced/start-and-deleteCount-missing.js @@ -0,0 +1,25 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.toSpliced +description: %TypedArray%.prototype.toSpliced returns a copy of the TypedArray if called with zero arguments +info: | + 22.1.3.25 %TypedArray%.prototype.toSpliced (start, deleteCount , ...items ) + + ... + 4. Let relativeStart be ? ToIntegerOrInfinity(start). + ... + 7. Else, let actualStart be min(relativeStart, len). + 8. If start is not present, then + a. Let actualDeleteCount be 0. + ... +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +withTypedArrayConstructors((TA) => { + var result = new TA([1, 2, 3]).toSpliced(); + + assert.compareArray(result, [1, 2, 3]); +}); diff --git a/test/built-ins/TypedArray/prototype/toSpliced/start-and-deleteCount-undefineds.js b/test/built-ins/TypedArray/prototype/toSpliced/start-and-deleteCount-undefineds.js new file mode 100644 index 00000000000..00615279660 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/toSpliced/start-and-deleteCount-undefineds.js @@ -0,0 +1,29 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.toSpliced +description: %TypedArray%.prototype.toSpliced(undefined, undefined) returns a copy of the original TypedArray +info: | + 22.1.3.25 %TypedArray%.prototype.toSpliced ( start, deleteCount , ...items ) + + ... + 4. Let relativeStart be ? ToIntegerOrInfinity(start). + ... + 7. Else, let actualStart be min(relativeStart, len). + 8. If start is not present, then + a. Let insertCount be 0. + b. Let actualDeleteCount be 0. + 9. Else if deleteCount is not present, then + a. Let insertCount be 0. + b. Let actualDeleteCount be len - actualStart. + ... +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +withTypedArrayConstructors((TA) => { + var result = new TA([1, 2, 3]).toSpliced(undefined, undefined); + + assert.compareArray(result, [1, 2, 3]); +}); diff --git a/test/built-ins/TypedArray/prototype/toSpliced/start-bigger-than-length.js b/test/built-ins/TypedArray/prototype/toSpliced/start-bigger-than-length.js new file mode 100644 index 00000000000..a78625a4788 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/toSpliced/start-bigger-than-length.js @@ -0,0 +1,25 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.toSpliced +description: > + %TypedArray%.prototype.toSpliced converts the this value length to a number. +info: | + %TypedArray%.prototype.toSpliced ( start, deleteCount, ...items ) + + ... + 3. Let len be O.[[ArrayLength]]. + 4. Let relativeStart be ? ToIntegerOrInfinity(start). + 5. If relativeStart is -∞, let actualStart be 0. + 6. Else if relativeStart < 0, let actualStart be max(len + relativeStart, 0). + 7. Else, let actualStart be min(relativeStart, len). + ... +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +withTypedArrayConstructors((TA) => { + var result = new TA([0, 1, 2, 3, 4]).toSpliced(10, 1, 5, 6); + assert.compareArray(result, [5, 6]); +}); diff --git a/test/built-ins/TypedArray/prototype/toSpliced/start-neg-infinity-is-zero.js b/test/built-ins/TypedArray/prototype/toSpliced/start-neg-infinity-is-zero.js new file mode 100644 index 00000000000..7cbaed8fcd6 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/toSpliced/start-neg-infinity-is-zero.js @@ -0,0 +1,24 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.toSpliced +description: > + %TypedArray%.prototype.toSpliced converts the this value length to a number. +info: | + %TypedArray%.prototype.toSpliced ( start, deleteCount, ...items ) + + ... + 3. Let len be O.[[ArrayLength]]. + 4. Let relativeStart be ? ToIntegerOrInfinity(start). + 5. If relativeStart is -∞, let actualStart be 0. + 6. Else if relativeStart < 0, let actualStart be max(len + relativeStart, 0). + ... +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +withTypedArrayConstructors((TA) => { + var result = new TA([0, 1, 2, 3, 4]).toSpliced(-Infinity, 2); + assert.compareArray(result, [2, 3, 4]); +}); diff --git a/test/built-ins/TypedArray/prototype/toSpliced/start-neg-less-than-minus-length-is-zero.js b/test/built-ins/TypedArray/prototype/toSpliced/start-neg-less-than-minus-length-is-zero.js new file mode 100644 index 00000000000..223a5280e9f --- /dev/null +++ b/test/built-ins/TypedArray/prototype/toSpliced/start-neg-less-than-minus-length-is-zero.js @@ -0,0 +1,24 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.toSpliced +description: > + %TypedArray%.prototype.toSpliced converts the this value length to a number. +info: | + %TypedArray%.prototype.toSpliced ( start, deleteCount, ...items ) + + ... + 3. Let len be O.[[ArrayLength]]. + 4. Let relativeStart be ? ToIntegerOrInfinity(start). + 5. If relativeStart is -∞, let actualStart be 0. + 6. Else if relativeStart < 0, let actualStart be max(len + relativeStart, 0). + ... +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +withTypedArrayConstructors((TA) => { + var result = new TA([0, 1, 2, 3, 4]).toSpliced(-20, 2); + assert.compareArray(result, [2, 3, 4]); +}); diff --git a/test/built-ins/TypedArray/prototype/toSpliced/start-neg-subtracted-from-length.js b/test/built-ins/TypedArray/prototype/toSpliced/start-neg-subtracted-from-length.js new file mode 100644 index 00000000000..f98619e48ab --- /dev/null +++ b/test/built-ins/TypedArray/prototype/toSpliced/start-neg-subtracted-from-length.js @@ -0,0 +1,24 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.toSpliced +description: > + %TypedArray%.prototype.toSpliced converts the this value length to a number. +info: | + %TypedArray%.prototype.toSpliced ( start, deleteCount, ...items ) + + ... + 3. Let len be O.[[ArrayLength]]. + 4. Let relativeStart be ? ToIntegerOrInfinity(start). + 5. If relativeStart is -∞, let actualStart be 0. + 6. Else if relativeStart < 0, let actualStart be max(len + relativeStart, 0). + ... +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +withTypedArrayConstructors((TA) => { + var result = new TA([0, 1, 2, 3, 4]).toSpliced(-3, 2); + assert.compareArray(result, [0, 1, 4]); +}); diff --git a/test/built-ins/TypedArray/prototype/toSpliced/start-undefined-and-deleteCount-missing.js b/test/built-ins/TypedArray/prototype/toSpliced/start-undefined-and-deleteCount-missing.js new file mode 100644 index 00000000000..0afa597a0c7 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/toSpliced/start-undefined-and-deleteCount-missing.js @@ -0,0 +1,29 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.toSpliced +description: %TypedArray%.prototype.toSpliced(undefined) returns an empty array +info: | + 22.1.3.25 %TypedArray%.prototype.toSpliced ( start, deleteCount , ...items ) + + ... + 4. Let relativeStart be ? ToIntegerOrInfinity(start). + ... + 7. Else, let actualStart be min(relativeStart, len). + ... + 8. If start is not present, then + a. Let insertCount be 0. + b. Let actualDeleteCount be 0. + 8. Else if deleteCount is not present, then + a. Let insertCount be 0. + b. Let actualDeleteCount be len - actualStart. + ... +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +withTypedArrayConstructors((TA) => { + var result = new TA([1, 2, 3]).toSpliced(undefined); + assert.compareArray(result, []); +}); diff --git a/test/built-ins/TypedArray/prototype/toSpliced/this-value-invalid.js b/test/built-ins/TypedArray/prototype/toSpliced/this-value-invalid.js new file mode 100644 index 00000000000..2505ebdfd26 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/toSpliced/this-value-invalid.js @@ -0,0 +1,35 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.toSpliced +description: > + %TypedArray%.prototype.toSpliced throws if the receiver is null or undefined +info: | + %TypedArray%.prototype.toSpliced ( start, deleteCount , ...items ) + + 1. Let O be the this value. + 2. Perform ? ValidateTypedArray(O). + ... +includes: [testTypedArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +var invalidValues = { + 'null': null, + 'undefined': undefined, + 'true': true, + '"abc"': "abc", + '12': 12, + 'Symbol()': Symbol(), + '[1, 2, 3]': [1, 2, 3], + '{ 0: 1, 1: 2, 2: 3, length: 3 }': { 0: 1, 1: 2, 2: 3, length: 3 }, + 'Uint8Array.prototype': Uint8Array.prototype, +}; + +Object.keys(invalidValues).forEach(desc => { + var value = invalidValues[desc]; + assert.throws(TypeError, () => { + TypedArray.prototype.toSpliced.call(value); + }, `${desc} is not a valid TypedArray`); +}); From 2148f66a3bc91252503a019c97fc8fd8aaebcb6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Fri, 24 Dec 2021 17:17:13 +0100 Subject: [PATCH 10/86] Include `deepEqual.js` where needed --- .../Array/prototype/toReversed/get-descending-order.js | 1 + .../Array/prototype/toReversed/holes-not-preserved.js | 1 + test/built-ins/Array/prototype/toReversed/immutable.js | 1 + .../Array/prototype/toReversed/length-casted-to-zero.js | 1 + .../prototype/toReversed/length-decreased-while-iterating.js | 1 + .../prototype/toReversed/length-increased-while-iterating.js | 1 + .../Array/prototype/toReversed/length-integer-string.js | 1 + .../built-ins/Array/prototype/toReversed/this-value-boolean.js | 1 + .../Array/prototype/toReversed/zero-or-one-element.js | 1 + .../prototype/toSorted/comparefn-called-after-get-elements.js | 1 + test/built-ins/Array/prototype/toSorted/holes-not-preserved.js | 1 + test/built-ins/Array/prototype/toSorted/immutable.js | 1 + .../Array/prototype/toSorted/length-casted-to-zero.js | 1 + .../prototype/toSorted/length-increased-while-iterating.js | 1 + .../Array/prototype/toSorted/length-integer-string.js | 1 + test/built-ins/Array/prototype/toSorted/this-value-boolean.js | 1 + test/built-ins/Array/prototype/toSorted/zero-or-one-element.js | 1 + .../deleteCount-clamped-between-zero-and-remaining-count.js | 2 ++ .../built-ins/Array/prototype/toSpliced/deleteCount-missing.js | 2 ++ .../Array/prototype/toSpliced/deleteCount-undefined.js | 2 ++ .../Array/prototype/toSpliced/discarded-element-not-read.js | 2 ++ .../Array/prototype/toSpliced/elements-read-in-order.js | 2 ++ test/built-ins/Array/prototype/toSpliced/frozen-this-value.js | 1 + .../built-ins/Array/prototype/toSpliced/holes-not-preserved.js | 1 + test/built-ins/Array/prototype/toSpliced/immutable.js | 1 + .../Array/prototype/toSpliced/length-casted-to-zero.js | 1 + .../prototype/toSpliced/length-clamped-to-2pow53minus1.js | 3 ++- .../prototype/toSpliced/length-decreased-while-iterating.js | 1 + .../prototype/toSpliced/length-increased-while-iterating.js | 1 + .../Array/prototype/toSpliced/length-integer-string.js | 1 + .../Array/prototype/toSpliced/start-and-deleteCount-missing.js | 2 ++ .../prototype/toSpliced/start-and-deleteCount-undefineds.js | 2 ++ .../Array/prototype/toSpliced/start-bigger-than-length.js | 1 + .../Array/prototype/toSpliced/start-neg-infinity-is-zero.js | 1 + .../toSpliced/start-neg-less-than-minus-length-is-zero.js | 1 + .../prototype/toSpliced/start-neg-subtracted-from-length.js | 1 + .../toSpliced/start-undefined-and-deleteCount-missing.js | 2 ++ test/built-ins/Array/prototype/toSpliced/this-value-boolean.js | 1 + test/built-ins/Array/prototype/toSpliced/unmodified.js | 1 + test/built-ins/Array/prototype/with/frozen-this-value.js | 1 + test/built-ins/Array/prototype/with/holes-not-preserved.js | 1 + test/built-ins/Array/prototype/with/immutable.js | 1 + test/built-ins/Array/prototype/with/index-casted-to-number.js | 1 + test/built-ins/Array/prototype/with/index-negative.js | 1 + .../Array/prototype/with/length-decreased-while-iterating.js | 1 + .../Array/prototype/with/length-increased-while-iterating.js | 1 + test/built-ins/Array/prototype/with/length-integer-string.js | 1 + test/built-ins/Array/prototype/with/no-get-replaced-index.js | 1 + test/built-ins/Array/prototype/with/this-value-boolean.js | 1 + 49 files changed, 58 insertions(+), 1 deletion(-) diff --git a/test/built-ins/Array/prototype/toReversed/get-descending-order.js b/test/built-ins/Array/prototype/toReversed/get-descending-order.js index 3ece167551d..cf0ef324ed2 100644 --- a/test/built-ins/Array/prototype/toReversed/get-descending-order.js +++ b/test/built-ins/Array/prototype/toReversed/get-descending-order.js @@ -17,6 +17,7 @@ info: | c. Let fromValue be ? Get(O, from). ... features: [change-array-by-copy] +includes: [deepEqual.js] ---*/ var order = []; diff --git a/test/built-ins/Array/prototype/toReversed/holes-not-preserved.js b/test/built-ins/Array/prototype/toReversed/holes-not-preserved.js index 44e9371a8bf..800178526d2 100644 --- a/test/built-ins/Array/prototype/toReversed/holes-not-preserved.js +++ b/test/built-ins/Array/prototype/toReversed/holes-not-preserved.js @@ -18,6 +18,7 @@ info: | d. Perform ? CreateDataPropertyOrThrow(A, Pk, fromValue). ... features: [change-array-by-copy] +includes: [deepEqual.js] ---*/ var arr = [0, /* hole */, 2, /* hole */, 4]; diff --git a/test/built-ins/Array/prototype/toReversed/immutable.js b/test/built-ins/Array/prototype/toReversed/immutable.js index 98f885b6f79..0c21742f31b 100644 --- a/test/built-ins/Array/prototype/toReversed/immutable.js +++ b/test/built-ins/Array/prototype/toReversed/immutable.js @@ -6,6 +6,7 @@ esid: sec-array.prototype.toReversed description: > Array.prototype.toReversed does not mutate its this value features: [change-array-by-copy] +includes: [deepEqual.js] ---*/ var arr = [0, 1, 2]; diff --git a/test/built-ins/Array/prototype/toReversed/length-casted-to-zero.js b/test/built-ins/Array/prototype/toReversed/length-casted-to-zero.js index 2ba470c9f13..0ae30c5754c 100644 --- a/test/built-ins/Array/prototype/toReversed/length-casted-to-zero.js +++ b/test/built-ins/Array/prototype/toReversed/length-casted-to-zero.js @@ -12,6 +12,7 @@ info: | 2. Let len be ? LengthOfArrayLike(O). ... features: [change-array-by-copy] +includes: [deepEqual.js] ---*/ assert.deepEqual(Array.prototype.toReversed.call({ length: -2 }), []); diff --git a/test/built-ins/Array/prototype/toReversed/length-decreased-while-iterating.js b/test/built-ins/Array/prototype/toReversed/length-decreased-while-iterating.js index 0cecbd92e27..fd468665ff9 100644 --- a/test/built-ins/Array/prototype/toReversed/length-decreased-while-iterating.js +++ b/test/built-ins/Array/prototype/toReversed/length-decreased-while-iterating.js @@ -16,6 +16,7 @@ info: | c. Let fromValue be ? Get(O, from). ... features: [change-array-by-copy] +includes: [deepEqual.js] ---*/ var arr = [0, 1, 2, 3, 4]; diff --git a/test/built-ins/Array/prototype/toReversed/length-increased-while-iterating.js b/test/built-ins/Array/prototype/toReversed/length-increased-while-iterating.js index 357178acf93..756c0adfb38 100644 --- a/test/built-ins/Array/prototype/toReversed/length-increased-while-iterating.js +++ b/test/built-ins/Array/prototype/toReversed/length-increased-while-iterating.js @@ -16,6 +16,7 @@ info: | c. Let fromValue be ? Get(O, from). ... features: [change-array-by-copy] +includes: [deepEqual.js] ---*/ var arr = [0, 1, 2]; diff --git a/test/built-ins/Array/prototype/toReversed/length-integer-string.js b/test/built-ins/Array/prototype/toReversed/length-integer-string.js index 08b54db90ac..d1a46380811 100644 --- a/test/built-ins/Array/prototype/toReversed/length-integer-string.js +++ b/test/built-ins/Array/prototype/toReversed/length-integer-string.js @@ -12,6 +12,7 @@ info: | 2. Let len be ? LengthOfArrayLike(O). ... features: [change-array-by-copy] +includes: [deepEqual.js] ---*/ assert.deepEqual(Array.prototype.toReversed.call({ length: "2", 0: 1, 1: 2, 2: 3 }), [2, 1]); diff --git a/test/built-ins/Array/prototype/toReversed/this-value-boolean.js b/test/built-ins/Array/prototype/toReversed/this-value-boolean.js index 23366c74e48..fc4ff780dcb 100644 --- a/test/built-ins/Array/prototype/toReversed/this-value-boolean.js +++ b/test/built-ins/Array/prototype/toReversed/this-value-boolean.js @@ -12,6 +12,7 @@ info: | 2. Let len be ? LengthOfArrayLike(O). ... features: [change-array-by-copy] +includes: [deepEqual.js] ---*/ assert.deepEqual(Array.prototype.toReversed.call(true), []); diff --git a/test/built-ins/Array/prototype/toReversed/zero-or-one-element.js b/test/built-ins/Array/prototype/toReversed/zero-or-one-element.js index e76a809697e..1cd618f6525 100644 --- a/test/built-ins/Array/prototype/toReversed/zero-or-one-element.js +++ b/test/built-ins/Array/prototype/toReversed/zero-or-one-element.js @@ -6,6 +6,7 @@ esid: sec-array.prototype.toReversed description: > Array.prototype.toReversed returns a new array even if it has zero or one elements features: [change-array-by-copy] +includes: [deepEqual.js] ---*/ var zero = []; diff --git a/test/built-ins/Array/prototype/toSorted/comparefn-called-after-get-elements.js b/test/built-ins/Array/prototype/toSorted/comparefn-called-after-get-elements.js index 7ee184c87b5..a1e69f3f9c2 100644 --- a/test/built-ins/Array/prototype/toSorted/comparefn-called-after-get-elements.js +++ b/test/built-ins/Array/prototype/toSorted/comparefn-called-after-get-elements.js @@ -20,6 +20,7 @@ info: | SortCompare or steps in this algorithm and return that completion. ... features: [change-array-by-copy] +includes: [deepEqual.js] ---*/ var getCalls = []; diff --git a/test/built-ins/Array/prototype/toSorted/holes-not-preserved.js b/test/built-ins/Array/prototype/toSorted/holes-not-preserved.js index 3d6121b3887..28a49debdb6 100644 --- a/test/built-ins/Array/prototype/toSorted/holes-not-preserved.js +++ b/test/built-ins/Array/prototype/toSorted/holes-not-preserved.js @@ -19,6 +19,7 @@ info: | d. Set k to k + 1. ... features: [change-array-by-copy] +includes: [deepEqual.js] ---*/ var arr = [3, /* hole */, 4, /* hole */, 1]; diff --git a/test/built-ins/Array/prototype/toSorted/immutable.js b/test/built-ins/Array/prototype/toSorted/immutable.js index 535625ed2d7..6c6e4e83daa 100644 --- a/test/built-ins/Array/prototype/toSorted/immutable.js +++ b/test/built-ins/Array/prototype/toSorted/immutable.js @@ -6,6 +6,7 @@ esid: sec-array.prototype.toSorted description: > Array.prototype.toSorted does not mutate its this value features: [change-array-by-copy] +includes: [deepEqual.js] ---*/ var arr = [2, 0, 1]; diff --git a/test/built-ins/Array/prototype/toSorted/length-casted-to-zero.js b/test/built-ins/Array/prototype/toSorted/length-casted-to-zero.js index ee6ce838424..3b512799d84 100644 --- a/test/built-ins/Array/prototype/toSorted/length-casted-to-zero.js +++ b/test/built-ins/Array/prototype/toSorted/length-casted-to-zero.js @@ -12,6 +12,7 @@ info: | 3. Let len be ? LengthOfArrayLike(O). ... features: [change-array-by-copy] +includes: [deepEqual.js] ---*/ assert.deepEqual(Array.prototype.toSorted.call({ length: -2 }), []); diff --git a/test/built-ins/Array/prototype/toSorted/length-increased-while-iterating.js b/test/built-ins/Array/prototype/toSorted/length-increased-while-iterating.js index f7c798b053d..a27a744ad95 100644 --- a/test/built-ins/Array/prototype/toSorted/length-increased-while-iterating.js +++ b/test/built-ins/Array/prototype/toSorted/length-increased-while-iterating.js @@ -17,6 +17,7 @@ info: | b. Let kValue be ? Get(O, Pk). ... features: [change-array-by-copy] +includes: [deepEqual.js] ---*/ var arr = [5, 0, 3]; diff --git a/test/built-ins/Array/prototype/toSorted/length-integer-string.js b/test/built-ins/Array/prototype/toSorted/length-integer-string.js index d294c03dd8a..61d93563a16 100644 --- a/test/built-ins/Array/prototype/toSorted/length-integer-string.js +++ b/test/built-ins/Array/prototype/toSorted/length-integer-string.js @@ -12,6 +12,7 @@ info: | 3. Let len be ? LengthOfArrayLike(O). ... features: [change-array-by-copy] +includes: [deepEqual.js] ---*/ assert.deepEqual(Array.prototype.toSorted.call({ length: "2", 0: 4, 1: 0, 2: 1 }), [0, 4]); diff --git a/test/built-ins/Array/prototype/toSorted/this-value-boolean.js b/test/built-ins/Array/prototype/toSorted/this-value-boolean.js index 492dd9f5b6a..b03d29d2056 100644 --- a/test/built-ins/Array/prototype/toSorted/this-value-boolean.js +++ b/test/built-ins/Array/prototype/toSorted/this-value-boolean.js @@ -12,6 +12,7 @@ info: | 2. Let len be ? LengthOfArrayLike(O). ... features: [change-array-by-copy] +includes: [deepEqual.js] ---*/ assert.deepEqual(Array.prototype.toSorted.call(true), []); diff --git a/test/built-ins/Array/prototype/toSorted/zero-or-one-element.js b/test/built-ins/Array/prototype/toSorted/zero-or-one-element.js index 46d121c0f49..604bb50bef0 100644 --- a/test/built-ins/Array/prototype/toSorted/zero-or-one-element.js +++ b/test/built-ins/Array/prototype/toSorted/zero-or-one-element.js @@ -6,6 +6,7 @@ esid: sec-array.prototype.toSorted description: > Array.prototype.toSorted returns a new array even if it has zero or one elements features: [change-array-by-copy] +includes: [deepEqual.js] ---*/ var zero = []; diff --git a/test/built-ins/Array/prototype/toSpliced/deleteCount-clamped-between-zero-and-remaining-count.js b/test/built-ins/Array/prototype/toSpliced/deleteCount-clamped-between-zero-and-remaining-count.js index 1504c27655a..2af91399a01 100644 --- a/test/built-ins/Array/prototype/toSpliced/deleteCount-clamped-between-zero-and-remaining-count.js +++ b/test/built-ins/Array/prototype/toSpliced/deleteCount-clamped-between-zero-and-remaining-count.js @@ -12,6 +12,8 @@ info: | a. Let actualDeleteCount be len - actualStart. b. Let actualDeleteCount be the result of clamping dc between 0 and len - actualStart. ... +features: [change-array-by-copy] +includes: [deepEqual.js] ---*/ assert.deepEqual( diff --git a/test/built-ins/Array/prototype/toSpliced/deleteCount-missing.js b/test/built-ins/Array/prototype/toSpliced/deleteCount-missing.js index 658ef436fad..aef5b36ede8 100644 --- a/test/built-ins/Array/prototype/toSpliced/deleteCount-missing.js +++ b/test/built-ins/Array/prototype/toSpliced/deleteCount-missing.js @@ -11,6 +11,8 @@ info: | 9. Else if deleteCount is not present, then a. Let actualDeleteCount be len - actualStart. ... +features: [change-array-by-copy] +includes: [deepEqual.js] ---*/ var result = ["first", "second", "third"].toSpliced(1); diff --git a/test/built-ins/Array/prototype/toSpliced/deleteCount-undefined.js b/test/built-ins/Array/prototype/toSpliced/deleteCount-undefined.js index 53fe720f4be..19ae816ef22 100644 --- a/test/built-ins/Array/prototype/toSpliced/deleteCount-undefined.js +++ b/test/built-ins/Array/prototype/toSpliced/deleteCount-undefined.js @@ -17,6 +17,8 @@ info: | 8. Else if deleteCount is not present, then a. Let actualDeleteCount be len - actualStart. ... +features: [change-array-by-copy] +includes: [deepEqual.js] ---*/ var result = ["first", "second", "third"].toSpliced(1, undefined); diff --git a/test/built-ins/Array/prototype/toSpliced/discarded-element-not-read.js b/test/built-ins/Array/prototype/toSpliced/discarded-element-not-read.js index 1743fdb740e..8b28f5b03e0 100644 --- a/test/built-ins/Array/prototype/toSpliced/discarded-element-not-read.js +++ b/test/built-ins/Array/prototype/toSpliced/discarded-element-not-read.js @@ -17,6 +17,8 @@ info: | 8. Else if deleteCount is not present, then a. Let actualDeleteCount be len - actualStart. ... +features: [change-array-by-copy] +includes: [deepEqual.js] ---*/ var arrayLike = { diff --git a/test/built-ins/Array/prototype/toSpliced/elements-read-in-order.js b/test/built-ins/Array/prototype/toSpliced/elements-read-in-order.js index f8d6458c068..f8704de830d 100644 --- a/test/built-ins/Array/prototype/toSpliced/elements-read-in-order.js +++ b/test/built-ins/Array/prototype/toSpliced/elements-read-in-order.js @@ -17,6 +17,8 @@ info: | 8. Else if deleteCount is not present, then a. Let actualDeleteCount be len - actualStart. ... +features: [change-array-by-copy] +includes: [deepEqual.js] ---*/ var order = []; diff --git a/test/built-ins/Array/prototype/toSpliced/frozen-this-value.js b/test/built-ins/Array/prototype/toSpliced/frozen-this-value.js index c68fa35b142..cc16a08614e 100644 --- a/test/built-ins/Array/prototype/toSpliced/frozen-this-value.js +++ b/test/built-ins/Array/prototype/toSpliced/frozen-this-value.js @@ -6,6 +6,7 @@ esid: sec-array.prototype.toSpliced description: > Array.prototype.toSpliced works on frozen objects features: [change-array-by-copy] +includes: [deepEqual.js] ---*/ var arr = Object.freeze([2, 0, 1]); diff --git a/test/built-ins/Array/prototype/toSpliced/holes-not-preserved.js b/test/built-ins/Array/prototype/toSpliced/holes-not-preserved.js index 9bb44bcf0cd..9cfac4d4c68 100644 --- a/test/built-ins/Array/prototype/toSpliced/holes-not-preserved.js +++ b/test/built-ins/Array/prototype/toSpliced/holes-not-preserved.js @@ -23,6 +23,7 @@ info: | d. Perform ? CreateDataPropertyOrThrow(A, Pk, fromValue). e. Set k to k + 1. ... +includes: [deepEqual.js] features: [change-array-by-copy] ---*/ diff --git a/test/built-ins/Array/prototype/toSpliced/immutable.js b/test/built-ins/Array/prototype/toSpliced/immutable.js index 2a12ad38a03..9c091c0916c 100644 --- a/test/built-ins/Array/prototype/toSpliced/immutable.js +++ b/test/built-ins/Array/prototype/toSpliced/immutable.js @@ -6,6 +6,7 @@ esid: sec-array.prototype.toSpliced description: > Array.prototype.toSpliced does not mutate its this value features: [change-array-by-copy] +includes: [deepEqual.js] ---*/ var arr = [2, 0, 1]; diff --git a/test/built-ins/Array/prototype/toSpliced/length-casted-to-zero.js b/test/built-ins/Array/prototype/toSpliced/length-casted-to-zero.js index 86635417b91..8b71f5dbb75 100644 --- a/test/built-ins/Array/prototype/toSpliced/length-casted-to-zero.js +++ b/test/built-ins/Array/prototype/toSpliced/length-casted-to-zero.js @@ -12,6 +12,7 @@ info: | 2. Let len be ? LengthOfArrayLike(O). ... features: [change-array-by-copy] +includes: [deepEqual.js] ---*/ assert.deepEqual(Array.prototype.toSpliced.call({ length: -2 }, 0, 0, 2, 3), [2, 3]); diff --git a/test/built-ins/Array/prototype/toSpliced/length-clamped-to-2pow53minus1.js b/test/built-ins/Array/prototype/toSpliced/length-clamped-to-2pow53minus1.js index 6281e892bcd..7e69f8dc119 100644 --- a/test/built-ins/Array/prototype/toSpliced/length-clamped-to-2pow53minus1.js +++ b/test/built-ins/Array/prototype/toSpliced/length-clamped-to-2pow53minus1.js @@ -55,7 +55,8 @@ info: | 2. If len ≀ 0, return +0𝔽. 3. Return 𝔽(min(len, 253 - 1)) -includes: [compareArray.js] +features: [change-array-by-copy] +includes: [deepEqual.js] ---*/ var arrayLike = { diff --git a/test/built-ins/Array/prototype/toSpliced/length-decreased-while-iterating.js b/test/built-ins/Array/prototype/toSpliced/length-decreased-while-iterating.js index 19d281d30b2..07ff1ce3bca 100644 --- a/test/built-ins/Array/prototype/toSpliced/length-decreased-while-iterating.js +++ b/test/built-ins/Array/prototype/toSpliced/length-decreased-while-iterating.js @@ -28,6 +28,7 @@ info: | e. Set k to k + 1. ... features: [change-array-by-copy] +includes: [deepEqual.js] ---*/ var arr = [0, 1, 2, 3, 4, 5]; diff --git a/test/built-ins/Array/prototype/toSpliced/length-increased-while-iterating.js b/test/built-ins/Array/prototype/toSpliced/length-increased-while-iterating.js index f59d305cc7c..03fcf19398b 100644 --- a/test/built-ins/Array/prototype/toSpliced/length-increased-while-iterating.js +++ b/test/built-ins/Array/prototype/toSpliced/length-increased-while-iterating.js @@ -17,6 +17,7 @@ info: | b. Let kValue be ? Get(O, Pk). ... features: [change-array-by-copy] +includes: [deepEqual.js] ---*/ var arr = [0, 1, 2]; diff --git a/test/built-ins/Array/prototype/toSpliced/length-integer-string.js b/test/built-ins/Array/prototype/toSpliced/length-integer-string.js index 53a38c4614b..57d6e7aeca6 100644 --- a/test/built-ins/Array/prototype/toSpliced/length-integer-string.js +++ b/test/built-ins/Array/prototype/toSpliced/length-integer-string.js @@ -12,6 +12,7 @@ info: | 2. Let len be ? LengthOfArrayLike(O). ... features: [change-array-by-copy] +includes: [deepEqual.js] ---*/ assert.deepEqual(Array.prototype.toSpliced.call({ length: "2", 0: 0, 1: 1, 2: 2 }, 0, 0), [0, 1]); diff --git a/test/built-ins/Array/prototype/toSpliced/start-and-deleteCount-missing.js b/test/built-ins/Array/prototype/toSpliced/start-and-deleteCount-missing.js index 73d8bcbda4f..2cb4f9c9eb5 100644 --- a/test/built-ins/Array/prototype/toSpliced/start-and-deleteCount-missing.js +++ b/test/built-ins/Array/prototype/toSpliced/start-and-deleteCount-missing.js @@ -15,6 +15,8 @@ info: | 8. If start is not present, then a. Let actualDeleteCount be 0. ... +features: [change-array-by-copy] +includes: [deepEqual.js] ---*/ var result = ["first", "second", "third"].toSpliced(); diff --git a/test/built-ins/Array/prototype/toSpliced/start-and-deleteCount-undefineds.js b/test/built-ins/Array/prototype/toSpliced/start-and-deleteCount-undefineds.js index 404eaae2354..e6aebd9900d 100644 --- a/test/built-ins/Array/prototype/toSpliced/start-and-deleteCount-undefineds.js +++ b/test/built-ins/Array/prototype/toSpliced/start-and-deleteCount-undefineds.js @@ -17,6 +17,8 @@ info: | 8. Else if deleteCount is not present, then a. Let actualDeleteCount be len - actualStart. ... +features: [change-array-by-copy] +includes: [deepEqual.js] ---*/ var result = ["first", "second", "third"].toSpliced(undefined, undefined); diff --git a/test/built-ins/Array/prototype/toSpliced/start-bigger-than-length.js b/test/built-ins/Array/prototype/toSpliced/start-bigger-than-length.js index de58f48f228..707bd84e454 100644 --- a/test/built-ins/Array/prototype/toSpliced/start-bigger-than-length.js +++ b/test/built-ins/Array/prototype/toSpliced/start-bigger-than-length.js @@ -16,6 +16,7 @@ info: | 6. Else, let actualStart be min(relativeStart, len). ... features: [change-array-by-copy] +includes: [deepEqual.js] ---*/ var result = [0, 1, 2, 3, 4].toSpliced(10, 1, 5, 6); diff --git a/test/built-ins/Array/prototype/toSpliced/start-neg-infinity-is-zero.js b/test/built-ins/Array/prototype/toSpliced/start-neg-infinity-is-zero.js index 5ea54c8df3a..102175ad5ab 100644 --- a/test/built-ins/Array/prototype/toSpliced/start-neg-infinity-is-zero.js +++ b/test/built-ins/Array/prototype/toSpliced/start-neg-infinity-is-zero.js @@ -15,6 +15,7 @@ info: | 5. Else if relativeStart < 0, let actualStart be max(len + relativeStart, 0). ... features: [change-array-by-copy] +includes: [deepEqual.js] ---*/ var result = [0, 1, 2, 3, 4].toSpliced(-Infinity, 2); diff --git a/test/built-ins/Array/prototype/toSpliced/start-neg-less-than-minus-length-is-zero.js b/test/built-ins/Array/prototype/toSpliced/start-neg-less-than-minus-length-is-zero.js index 093c04282ad..8b677bd35f1 100644 --- a/test/built-ins/Array/prototype/toSpliced/start-neg-less-than-minus-length-is-zero.js +++ b/test/built-ins/Array/prototype/toSpliced/start-neg-less-than-minus-length-is-zero.js @@ -15,6 +15,7 @@ info: | 5. Else if relativeStart < 0, let actualStart be max(len + relativeStart, 0). ... features: [change-array-by-copy] +includes: [deepEqual.js] ---*/ var result = [0, 1, 2, 3, 4].toSpliced(-20, 2); diff --git a/test/built-ins/Array/prototype/toSpliced/start-neg-subtracted-from-length.js b/test/built-ins/Array/prototype/toSpliced/start-neg-subtracted-from-length.js index dd212d9b6c8..210d66c605d 100644 --- a/test/built-ins/Array/prototype/toSpliced/start-neg-subtracted-from-length.js +++ b/test/built-ins/Array/prototype/toSpliced/start-neg-subtracted-from-length.js @@ -15,6 +15,7 @@ info: | 5. Else if relativeStart < 0, let actualStart be max(len + relativeStart, 0). ... features: [change-array-by-copy] +includes: [deepEqual.js] ---*/ var result = [0, 1, 2, 3, 4].toSpliced(-3, 2); diff --git a/test/built-ins/Array/prototype/toSpliced/start-undefined-and-deleteCount-missing.js b/test/built-ins/Array/prototype/toSpliced/start-undefined-and-deleteCount-missing.js index 529fa17f676..c237bdb3ced 100644 --- a/test/built-ins/Array/prototype/toSpliced/start-undefined-and-deleteCount-missing.js +++ b/test/built-ins/Array/prototype/toSpliced/start-undefined-and-deleteCount-missing.js @@ -17,6 +17,8 @@ info: | 8. Else if deleteCount is not present, then a. Let actualDeleteCount be len - actualStart. ... +features: [change-array-by-copy] +includes: [deepEqual.js] ---*/ var result = ["first", "second", "third"].toSpliced(undefined); diff --git a/test/built-ins/Array/prototype/toSpliced/this-value-boolean.js b/test/built-ins/Array/prototype/toSpliced/this-value-boolean.js index e9db963f550..944d6510638 100644 --- a/test/built-ins/Array/prototype/toSpliced/this-value-boolean.js +++ b/test/built-ins/Array/prototype/toSpliced/this-value-boolean.js @@ -12,6 +12,7 @@ info: | 2. Let len be ? LengthOfArrayLike(O). ... features: [change-array-by-copy] +includes: [deepEqual.js] ---*/ assert.deepEqual(Array.prototype.toSpliced.call(true, 0, 0), []); diff --git a/test/built-ins/Array/prototype/toSpliced/unmodified.js b/test/built-ins/Array/prototype/toSpliced/unmodified.js index fd1dc309d23..1c7f3c29440 100644 --- a/test/built-ins/Array/prototype/toSpliced/unmodified.js +++ b/test/built-ins/Array/prototype/toSpliced/unmodified.js @@ -6,6 +6,7 @@ esid: sec-array.prototype.toSpliced description: > Array.prototype.toSpliced returns a new array even if it the result is equal to the original array features: [change-array-by-copy] +includes: [deepEqual.js] ---*/ var arr = [1, 2, 3]; diff --git a/test/built-ins/Array/prototype/with/frozen-this-value.js b/test/built-ins/Array/prototype/with/frozen-this-value.js index 8052cf2338a..e313791e14b 100644 --- a/test/built-ins/Array/prototype/with/frozen-this-value.js +++ b/test/built-ins/Array/prototype/with/frozen-this-value.js @@ -6,6 +6,7 @@ esid: sec-array.prototype.with description: > Array.prototype.with works on frozen objects features: [change-array-by-copy] +includes: [deepEqual.js] ---*/ var arr = Object.freeze([0, 1, 2]); diff --git a/test/built-ins/Array/prototype/with/holes-not-preserved.js b/test/built-ins/Array/prototype/with/holes-not-preserved.js index 1145cacbe26..e1040671ffa 100644 --- a/test/built-ins/Array/prototype/with/holes-not-preserved.js +++ b/test/built-ins/Array/prototype/with/holes-not-preserved.js @@ -18,6 +18,7 @@ info: | d. Perform ? CreateDataPropertyOrThrow(A, Pk, fromValue). e. Set k to k + 1. features: [change-array-by-copy] +includes: [deepEqual.js] ---*/ var arr = [0, /* hole */, 2, /* hole */, 4]; diff --git a/test/built-ins/Array/prototype/with/immutable.js b/test/built-ins/Array/prototype/with/immutable.js index 31ff27c1c74..d1eeadf815d 100644 --- a/test/built-ins/Array/prototype/with/immutable.js +++ b/test/built-ins/Array/prototype/with/immutable.js @@ -6,6 +6,7 @@ esid: sec-array.prototype.with description: > Array.prototype.with does not mutate its this value features: [change-array-by-copy] +includes: [deepEqual.js] ---*/ var arr = [0, 1, 2]; diff --git a/test/built-ins/Array/prototype/with/index-casted-to-number.js b/test/built-ins/Array/prototype/with/index-casted-to-number.js index 966af65a73a..da21e700474 100644 --- a/test/built-ins/Array/prototype/with/index-casted-to-number.js +++ b/test/built-ins/Array/prototype/with/index-casted-to-number.js @@ -15,6 +15,7 @@ info: | 5. Else, let actualIndex be len + relativeIndex. ... features: [change-array-by-copy] +includes: [deepEqual.js] ---*/ var arr = [0, 4, 16]; diff --git a/test/built-ins/Array/prototype/with/index-negative.js b/test/built-ins/Array/prototype/with/index-negative.js index c16e3b62a94..9185ed08897 100644 --- a/test/built-ins/Array/prototype/with/index-negative.js +++ b/test/built-ins/Array/prototype/with/index-negative.js @@ -15,6 +15,7 @@ info: | 5. Else, let actualIndex be len + relativeIndex. ... features: [change-array-by-copy] +includes: [deepEqual.js] ---*/ var arr = [0, 1, 2]; diff --git a/test/built-ins/Array/prototype/with/length-decreased-while-iterating.js b/test/built-ins/Array/prototype/with/length-decreased-while-iterating.js index 5738a486ece..5f97eed9ace 100644 --- a/test/built-ins/Array/prototype/with/length-decreased-while-iterating.js +++ b/test/built-ins/Array/prototype/with/length-decreased-while-iterating.js @@ -18,6 +18,7 @@ info: | d. Perform ? CreateDataPropertyOrThrow(A, Pk, fromValue). e. Set k to k + 1. features: [change-array-by-copy] +includes: [deepEqual.js] ---*/ var arr = [0, 1, 2, 3, 4]; diff --git a/test/built-ins/Array/prototype/with/length-increased-while-iterating.js b/test/built-ins/Array/prototype/with/length-increased-while-iterating.js index da69ec13f00..93c487edc5a 100644 --- a/test/built-ins/Array/prototype/with/length-increased-while-iterating.js +++ b/test/built-ins/Array/prototype/with/length-increased-while-iterating.js @@ -18,6 +18,7 @@ info: | d. Perform ? CreateDataPropertyOrThrow(A, Pk, fromValue). e. Set k to k + 1. features: [change-array-by-copy] +includes: [deepEqual.js] ---*/ var arr = [0, 1, 2]; diff --git a/test/built-ins/Array/prototype/with/length-integer-string.js b/test/built-ins/Array/prototype/with/length-integer-string.js index 0d8d756e0be..12c2860db30 100644 --- a/test/built-ins/Array/prototype/with/length-integer-string.js +++ b/test/built-ins/Array/prototype/with/length-integer-string.js @@ -12,6 +12,7 @@ info: | 2. Let len be ? LengthOfArrayLike(O). ... features: [change-array-by-copy] +includes: [deepEqual.js] ---*/ var arrayLike = { length: "2", 0: 1, 1: 2, 2: 3 }; diff --git a/test/built-ins/Array/prototype/with/no-get-replaced-index.js b/test/built-ins/Array/prototype/with/no-get-replaced-index.js index f3dcd24ed8a..c6ee2f6dd4d 100644 --- a/test/built-ins/Array/prototype/with/no-get-replaced-index.js +++ b/test/built-ins/Array/prototype/with/no-get-replaced-index.js @@ -16,6 +16,7 @@ info: | d. Perform ? CreateDataPropertyOrThrow(A, Pk, fromValue). e. Set k to k + 1. features: [change-array-by-copy] +includes: [deepEqual.js] ---*/ var arr = [0, 1, 2, 3]; diff --git a/test/built-ins/Array/prototype/with/this-value-boolean.js b/test/built-ins/Array/prototype/with/this-value-boolean.js index b274dd7362d..044619ba765 100644 --- a/test/built-ins/Array/prototype/with/this-value-boolean.js +++ b/test/built-ins/Array/prototype/with/this-value-boolean.js @@ -12,6 +12,7 @@ info: | 2. Let len be ? LengthOfArrayLike(O). ... features: [change-array-by-copy] +includes: [deepEqual.js] ---*/ Boolean.prototype.length = 2; From 7ae0999a4b1474676dd97401fd8a5d4c3d716042 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Mon, 27 Dec 2021 16:32:58 +0100 Subject: [PATCH 11/86] Fix many test bugs --- .../length-decreased-while-iterating.js | 8 ++-- .../toSorted/comparefn-not-a-function.js | 4 +- .../length-decreased-while-iterating.js | 3 +- .../prototype/toSpliced/frozen-this-value.js | 2 +- .../toSpliced/holes-not-preserved.js | 2 +- .../length-clamped-to-2pow53minus1.js | 47 ++----------------- .../toSpliced/start-bigger-than-length.js | 2 +- .../Array/prototype/with/frozen-this-value.js | 2 +- .../Array/prototype/with/ignores-species.js | 4 +- .../with/length-decreased-while-iterating.js | 11 +++-- .../prototype/toReversed/frozen-this-value.js | 17 ------- .../toReversed/length-property-ignored.js | 2 +- .../prototype/toReversed/metadata/length.js | 4 +- .../prototype/toReversed/metadata/name.js | 6 +-- .../metadata/property-descriptor.js | 4 +- .../toSorted/comparefn-not-a-function.js | 2 +- .../toSorted/comparefn-stop-after-error.js | 22 ++++----- .../prototype/toSorted/frozen-this-value.js | 17 ------- .../length-decreased-while-comparing.js | 43 ----------------- .../length-increased-while-comparing.js | 45 ------------------ .../toSorted/length-property-ignored.js | 2 +- .../prototype/toSorted/metadata/length.js | 4 +- .../prototype/toSorted/metadata/name.js | 6 +-- .../toSorted/metadata/property-descriptor.js | 2 +- ...lamped-between-zero-and-remaining-count.js | 2 +- .../toSpliced/deleteCount-missing.js | 4 +- .../toSpliced/deleteCount-undefined.js | 3 +- .../prototype/toSpliced/frozen-this-value.js | 17 ------- .../toSpliced/length-property-ignored.js | 41 ++++++++++++++++ .../prototype/toSpliced/metadata/length.js | 2 +- .../prototype/toSpliced/metadata/name.js | 2 +- .../toSpliced/metadata/property-descriptor.js | 2 +- .../start-and-deleteCount-missing.js | 4 +- .../start-and-deleteCount-undefineds.js | 4 +- .../toSpliced/start-bigger-than-length.js | 4 +- .../toSpliced/start-neg-infinity-is-zero.js | 2 +- ...tart-neg-less-than-minus-length-is-zero.js | 2 +- .../start-neg-subtracted-from-length.js | 2 +- ...start-undefined-and-deleteCount-missing.js | 4 +- 39 files changed, 113 insertions(+), 243 deletions(-) delete mode 100644 test/built-ins/TypedArray/prototype/toReversed/frozen-this-value.js delete mode 100644 test/built-ins/TypedArray/prototype/toSorted/frozen-this-value.js delete mode 100644 test/built-ins/TypedArray/prototype/toSorted/length-decreased-while-comparing.js delete mode 100644 test/built-ins/TypedArray/prototype/toSorted/length-increased-while-comparing.js delete mode 100644 test/built-ins/TypedArray/prototype/toSpliced/frozen-this-value.js create mode 100644 test/built-ins/TypedArray/prototype/toSpliced/length-property-ignored.js diff --git a/test/built-ins/Array/prototype/toReversed/length-decreased-while-iterating.js b/test/built-ins/Array/prototype/toReversed/length-decreased-while-iterating.js index fd468665ff9..0d85857a1cc 100644 --- a/test/built-ins/Array/prototype/toReversed/length-decreased-while-iterating.js +++ b/test/built-ins/Array/prototype/toReversed/length-decreased-while-iterating.js @@ -20,13 +20,13 @@ includes: [deepEqual.js] ---*/ var arr = [0, 1, 2, 3, 4]; -Array.prototype[4] = 5; +Array.prototype[1] = 5; -Object.defineProperty(arr, "2", { +Object.defineProperty(arr, "3", { get() { arr.length = 1; - return 2; + return 3; } }); -assert.deepEqual(arr.toReversed(), [5, undefined, 2, 1, 0]); +assert.deepEqual(arr.toReversed(), [4, 3, undefined, 5, 0]); diff --git a/test/built-ins/Array/prototype/toSorted/comparefn-not-a-function.js b/test/built-ins/Array/prototype/toSorted/comparefn-not-a-function.js index ce51b4724c9..93332a569df 100644 --- a/test/built-ins/Array/prototype/toSorted/comparefn-not-a-function.js +++ b/test/built-ins/Array/prototype/toSorted/comparefn-not-a-function.js @@ -25,9 +25,9 @@ var invalidComparators = [null, true, false, "", /a/g, 42, [], {}, Symbol()]; for (var i = 0; i < invalidComparators.length; i++) { assert.throws(TypeError, function() { [1].toSorted(invalidComparators[i]); - }, invalidComparators[i]); + }, String(invalidComparators[i])); assert.throws(TypeError, function() { Array.prototype.toSorted.call(getLengthThrow, invalidComparators[i]); - }, invalidComparators[i]); + }, String(invalidComparators[i])); } diff --git a/test/built-ins/Array/prototype/toSorted/length-decreased-while-iterating.js b/test/built-ins/Array/prototype/toSorted/length-decreased-while-iterating.js index bca16ed204e..42243bb6cf4 100644 --- a/test/built-ins/Array/prototype/toSorted/length-decreased-while-iterating.js +++ b/test/built-ins/Array/prototype/toSorted/length-decreased-while-iterating.js @@ -17,6 +17,7 @@ info: | b. Let kValue be ? Get(O, Pk). ... features: [change-array-by-copy] +includes: [deepEqual.js] ---*/ var arr = [5, 1, 4, 6, 3]; @@ -29,4 +30,4 @@ Object.defineProperty(arr, "2", { } }); -assert.deepEqual(arr.toSorted(), [1, 2, 4, 5]); +assert.deepEqual(arr.toSorted(), [1, 2, 4, 5, undefined]); diff --git a/test/built-ins/Array/prototype/toSpliced/frozen-this-value.js b/test/built-ins/Array/prototype/toSpliced/frozen-this-value.js index cc16a08614e..674e92ffb5e 100644 --- a/test/built-ins/Array/prototype/toSpliced/frozen-this-value.js +++ b/test/built-ins/Array/prototype/toSpliced/frozen-this-value.js @@ -14,4 +14,4 @@ arr.toSpliced(); var arrayLike = Object.freeze({ length: 3, 0: 0, 1: 1, 2: 2 }); -assert.deepEqual(Array.prototype.toSpliced.call(1, 1, 4, 5), [0, 4, 5, 2]); +assert.deepEqual(Array.prototype.toSpliced.call(arrayLike, 1, 1, 4, 5), [0, 4, 5, 2]); diff --git a/test/built-ins/Array/prototype/toSpliced/holes-not-preserved.js b/test/built-ins/Array/prototype/toSpliced/holes-not-preserved.js index 9cfac4d4c68..4c6279e41de 100644 --- a/test/built-ins/Array/prototype/toSpliced/holes-not-preserved.js +++ b/test/built-ins/Array/prototype/toSpliced/holes-not-preserved.js @@ -36,4 +36,4 @@ assert(spliced.hasOwnProperty(1)); assert(spliced.hasOwnProperty(3)); spliced = arr.toSpliced(0, 0, -1); -assert.deepEqual(spliced, [0, -1, undefined, 2, 3, 4]); +assert.deepEqual(spliced, [-1, 0, undefined, 2, 3, 4]); diff --git a/test/built-ins/Array/prototype/toSpliced/length-clamped-to-2pow53minus1.js b/test/built-ins/Array/prototype/toSpliced/length-clamped-to-2pow53minus1.js index 7e69f8dc119..cb7eb2cf916 100644 --- a/test/built-ins/Array/prototype/toSpliced/length-clamped-to-2pow53minus1.js +++ b/test/built-ins/Array/prototype/toSpliced/length-clamped-to-2pow53minus1.js @@ -1,45 +1,6 @@ // Copyright (C) 2021 Igalia. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-array.prototype.toSpliced -description: > - Array.prototype.toSpliced caches the length getting the array elements. -info: | - Array.prototype.toSpliced ( start, deleteCount, ...items ) - - ... - 2. Let len be ? LengthOfArrayLike(O). - ... - 11. Let newLen be len + insertCount - actualDeleteCount. - ... - 13. Let k be 0. - 14. Repeat, while k < actualStart, - a. Let Pk be ! ToString(𝔽(k)). - b. Let kValue be ? Get(O, Pk). - c. Perform ? CreateDataPropertyOrThrow(A, Pk, kValue). - d. Set k to k + 1. - ... - 16. Repeat, while k < newLen, - a. Let Pk be ! ToString(𝔽(k)). - b. Let from be ! ToString(𝔽(k + actualDeleteCount - insertCount)). - c. Let fromValue be ? Get(O, from). - d. Perform ? CreateDataPropertyOrThrow(A, Pk, fromValue). - e. Set k to k + 1. - ... - - - ToLength ( argument ) - - 1. Let len be ? ToIntegerOrInfinity(argument). - 2. If len ≀ 0, return +0𝔽. - 3. Return 𝔽(min(len, 253 - 1)). -features: [change-array-by-copy] ----*/ - -// Copyright (C) 2017 AndrΓ© Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - /*--- esid: sec-array.prototype.toSpliced description: > @@ -53,13 +14,13 @@ info: | 1. Let len be ? ToIntegerOrInfinity(argument). 2. If len ≀ 0, return +0𝔽. - 3. Return 𝔽(min(len, 253 - 1)) - + 3. Return 𝔽(min(len, 2^53 - 1)) features: [change-array-by-copy] includes: [deepEqual.js] ---*/ var arrayLike = { + "9007199254740989": 2 ** 53 - 3, "9007199254740990": 2 ** 53 - 2, "9007199254740991": 2 ** 53 - 1, "9007199254740992": 2 ** 53, @@ -67,7 +28,7 @@ var arrayLike = { length: 2 ** 53 + 20, }; -var result = Array.prototype.splice.call(arrayLike, 0, 2 ** 53 - 3); +var result = Array.prototype.toSpliced.call(arrayLike, 0, 2 ** 53 - 4); assert.sameValue(result.length, 2); -assert.deepEqual(result, [2 ** 5 - 2, 2 ** 5 - 1]); +assert.deepEqual(result, [2 ** 53 - 3, 2 ** 53 - 2]); diff --git a/test/built-ins/Array/prototype/toSpliced/start-bigger-than-length.js b/test/built-ins/Array/prototype/toSpliced/start-bigger-than-length.js index 707bd84e454..b1e31a32344 100644 --- a/test/built-ins/Array/prototype/toSpliced/start-bigger-than-length.js +++ b/test/built-ins/Array/prototype/toSpliced/start-bigger-than-length.js @@ -20,4 +20,4 @@ includes: [deepEqual.js] ---*/ var result = [0, 1, 2, 3, 4].toSpliced(10, 1, 5, 6); -assert.deepEqual(result, [5, 6]); +assert.deepEqual(result, [0, 1, 2, 3, 4, 5, 6]); diff --git a/test/built-ins/Array/prototype/with/frozen-this-value.js b/test/built-ins/Array/prototype/with/frozen-this-value.js index e313791e14b..97bc0d341c5 100644 --- a/test/built-ins/Array/prototype/with/frozen-this-value.js +++ b/test/built-ins/Array/prototype/with/frozen-this-value.js @@ -14,5 +14,5 @@ var result = arr.with(1, 3); assert.deepEqual(result, [0, 3, 2]); var arrayLike = Object.freeze({ length: 3, 0: 0, 1: 1, 2: 2 }); -var result2 = Array.prototype.with.call(arrayLike); +var result2 = Array.prototype.with.call(arrayLike, 1, 3); assert.deepEqual(result2, [0, 3, 2]); diff --git a/test/built-ins/Array/prototype/with/ignores-species.js b/test/built-ins/Array/prototype/with/ignores-species.js index e4c6c3c61dd..6df66daa27b 100644 --- a/test/built-ins/Array/prototype/with/ignores-species.js +++ b/test/built-ins/Array/prototype/with/ignores-species.js @@ -14,13 +14,13 @@ info: | features: [change-array-by-copy] ---*/ -var a = []; +var a = [1, 2, 3]; a.constructor = {}; a.constructor[Symbol.species] = function () {} assert.sameValue(Object.getPrototypeOf(a.with(0, 0)), Array.prototype); -var b = []; +var b = [1, 2, 3]; Object.defineProperty(b, "constructor", { get() { throw new Test262Error("Should not get .constructor"); diff --git a/test/built-ins/Array/prototype/with/length-decreased-while-iterating.js b/test/built-ins/Array/prototype/with/length-decreased-while-iterating.js index 5f97eed9ace..0abbd1807b6 100644 --- a/test/built-ins/Array/prototype/with/length-decreased-while-iterating.js +++ b/test/built-ins/Array/prototype/with/length-decreased-while-iterating.js @@ -21,15 +21,20 @@ features: [change-array-by-copy] includes: [deepEqual.js] ---*/ -var arr = [0, 1, 2, 3, 4]; Array.prototype[4] = 5; -Object.defineProperty(arr, "1", { +var arr = Object.defineProperty([0, 1, 2, 3, 4], "1", { get() { arr.length = 1; return 1; } }); - assert.deepEqual(arr.with(2, 7), [0, 1, 7, undefined, 5]); + +arr = Object.defineProperty([0, 1, 2, 3, 4], "1", { + get() { + arr.length = 1; + return 1; + } +}); assert.deepEqual(arr.with(0, 7), [7, 1, undefined, undefined, 5]); diff --git a/test/built-ins/TypedArray/prototype/toReversed/frozen-this-value.js b/test/built-ins/TypedArray/prototype/toReversed/frozen-this-value.js deleted file mode 100644 index 268ee4e9673..00000000000 --- a/test/built-ins/TypedArray/prototype/toReversed/frozen-this-value.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2021 Igalia. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-%typedarray%.prototype.toReversed -description: > - TypedArray.prototype.toReversed works on frozen TAs -includes: [testTypedArray.js, compareArray.js] -features: [TypedArray, change-array-by-copy] ----*/ - -testWithTypedArrayConstructors(TA => { - var ta = Object.freeze(new TA([1, 2, 3])); - - var result = ta.toReversed(); - assert.compareArray(result, [3, 2, 1]); -}); diff --git a/test/built-ins/TypedArray/prototype/toReversed/length-property-ignored.js b/test/built-ins/TypedArray/prototype/toReversed/length-property-ignored.js index f24c9db24d9..1425e78acad 100644 --- a/test/built-ins/TypedArray/prototype/toReversed/length-property-ignored.js +++ b/test/built-ins/TypedArray/prototype/toReversed/length-property-ignored.js @@ -11,7 +11,7 @@ info: | ... 3. Let len be O.[[ArrayLength]]. ... -includes: [testTypedArray.js] +includes: [testTypedArray.js, compareArray.js] features: [TypedArray, change-array-by-copy] ---*/ diff --git a/test/built-ins/TypedArray/prototype/toReversed/metadata/length.js b/test/built-ins/TypedArray/prototype/toReversed/metadata/length.js index 5d97f3823ff..8649664e8b9 100644 --- a/test/built-ins/TypedArray/prototype/toReversed/metadata/length.js +++ b/test/built-ins/TypedArray/prototype/toReversed/metadata/length.js @@ -4,7 +4,7 @@ /*--- esid: sec-typedarray.prototype.toReversed description: > - The "length" property of TypedTypedArray.prototype.toReversed + The "length" property of TypedArray.prototype.toReversed info: | 17 ECMAScript Standard Built-in Objects @@ -22,7 +22,7 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray, change-array-by-copy] ---*/ -verifyProperty(TypedTypedArray.prototype.toReversed, "length", { +verifyProperty(TypedArray.prototype.toReversed, "length", { value: 0, writable: false, enumerable: false, diff --git a/test/built-ins/TypedArray/prototype/toReversed/metadata/name.js b/test/built-ins/TypedArray/prototype/toReversed/metadata/name.js index df33804ed37..d1de00b7928 100644 --- a/test/built-ins/TypedArray/prototype/toReversed/metadata/name.js +++ b/test/built-ins/TypedArray/prototype/toReversed/metadata/name.js @@ -4,9 +4,9 @@ /*--- esid: sec-typedarray.prototype.toReversed description: > - TypedTypedArray.prototype.toReversed.name is "toReversed". + TypedArray.prototype.toReversed.name is "toReversed". info: | - TypedTypedArray.prototype.toReversed ( ) + TypedArray.prototype.toReversed ( ) 17 ECMAScript Standard Built-in Objects: Every built-in Function object, including constructors, that is not @@ -20,7 +20,7 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray, change-array-by-copy] ---*/ -verifyProperty(TypedTypedArray.prototype.toReversed, "name", { +verifyProperty(TypedArray.prototype.toReversed, "name", { value: "toReversed", writable: false, enumerable: false, diff --git a/test/built-ins/TypedArray/prototype/toReversed/metadata/property-descriptor.js b/test/built-ins/TypedArray/prototype/toReversed/metadata/property-descriptor.js index 9f89760c4a3..a3695423dc8 100644 --- a/test/built-ins/TypedArray/prototype/toReversed/metadata/property-descriptor.js +++ b/test/built-ins/TypedArray/prototype/toReversed/metadata/property-descriptor.js @@ -15,10 +15,10 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray, change-array-by-copy] ---*/ -assert.sameValue(typeof TypedTypedArray.prototype.toReversed, "function", "typeof"); +assert.sameValue(typeof TypedArray.prototype.toReversed, "function", "typeof"); verifyProperty(TypedArray.prototype, "toReversed", { - value: TypedTypedArray.prototype.toReversed, + value: TypedArray.prototype.toReversed, writable: true, enumerable: false, configurable: true, diff --git a/test/built-ins/TypedArray/prototype/toSorted/comparefn-not-a-function.js b/test/built-ins/TypedArray/prototype/toSorted/comparefn-not-a-function.js index df7b69f0edf..0a88db9fe52 100644 --- a/test/built-ins/TypedArray/prototype/toSorted/comparefn-not-a-function.js +++ b/test/built-ins/TypedArray/prototype/toSorted/comparefn-not-a-function.js @@ -22,6 +22,6 @@ testWithTypedArrayConstructors(TA => { for (var i = 0; i < invalidComparators.length; i++) { assert.throws(TypeError, function() { ta.toSorted(invalidComparators[i]); - }, invalidComparators[i]); + }, String(invalidComparators[i])); } }); diff --git a/test/built-ins/TypedArray/prototype/toSorted/comparefn-stop-after-error.js b/test/built-ins/TypedArray/prototype/toSorted/comparefn-stop-after-error.js index 5d3d53ff13b..f623afdee51 100644 --- a/test/built-ins/TypedArray/prototype/toSorted/comparefn-stop-after-error.js +++ b/test/built-ins/TypedArray/prototype/toSorted/comparefn-stop-after-error.js @@ -20,17 +20,17 @@ features: [TypedArray, change-array-by-copy] function StopToSorted() {} -var called = false; - testWithTypedArrayConstructors(TA => { - var called = false; + var calls = 0; var ta = new TA([3, 1, 2]); - ta.toSorted(() => { - if (first) { - first = false; - throw new StopToSorted(); - } - called = true; - }); - assert.sameValue(called, false, "compareFn is not called after an error"); + try { + ta.toSorted(() => { + if (calls === 0) { + calls++; + throw new StopToSorted(); + } + calls++; + }); + } catch (e) {} + assert.sameValue(calls, 1, "compareFn is not called after an error"); }); diff --git a/test/built-ins/TypedArray/prototype/toSorted/frozen-this-value.js b/test/built-ins/TypedArray/prototype/toSorted/frozen-this-value.js deleted file mode 100644 index 7d30c658471..00000000000 --- a/test/built-ins/TypedArray/prototype/toSorted/frozen-this-value.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2021 Igalia. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-%typedarray%.prototype.toReversed -description: > - TypedArray.prototype.toReversed works on frozen TAs -includes: [testTypedArray.js, compareArray.js] -features: [TypedArray, change-array-by-copy] ----*/ - -testWithTypedArrayConstructors(TA => { - var ta = Object.freeze(new TA([3, 1, 2])); - - var result = ta.toSorted(); - assert.compareArray(result, [1, 2, 3]); -}); diff --git a/test/built-ins/TypedArray/prototype/toSorted/length-decreased-while-comparing.js b/test/built-ins/TypedArray/prototype/toSorted/length-decreased-while-comparing.js deleted file mode 100644 index 178b1cf4bee..00000000000 --- a/test/built-ins/TypedArray/prototype/toSorted/length-decreased-while-comparing.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2021 Igalia. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-%typedarray%.prototype.toSorted -description: > - %TypedArray%.prototype.toSorted caches the length getting the %typedarray% elements. -info: | - %TypedArray%.prototype.toSorted ( compareFn ) - - ... - 4. Let len be O.[[ArrayLength]]. - ... - 5. Let items be a new empty List. - 7. Let k be 0. - 8. Repeat, while k < len, - a. Let Pk be ! ToString(𝔽(k)). - b. Let kValue be ? Get(O, Pk). - c. Append kValue to items. - d. Set k to k + 1. - 9. Sort items using an implementation-defined sequence of calls - to SortCompare. If any such call returns an abrupt completion, - stop before performing any further calls to SortCompare or - steps in this algorithm and return that completion. - ... -includes: [testTypedArray.js, compareArray.js] -features: [TypedArray, change-%typedarray%-by-copy] ----*/ - -testWithTypedArrayConstructors(TA => { - var ta = new TA([3, 1, 2]); - - var popped = false; - - var sorted = ta.toSorted((a, b) => { - if (!popped) ta.pop(); - popped = true; - return 1; - }); - - assert.compareArray(sorted, [3, 1, 2]); - assert.compareArray(ta, [3, 1]); -}); diff --git a/test/built-ins/TypedArray/prototype/toSorted/length-increased-while-comparing.js b/test/built-ins/TypedArray/prototype/toSorted/length-increased-while-comparing.js deleted file mode 100644 index 674835efe1e..00000000000 --- a/test/built-ins/TypedArray/prototype/toSorted/length-increased-while-comparing.js +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2021 Igalia. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-%typedarray%.prototype.toSorted -description: > - %TypedArray%.prototype.toSorted caches the length getting the %typedarray% elements. -info: | - %TypedArray%.prototype.toSorted ( compareFn ) - - ... - 4. Let len be O.[[ArrayLength]]. - ... - 5. Let items be a new empty List. - 7. Let k be 0. - 8. Repeat, while k < len, - a. Let Pk be ! ToString(𝔽(k)). - b. Let kValue be ? Get(O, Pk). - c. Append kValue to items. - d. Set k to k + 1. - 9. Sort items using an implementation-defined sequence of calls - to SortCompare. If any such call returns an abrupt completion, - stop before performing any further calls to SortCompare or - steps in this algorithm and return that completion. - ... -includes: [testTypedArray.js, compareArray.js] -features: [TypedArray, change-%typedarray%-by-copy] ----*/ - -testWithTypedArrayConstructors(TA => { - var ta = new TA([3, 1, 2]); - - var sorted = ta.toSorted((a, b) => { - ta.push(10); - return 1; - }); - - assert.compareArray(sorted, [3, 1, 2]); - - assert(ta.length > 3); - assert.sameValue(ta[0], 3); - assert.sameValue(ta[1], 1); - assert.sameValue(ta[2], 2); - assert.sameValue(ta[3], 10); -}); diff --git a/test/built-ins/TypedArray/prototype/toSorted/length-property-ignored.js b/test/built-ins/TypedArray/prototype/toSorted/length-property-ignored.js index 2f08ee1219e..dfa7bf84ae9 100644 --- a/test/built-ins/TypedArray/prototype/toSorted/length-property-ignored.js +++ b/test/built-ins/TypedArray/prototype/toSorted/length-property-ignored.js @@ -11,7 +11,7 @@ info: | ... 4. Let len be O.[[ArrayLength]]. ... -includes: [testTypedArray.js] +includes: [testTypedArray.js, compareArray.js] features: [TypedArray, change-array-by-copy] ---*/ diff --git a/test/built-ins/TypedArray/prototype/toSorted/metadata/length.js b/test/built-ins/TypedArray/prototype/toSorted/metadata/length.js index acca03d1413..e115afd7a6a 100644 --- a/test/built-ins/TypedArray/prototype/toSorted/metadata/length.js +++ b/test/built-ins/TypedArray/prototype/toSorted/metadata/length.js @@ -4,7 +4,7 @@ /*--- esid: sec-typedarray.prototype.toSorted description: > - The "length" property of TypedTypedArray.prototype.toSorted + The "length" property of TypedArray.prototype.toSorted info: | 17 ECMAScript Standard Built-in Objects @@ -22,7 +22,7 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray, change-array-by-copy] ---*/ -verifyProperty(TypedTypedArray.prototype.toSorted, "length", { +verifyProperty(TypedArray.prototype.toSorted, "length", { value: 1, writable: false, enumerable: false, diff --git a/test/built-ins/TypedArray/prototype/toSorted/metadata/name.js b/test/built-ins/TypedArray/prototype/toSorted/metadata/name.js index 7616e91eb08..26caf82e657 100644 --- a/test/built-ins/TypedArray/prototype/toSorted/metadata/name.js +++ b/test/built-ins/TypedArray/prototype/toSorted/metadata/name.js @@ -4,9 +4,9 @@ /*--- esid: sec-typedarray.prototype.toSorted description: > - TypedTypedArray.prototype.toSorted.name is "toSorted". + TypedArray.prototype.toSorted.name is "toSorted". info: | - TypedTypedArray.prototype.toSorted ( comparefn ) + TypedArray.prototype.toSorted ( comparefn ) 17 ECMAScript Standard Built-in Objects: Every built-in Function object, including constructors, that is not @@ -20,7 +20,7 @@ includes: [propertyHelper.js, testTypedArray.js] features: [TypedArray, change-array-by-copy] ---*/ -verifyProperty(TypedTypedArray.prototype.toSorted, "name", { +verifyProperty(TypedArray.prototype.toSorted, "name", { value: "toSorted", writable: false, enumerable: false, diff --git a/test/built-ins/TypedArray/prototype/toSorted/metadata/property-descriptor.js b/test/built-ins/TypedArray/prototype/toSorted/metadata/property-descriptor.js index e436f0a8f31..288f1eb0238 100644 --- a/test/built-ins/TypedArray/prototype/toSorted/metadata/property-descriptor.js +++ b/test/built-ins/TypedArray/prototype/toSorted/metadata/property-descriptor.js @@ -18,7 +18,7 @@ features: [TypedArray, change-array-by-copy] assert.sameValue(typeof TypedArray.prototype.toSorted, "function", "typeof"); verifyProperty(TypedArray.prototype, "toSorted", { - value: TypedTypedArray.prototype.toSorted, + value: TypedArray.prototype.toSorted, writable: true, enumerable: false, configurable: true, diff --git a/test/built-ins/TypedArray/prototype/toSpliced/deleteCount-clamped-between-zero-and-remaining-count.js b/test/built-ins/TypedArray/prototype/toSpliced/deleteCount-clamped-between-zero-and-remaining-count.js index 5e823469b26..0adada4e52f 100644 --- a/test/built-ins/TypedArray/prototype/toSpliced/deleteCount-clamped-between-zero-and-remaining-count.js +++ b/test/built-ins/TypedArray/prototype/toSpliced/deleteCount-clamped-between-zero-and-remaining-count.js @@ -17,7 +17,7 @@ includes: [testTypedArray.js, compareArray.js] features: [TypedArray, change-array-by-copy] ---*/ -withTypedArrayConstructors((TA) => { +testWithTypedArrayConstructors((TA) => { assert.compareArray( new TA([0, 1, 2, 3, 4, 5]).toSpliced(2, -1), [0, 1, 2, 3, 4, 5] diff --git a/test/built-ins/TypedArray/prototype/toSpliced/deleteCount-missing.js b/test/built-ins/TypedArray/prototype/toSpliced/deleteCount-missing.js index 23e19388d81..34a4b293d6a 100644 --- a/test/built-ins/TypedArray/prototype/toSpliced/deleteCount-missing.js +++ b/test/built-ins/TypedArray/prototype/toSpliced/deleteCount-missing.js @@ -3,7 +3,7 @@ /*--- esid: sec-%typedarray%.prototype.toSpliced -description: %TypedArray%.prototype.toSpliced deletes the elements after start when called with one argument +description: '%TypedArray%.prototype.toSpliced deletes the elements after start when called with one argument' info: | 22.1.3.25 %TypedArray%.prototype.toSpliced (start, deleteCount , ...items ) @@ -16,7 +16,7 @@ includes: [testTypedArray.js, compareArray.js] features: [TypedArray, change-array-by-copy] ---*/ -withTypedArrayConstructors((TA) => { +testWithTypedArrayConstructors((TA) => { assert.compareArray( new TA([1, 2, 3]).toSpliced(1), [1] diff --git a/test/built-ins/TypedArray/prototype/toSpliced/deleteCount-undefined.js b/test/built-ins/TypedArray/prototype/toSpliced/deleteCount-undefined.js index 70f7b1ef9fe..569efdab16e 100644 --- a/test/built-ins/TypedArray/prototype/toSpliced/deleteCount-undefined.js +++ b/test/built-ins/TypedArray/prototype/toSpliced/deleteCount-undefined.js @@ -17,9 +17,10 @@ info: | a. Let insertCount be 0. b. Let actualDeleteCount be len - actualStart. ... +includes: [testTypedArray.js, compareArray.js] ---*/ -withTypedArrayConstructors((TA) => { +testWithTypedArrayConstructors((TA) => { assert.compareArray( new TA([1, 2, 3]).toSpliced(1, undefined), [1, 2, 3] diff --git a/test/built-ins/TypedArray/prototype/toSpliced/frozen-this-value.js b/test/built-ins/TypedArray/prototype/toSpliced/frozen-this-value.js deleted file mode 100644 index 6290929ed65..00000000000 --- a/test/built-ins/TypedArray/prototype/toSpliced/frozen-this-value.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2021 Igalia. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-%typedarray%.prototype.toSpliced -description: > - %TypedArray%.prototype.toSpliced works on frozen TAs -includes: [testTypedArray.js, compareArray.js] -features: [TypedArray, change-array-by-copy] ----*/ - -testWithTypedArrayConstructors(TA => { - var ta = Object.freeze(new TA([3, 1, 2])); - - var result = ta.toSpliced(0, 2, 4); - assert.compareArray(result, [4, 3]); -}); diff --git a/test/built-ins/TypedArray/prototype/toSpliced/length-property-ignored.js b/test/built-ins/TypedArray/prototype/toSpliced/length-property-ignored.js new file mode 100644 index 00000000000..14dd9e370c6 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/toSpliced/length-property-ignored.js @@ -0,0 +1,41 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.toSpliced +description: > + TypedArray.prototype.toSpliced reads the TypedArray length ignoring the .length property +info: | + TypedArray.prototype.toSpliced ( start, deleteCount, ...items ) + + ... + 4. Let len be O.[[ArrayLength]]. + ... +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +testWithTypedArrayConstructors(TA => { + var ta = new TA([3, 1, 2]); + Object.defineProperty(ta, "length", { value: 2 }) + assert.compareArray(ta.toSpliced(0, 0), [1, 2, 3]); + + ta = new TA([3, 1, 2]); + Object.defineProperty(ta, "length", { value: 5 }); + assert.compareArray(ta.toSpliced(0, 0), [1, 2, 3]); +}); + +var length; +Object.defineProperty(TypedArray.prototype, "length", { + get: () => length, +}); + +testWithTypedArrayConstructors(TA => { + var ta = new TA([3, 1, 2]); + + length = 2; + assert.compareArray(ta.toSpliced(0, 0), [1, 2, 3]); + + length = 5; + assert.compareArray(ta.toSpliced(0, 0), [1, 2, 3]); +}); diff --git a/test/built-ins/TypedArray/prototype/toSpliced/metadata/length.js b/test/built-ins/TypedArray/prototype/toSpliced/metadata/length.js index a4cc4bbc742..2cd73a715a0 100644 --- a/test/built-ins/TypedArray/prototype/toSpliced/metadata/length.js +++ b/test/built-ins/TypedArray/prototype/toSpliced/metadata/length.js @@ -18,7 +18,7 @@ info: | Unless otherwise specified, the length property of a built-in function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [testTypedArray.js, compareArray.js] +includes: [testTypedArray.js, propertyHelper.js] features: [TypedArray, change-array-by-copy] ---*/ diff --git a/test/built-ins/TypedArray/prototype/toSpliced/metadata/name.js b/test/built-ins/TypedArray/prototype/toSpliced/metadata/name.js index db192733f9c..a00696be4f6 100644 --- a/test/built-ins/TypedArray/prototype/toSpliced/metadata/name.js +++ b/test/built-ins/TypedArray/prototype/toSpliced/metadata/name.js @@ -16,7 +16,7 @@ info: | Unless otherwise specified, the name property of a built-in Function object, if it exists, has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [testTypedArray.js, compareArray.js] +includes: [testTypedArray.js, propertyHelper.js] features: [TypedArray, change-array-by-copy] ---*/ diff --git a/test/built-ins/TypedArray/prototype/toSpliced/metadata/property-descriptor.js b/test/built-ins/TypedArray/prototype/toSpliced/metadata/property-descriptor.js index aa63aedfb3f..05335b41148 100644 --- a/test/built-ins/TypedArray/prototype/toSpliced/metadata/property-descriptor.js +++ b/test/built-ins/TypedArray/prototype/toSpliced/metadata/property-descriptor.js @@ -11,7 +11,7 @@ info: | Every other data property described in clauses 18 through 26 and in Annex B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified. -includes: [testTypedArray.js, compareArray.js] +includes: [testTypedArray.js, propertyHelper.js] features: [TypedArray, change-array-by-copy] ---*/ diff --git a/test/built-ins/TypedArray/prototype/toSpliced/start-and-deleteCount-missing.js b/test/built-ins/TypedArray/prototype/toSpliced/start-and-deleteCount-missing.js index b4911a95909..12d5696b028 100644 --- a/test/built-ins/TypedArray/prototype/toSpliced/start-and-deleteCount-missing.js +++ b/test/built-ins/TypedArray/prototype/toSpliced/start-and-deleteCount-missing.js @@ -3,7 +3,7 @@ /*--- esid: sec-%typedarray%.prototype.toSpliced -description: %TypedArray%.prototype.toSpliced returns a copy of the TypedArray if called with zero arguments +description: '%TypedArray%.prototype.toSpliced returns a copy of the TypedArray if called with zero arguments' info: | 22.1.3.25 %TypedArray%.prototype.toSpliced (start, deleteCount , ...items ) @@ -18,7 +18,7 @@ includes: [testTypedArray.js, compareArray.js] features: [TypedArray, change-array-by-copy] ---*/ -withTypedArrayConstructors((TA) => { +testWithTypedArrayConstructors((TA) => { var result = new TA([1, 2, 3]).toSpliced(); assert.compareArray(result, [1, 2, 3]); diff --git a/test/built-ins/TypedArray/prototype/toSpliced/start-and-deleteCount-undefineds.js b/test/built-ins/TypedArray/prototype/toSpliced/start-and-deleteCount-undefineds.js index 00615279660..b9752bca1ad 100644 --- a/test/built-ins/TypedArray/prototype/toSpliced/start-and-deleteCount-undefineds.js +++ b/test/built-ins/TypedArray/prototype/toSpliced/start-and-deleteCount-undefineds.js @@ -3,7 +3,7 @@ /*--- esid: sec-%typedarray%.prototype.toSpliced -description: %TypedArray%.prototype.toSpliced(undefined, undefined) returns a copy of the original TypedArray +description: '%TypedArray%.prototype.toSpliced(undefined, undefined) returns a copy of the original TypedArray' info: | 22.1.3.25 %TypedArray%.prototype.toSpliced ( start, deleteCount , ...items ) @@ -22,7 +22,7 @@ includes: [testTypedArray.js, compareArray.js] features: [TypedArray, change-array-by-copy] ---*/ -withTypedArrayConstructors((TA) => { +testWithTypedArrayConstructors((TA) => { var result = new TA([1, 2, 3]).toSpliced(undefined, undefined); assert.compareArray(result, [1, 2, 3]); diff --git a/test/built-ins/TypedArray/prototype/toSpliced/start-bigger-than-length.js b/test/built-ins/TypedArray/prototype/toSpliced/start-bigger-than-length.js index a78625a4788..b4f91e39d04 100644 --- a/test/built-ins/TypedArray/prototype/toSpliced/start-bigger-than-length.js +++ b/test/built-ins/TypedArray/prototype/toSpliced/start-bigger-than-length.js @@ -19,7 +19,7 @@ includes: [testTypedArray.js, compareArray.js] features: [TypedArray, change-array-by-copy] ---*/ -withTypedArrayConstructors((TA) => { +testWithTypedArrayConstructors((TA) => { var result = new TA([0, 1, 2, 3, 4]).toSpliced(10, 1, 5, 6); - assert.compareArray(result, [5, 6]); + assert.compareArray(result, [0, 1, 2, 3, 4, 5, 6]); }); diff --git a/test/built-ins/TypedArray/prototype/toSpliced/start-neg-infinity-is-zero.js b/test/built-ins/TypedArray/prototype/toSpliced/start-neg-infinity-is-zero.js index 7cbaed8fcd6..952c3fb3e52 100644 --- a/test/built-ins/TypedArray/prototype/toSpliced/start-neg-infinity-is-zero.js +++ b/test/built-ins/TypedArray/prototype/toSpliced/start-neg-infinity-is-zero.js @@ -18,7 +18,7 @@ includes: [testTypedArray.js, compareArray.js] features: [TypedArray, change-array-by-copy] ---*/ -withTypedArrayConstructors((TA) => { +testWithTypedArrayConstructors((TA) => { var result = new TA([0, 1, 2, 3, 4]).toSpliced(-Infinity, 2); assert.compareArray(result, [2, 3, 4]); }); diff --git a/test/built-ins/TypedArray/prototype/toSpliced/start-neg-less-than-minus-length-is-zero.js b/test/built-ins/TypedArray/prototype/toSpliced/start-neg-less-than-minus-length-is-zero.js index 223a5280e9f..6f66dcbcbae 100644 --- a/test/built-ins/TypedArray/prototype/toSpliced/start-neg-less-than-minus-length-is-zero.js +++ b/test/built-ins/TypedArray/prototype/toSpliced/start-neg-less-than-minus-length-is-zero.js @@ -18,7 +18,7 @@ includes: [testTypedArray.js, compareArray.js] features: [TypedArray, change-array-by-copy] ---*/ -withTypedArrayConstructors((TA) => { +testWithTypedArrayConstructors((TA) => { var result = new TA([0, 1, 2, 3, 4]).toSpliced(-20, 2); assert.compareArray(result, [2, 3, 4]); }); diff --git a/test/built-ins/TypedArray/prototype/toSpliced/start-neg-subtracted-from-length.js b/test/built-ins/TypedArray/prototype/toSpliced/start-neg-subtracted-from-length.js index f98619e48ab..2f66b793ebe 100644 --- a/test/built-ins/TypedArray/prototype/toSpliced/start-neg-subtracted-from-length.js +++ b/test/built-ins/TypedArray/prototype/toSpliced/start-neg-subtracted-from-length.js @@ -18,7 +18,7 @@ includes: [testTypedArray.js, compareArray.js] features: [TypedArray, change-array-by-copy] ---*/ -withTypedArrayConstructors((TA) => { +testWithTypedArrayConstructors((TA) => { var result = new TA([0, 1, 2, 3, 4]).toSpliced(-3, 2); assert.compareArray(result, [0, 1, 4]); }); diff --git a/test/built-ins/TypedArray/prototype/toSpliced/start-undefined-and-deleteCount-missing.js b/test/built-ins/TypedArray/prototype/toSpliced/start-undefined-and-deleteCount-missing.js index 0afa597a0c7..63b8c7e980f 100644 --- a/test/built-ins/TypedArray/prototype/toSpliced/start-undefined-and-deleteCount-missing.js +++ b/test/built-ins/TypedArray/prototype/toSpliced/start-undefined-and-deleteCount-missing.js @@ -3,7 +3,7 @@ /*--- esid: sec-%typedarray%.prototype.toSpliced -description: %TypedArray%.prototype.toSpliced(undefined) returns an empty array +description: '%TypedArray%.prototype.toSpliced(undefined) returns an empty array' info: | 22.1.3.25 %TypedArray%.prototype.toSpliced ( start, deleteCount , ...items ) @@ -23,7 +23,7 @@ includes: [testTypedArray.js, compareArray.js] features: [TypedArray, change-array-by-copy] ---*/ -withTypedArrayConstructors((TA) => { +testWithTypedArrayConstructors((TA) => { var result = new TA([1, 2, 3]).toSpliced(undefined); assert.compareArray(result, []); }); From 205c8d9fb5df8e856869464ddd2ba85200f0e784 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Tue, 28 Dec 2021 15:17:42 +0100 Subject: [PATCH 12/86] %TypedArray%.prototype.with --- .../with/index-bigger-or-eq-than-length.js | 6 +-- .../prototype/with/ignores-species.js | 42 +++++++++++++++++++ .../TypedArray/prototype/with/immutable.js | 17 ++++++++ .../with/index-bigger-or-eq-than-length.js | 40 ++++++++++++++++++ .../prototype/with/index-casted-to-number.js | 29 +++++++++++++ .../prototype/with/index-negative.js | 31 ++++++++++++++ .../with/index-smaller-than-minus-length.js | 40 ++++++++++++++++++ .../prototype/with/length-property-ignored.js | 41 ++++++++++++++++++ .../prototype/with/metadata/length.js | 30 +++++++++++++ .../prototype/with/metadata/name.js | 28 +++++++++++++ .../with/metadata/property-descriptor.js | 25 +++++++++++ .../prototype/with/not-a-constructor.js | 33 +++++++++++++++ .../prototype/with/this-value-invalid.js | 35 ++++++++++++++++ 13 files changed, 394 insertions(+), 3 deletions(-) create mode 100644 test/built-ins/TypedArray/prototype/with/ignores-species.js create mode 100644 test/built-ins/TypedArray/prototype/with/immutable.js create mode 100644 test/built-ins/TypedArray/prototype/with/index-bigger-or-eq-than-length.js create mode 100644 test/built-ins/TypedArray/prototype/with/index-casted-to-number.js create mode 100644 test/built-ins/TypedArray/prototype/with/index-negative.js create mode 100644 test/built-ins/TypedArray/prototype/with/index-smaller-than-minus-length.js create mode 100644 test/built-ins/TypedArray/prototype/with/length-property-ignored.js create mode 100644 test/built-ins/TypedArray/prototype/with/metadata/length.js create mode 100644 test/built-ins/TypedArray/prototype/with/metadata/name.js create mode 100644 test/built-ins/TypedArray/prototype/with/metadata/property-descriptor.js create mode 100644 test/built-ins/TypedArray/prototype/with/not-a-constructor.js create mode 100644 test/built-ins/TypedArray/prototype/with/this-value-invalid.js diff --git a/test/built-ins/Array/prototype/with/index-bigger-or-eq-than-length.js b/test/built-ins/Array/prototype/with/index-bigger-or-eq-than-length.js index 082935341c6..f45ecced1e1 100644 --- a/test/built-ins/Array/prototype/with/index-bigger-or-eq-than-length.js +++ b/test/built-ins/Array/prototype/with/index-bigger-or-eq-than-length.js @@ -2,11 +2,11 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-array.prototype.with +esid: sec-%typedarray%.prototype.with description: > - Array.prototype.with throws if the index is bigger than or equal to the array length. + %TypedArray%.prototype.with throws if the index is bigger than or equal to the array length. info: | - Array.prototype.with ( index, value ) + %TypedArray%.prototype.with ( index, value ) ... 2. Let len be ? LengthOfArrayLike(O). diff --git a/test/built-ins/TypedArray/prototype/with/ignores-species.js b/test/built-ins/TypedArray/prototype/with/ignores-species.js new file mode 100644 index 00000000000..4a1ab24cb08 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/with/ignores-species.js @@ -0,0 +1,42 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.with +description: > + %TypedArray%.prototype.with ignores @@species +info: | + %TypedArray%.prototype.with ( index, value ) + + ... + 8. Let A be ? TypedArraySpeciesCreate(O, Β« 𝔽(len) Β», true). + ... + + TypedArraySpeciesCreate ( exemplar, argumentList [ , noSpeciesOverride ] ) + ... + 2. Let defaultConstructor be the intrinsic object listed in column one of Table 63 for exemplar.[[TypedArrayName]]. + 3. If noSpeciesOverride is true, let constructor be defaultConstructor. + ... +includes: [testTypedArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +testWithTypedArrayConstructors(TA => { + var ta = new TA([1, 2, 3]); + ta.constructor = TA === Uint8Array ? Int32Array : Uint8Array; + assert.sameValue(Object.getPrototypeOf(ta.with(0, 2)), TA.prototype); + + ta = new TA([1, 2, 3]); + ta.constructor = { + [Symbol.species]: TA === Uint8Array ? Int32Array : Uint8Array, + }; + assert.sameValue(Object.getPrototypeOf(ta.with(0, 2)), TA.prototype); + + ta = new TA([1, 2, 3]); + Object.defineProperty(ta, "constructor", { + get() { + throw new Test262Error("Should not get .constructor"); + } + }); + ta.with(0, 2); +}); diff --git a/test/built-ins/TypedArray/prototype/with/immutable.js b/test/built-ins/TypedArray/prototype/with/immutable.js new file mode 100644 index 00000000000..348e4f9101e --- /dev/null +++ b/test/built-ins/TypedArray/prototype/with/immutable.js @@ -0,0 +1,17 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.with +description: > + %TypedArray%.prototype.with does not mutate its this value +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +testWithTypedArrayConstructors(TA => { + var ta = new TA([3, 1, 2]); + ta.with(0, 2); + + assert.compareArray(ta, [3, 1, 2]); +}); diff --git a/test/built-ins/TypedArray/prototype/with/index-bigger-or-eq-than-length.js b/test/built-ins/TypedArray/prototype/with/index-bigger-or-eq-than-length.js new file mode 100644 index 00000000000..02f149d4bd9 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/with/index-bigger-or-eq-than-length.js @@ -0,0 +1,40 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-typed%array%.prototype.with +description: > + %TypedArray%.prototype.with throws if the index is bigger than or equal to the array length. +info: | + %TypedArray%.prototype.with ( index, value ) + + ... + 3. Let len be O.[[ArrayLength]]. + 3. Let relativeIndex be ? ToIntegerOrInfinity(index). + 4. If index >= 0, let actualIndex be relativeIndex. + 5. Else, let actualIndex be len + relativeIndex. + 6. If ! IsValidIntegerIndex(O, actualIndex) is false, throw a *RangeError* exception. + ... +includes: [testTypedArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +testWithTypedArrayConstructors(TA => { + var arr = new TA([0, 1, 2]); + + assert.throws(RangeError, function() { + arr.with(3, 7); + }); + + assert.throws(RangeError, function() { + arr.with(10, 7); + }); + + assert.throws(RangeError, function() { + arr.with(2 ** 53 + 2, 7); + }); + + assert.throws(RangeError, function() { + arr.with(Infinity, 7); + }); +}); diff --git a/test/built-ins/TypedArray/prototype/with/index-casted-to-number.js b/test/built-ins/TypedArray/prototype/with/index-casted-to-number.js new file mode 100644 index 00000000000..dbebc5bb9ab --- /dev/null +++ b/test/built-ins/TypedArray/prototype/with/index-casted-to-number.js @@ -0,0 +1,29 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.with +description: > + %TypedArray%.prototype.with casts the index to an integer. +info: | + %TypedArray%.prototype.with ( index, value ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + 3. Let relativeIndex be ? ToIntegerOrInfinity(index). + 4. If index >= 0, let actualIndex be relativeIndex. + 5. Else, let actualIndex be len + relativeIndex. + ... +features: [TypedArray, change-array-by-copy] +includes: [testTypedArray.js, deepEqual.js] +---*/ + +testWithTypedArrayConstructors(TA => { + var arr = new TA([0, 4, 16]); + + assert.deepEqual(arr.with(1.2, 7), [0, 7, 16]); + assert.deepEqual(arr.with("1", 3), [0, 3, 16]); + assert.deepEqual(arr.with("-1", 5), [1, 5, 6]); + assert.deepEqual(arr.with(NaN, 2), [2, 4, 16]); + assert.deepEqual(arr.with("dog", "cat"), ["cat", 4, 16]); +}); diff --git a/test/built-ins/TypedArray/prototype/with/index-negative.js b/test/built-ins/TypedArray/prototype/with/index-negative.js new file mode 100644 index 00000000000..9e8ff1d1c68 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/with/index-negative.js @@ -0,0 +1,31 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.with +description: > + Array.prototype.with adds length to index if it's negative. +info: | + Array.prototype.with ( index, value ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + 3. Let relativeIndex be ? ToIntegerOrInfinity(index). + 4. If index >= 0, let actualIndex be relativeIndex. + 5. Else, let actualIndex be len + relativeIndex. + ... +features: [change-array-by-copy] +includes: [testTypedArray.js, compareArray.js] +---*/ + +testWithTypedArrayConstructors(TA => { + var arr = new TA([0, 1, 2]); + + assert.compareArray(arr.with(-1, 4), [0, 1, 4]); + assert.compareArray(arr.with(-3, 4), [4, 1, 2]); + + // -0 is disallowed as TypedArray index + assert.throws(RangeError, function() { + arr.with(-0, 7); + }); +}); diff --git a/test/built-ins/TypedArray/prototype/with/index-smaller-than-minus-length.js b/test/built-ins/TypedArray/prototype/with/index-smaller-than-minus-length.js new file mode 100644 index 00000000000..0b06e1a0bfd --- /dev/null +++ b/test/built-ins/TypedArray/prototype/with/index-smaller-than-minus-length.js @@ -0,0 +1,40 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.with +description: > + Array.prototype.with throws if the (negative) index is smaller than -length. +info: | + Array.prototype.with ( index, value ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + 3. Let relativeIndex be ? ToIntegerOrInfinity(index). + 4. If index >= 0, let actualIndex be relativeIndex. + 5. Else, let actualIndex be len + relativeIndex. + 6. If actualIndex >= len or actualIndex < 0, throw a *RangeError* exception. + ... +features: [change-array-by-copy] +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(TA => { + var arr = new TA([0, 1, 2]); + + assert.throws(RangeError, function() { + arr.with(-4, 7); + }); + + assert.throws(RangeError, function() { + arr.with(-10, 7); + }); + + assert.throws(RangeError, function() { + arr.with(-(2 ** 53) - 2, 7); + }); + + assert.throws(RangeError, function() { + arr.with(-Infinity, 7); + }); +}); diff --git a/test/built-ins/TypedArray/prototype/with/length-property-ignored.js b/test/built-ins/TypedArray/prototype/with/length-property-ignored.js new file mode 100644 index 00000000000..4a0f26e2f0a --- /dev/null +++ b/test/built-ins/TypedArray/prototype/with/length-property-ignored.js @@ -0,0 +1,41 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.with +description: > + %TypedArray%.prototype.with reads the TypedArray length ignoring the .length property +info: | + %TypedArray%.prototype.with ( index, value ) + + ... + 3. Let len be O.[[ArrayLength]]. + ... +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +testWithTypedArrayConstructors(TA => { + var ta = new TA([3, 1, 2]); + Object.defineProperty(ta, "length", { value: 2 }) + assert.compareArray(ta.with(0, 0), [1, 2, 3]); + + ta = new TA([3, 1, 2]); + Object.defineProperty(ta, "length", { value: 5 }); + assert.compareArray(ta.with(0, 0), [1, 2, 3]); +}); + +var length; +Object.defineProperty(TypedArray.prototype, "length", { + get: () => length, +}); + +testWithTypedArrayConstructors(TA => { + var ta = new TA([3, 1, 2]); + + length = 2; + assert.compareArray(ta.with(0, 0), [1, 2, 3]); + + length = 5; + assert.compareArray(ta.with(0, 0), [1, 2, 3]); +}); diff --git a/test/built-ins/TypedArray/prototype/with/metadata/length.js b/test/built-ins/TypedArray/prototype/with/metadata/length.js new file mode 100644 index 00000000000..2cd73a715a0 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/with/metadata/length.js @@ -0,0 +1,30 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.toSpliced +description: > + The "length" property of %TypedArray%.prototype.toSpliced +info: | + 17 ECMAScript Standard Built-in Objects + + Every built-in function object, including constructors, has a length property + whose value is an integer. Unless otherwise specified, this value is equal to + the largest number of named arguments shown in the subclause headings for the + function description. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are shown using the form Β«...nameΒ») are not + included in the default argument count. + + Unless otherwise specified, the length property of a built-in function object + has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +includes: [testTypedArray.js, propertyHelper.js] +features: [TypedArray, change-array-by-copy] +---*/ + +verifyProperty(TypedArray.prototype.toSpliced, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true, +}); diff --git a/test/built-ins/TypedArray/prototype/with/metadata/name.js b/test/built-ins/TypedArray/prototype/with/metadata/name.js new file mode 100644 index 00000000000..93e01ef5abd --- /dev/null +++ b/test/built-ins/TypedArray/prototype/with/metadata/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.with +description: > + %TypedArray%.prototype.with.name is "with". +info: | + %TypedArray%.prototype.with ( index, value ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [testTypedArray.js, propertyHelper.js] +features: [TypedArray, change-array-by-copy] +---*/ + +verifyProperty(TypedArray.prototype.with, "name", { + value: "with", + writable: false, + enumerable: false, + configurable: true, +}); diff --git a/test/built-ins/TypedArray/prototype/with/metadata/property-descriptor.js b/test/built-ins/TypedArray/prototype/with/metadata/property-descriptor.js new file mode 100644 index 00000000000..adc9dbfe41d --- /dev/null +++ b/test/built-ins/TypedArray/prototype/with/metadata/property-descriptor.js @@ -0,0 +1,25 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.with +description: > + "with" property of %TypedArray%.prototype +info: | + 17 ECMAScript Standard Built-in Objects + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [testTypedArray.js, propertyHelper.js] +features: [TypedArray, change-array-by-copy] +---*/ + +assert.sameValue(typeof TypedArray.prototype.with, "function", "typeof"); + +verifyProperty(TypedArray.prototype, "with", { + value: TypedArray.prototype.with, + writable: true, + enumerable: false, + configurable: true, +}); diff --git a/test/built-ins/TypedArray/prototype/with/not-a-constructor.js b/test/built-ins/TypedArray/prototype/with/not-a-constructor.js new file mode 100644 index 00000000000..45759912644 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/with/not-a-constructor.js @@ -0,0 +1,33 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + %TypedArray%.prototype.with does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js, testTypedArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +assert.sameValue( + isConstructor(TypedArray.prototype.with), + false, + 'isConstructor(TypedArray.prototype.with) must return false' +); + +assert.throws(TypeError, () => { + new TypedArray.prototype.with(0, 1); +}, '`new %TypedArray%.prototype.with()` throws TypeError'); + diff --git a/test/built-ins/TypedArray/prototype/with/this-value-invalid.js b/test/built-ins/TypedArray/prototype/with/this-value-invalid.js new file mode 100644 index 00000000000..404d6eae557 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/with/this-value-invalid.js @@ -0,0 +1,35 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.with +description: > + %TypedArray%.prototype.with throws if the receiver is null or undefined +info: | + %TypedArray%.prototype.with ( start, deleteCount , ...items ) + + 1. Let O be the this value. + 2. Perform ? ValidateTypedArray(O). + ... +includes: [testTypedArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +var invalidValues = { + 'null': null, + 'undefined': undefined, + 'true': true, + '"abc"': "abc", + '12': 12, + 'Symbol()': Symbol(), + '[1, 2, 3]': [1, 2, 3], + '{ 0: 1, 1: 2, 2: 3, length: 3 }': { 0: 1, 1: 2, 2: 3, length: 3 }, + 'Uint8Array.prototype': Uint8Array.prototype, +}; + +Object.keys(invalidValues).forEach(desc => { + var value = invalidValues[desc]; + assert.throws(TypeError, () => { + TypedArray.prototype.with.call(value, 0, 0); + }, `${desc} is not a valid TypedArray`); +}); From c34e9b43b34a2a12b083acba9e0f1946521ec2d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Fri, 31 Dec 2021 10:52:15 +0100 Subject: [PATCH 13/86] Fix max array length tests --- .../length-exceeding-array-length-limit.js | 12 ++++++------ .../length-exceeding-array-length-limit.js | 12 ++++++------ .../length-exceeding-array-length-limit.js | 18 +++++++++--------- .../length-exceeding-array-length-limit.js | 14 +++++++------- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/test/built-ins/Array/prototype/toReversed/length-exceeding-array-length-limit.js b/test/built-ins/Array/prototype/toReversed/length-exceeding-array-length-limit.js index b60b1f7933a..a2deee8c0b3 100644 --- a/test/built-ins/Array/prototype/toReversed/length-exceeding-array-length-limit.js +++ b/test/built-ins/Array/prototype/toReversed/length-exceeding-array-length-limit.js @@ -4,7 +4,7 @@ /*--- esid: sec-array.prototype.toReversed description: > - Array.prototype.toReversed limits the length to 2 ** 53 - 1 + Array.prototype.toReversed limits the length to 2 ** 32 - 1 info: | Array.prototype.toReversed ( ) @@ -15,7 +15,7 @@ info: | ArrayCreate ( length [, proto ] ) - 1. If length > 2 ** 31 - 1, throw a RangeError exception. + 1. If length > 2 ** 32 - 1, throw a RangeError exception. features: [change-array-by-copy] ---*/ @@ -24,15 +24,15 @@ var arrayLike = { get "0"() { throw new Test262Error("Get 0"); }, - get "2147483647" () { // 2 ** 31 - 1 + get "4294967295" () { // 2 ** 32 - 1 throw new Test262Error("Get 2147483648"); }, - get "2147483648" () { // 2 ** 31 + get "4294967296" () { // 2 ** 32 throw new Test262Error("Get 2147483648"); }, - length: 2 ** 31 + length: 2 ** 32 }; -assert.throws(TypeError, function() { +assert.throws(RangeError, function() { Array.prototype.toReversed.call(arrayLike); }); diff --git a/test/built-ins/Array/prototype/toSorted/length-exceeding-array-length-limit.js b/test/built-ins/Array/prototype/toSorted/length-exceeding-array-length-limit.js index 7ef4db6a684..3bec52758f3 100644 --- a/test/built-ins/Array/prototype/toSorted/length-exceeding-array-length-limit.js +++ b/test/built-ins/Array/prototype/toSorted/length-exceeding-array-length-limit.js @@ -4,7 +4,7 @@ /*--- esid: sec-array.prototype.toSorted description: > - Array.prototype.toSorted limits the length to 2 ** 53 - 1 + Array.prototype.toSorted limits the length to 2 ** 32 - 1 info: | Array.prototype.toSorted ( compareFn ) @@ -16,7 +16,7 @@ info: | ArrayCreate ( length [, proto ] ) - 1. If length > 2 ** 31 - 1, throw a RangeError exception. + 1. If length > 2 ** 32 - 1, throw a RangeError exception. features: [change-array-by-copy] ---*/ @@ -25,15 +25,15 @@ var arrayLike = { get "0"() { throw new Test262Error("Get 0"); }, - get "2147483647" () { // 2 ** 31 - 1 + get "4294967295" () { // 2 ** 32 - 1 throw new Test262Error("Get 2147483648"); }, - get "2147483648" () { // 2 ** 31 + get "4294967296" () { // 2 ** 32 throw new Test262Error("Get 2147483648"); }, - length: 2 ** 31 + length: 2 ** 32 }; -assert.throws(TypeError, function() { +assert.throws(RangeError, function() { Array.prototype.toSorted.call(arrayLike); }); diff --git a/test/built-ins/Array/prototype/toSpliced/length-exceeding-array-length-limit.js b/test/built-ins/Array/prototype/toSpliced/length-exceeding-array-length-limit.js index be0f1a45d3b..679413a4608 100644 --- a/test/built-ins/Array/prototype/toSpliced/length-exceeding-array-length-limit.js +++ b/test/built-ins/Array/prototype/toSpliced/length-exceeding-array-length-limit.js @@ -4,7 +4,7 @@ /*--- esid: sec-array.prototype.toSpliced description: > - Array.prototype.toSpliced limits the length to 2 ** 53 - 1 + Array.prototype.toSpliced limits the length to 2 ** 32 - 1 info: | Array.prototype.toSpliced ( start, deleteCount, ...items ) @@ -17,29 +17,29 @@ info: | ArrayCreate ( length [, proto ] ) - 1. If length > 2 ** 31 - 1, throw a RangeError exception. + 1. If length > 2 ** 32 - 1, throw a RangeError exception. features: [change-array-by-copy] ---*/ // Object with large "length" property var arrayLike = { - get "0" () { + get "0"() { throw new Test262Error("Get 0"); }, - get "2147483647" () { // 2 ** 31 - 1 + get "4294967295" () { // 2 ** 32 - 1 throw new Test262Error("Get 2147483648"); }, - get "2147483648" () { // 2 ** 31 + get "4294967296" () { // 2 ** 32 throw new Test262Error("Get 2147483648"); }, - length: 2 ** 31 + length: 2 ** 32 }; -assert.throws(TypeError, function() { +assert.throws(RangeError, function() { Array.prototype.toSpliced.call(arrayLike, 0, 0); }); -arrayLike.length = 2 ** 31 - 1; -assert.throws(TypeError, function() { +arrayLike.length = 2 ** 32 - 1; +assert.throws(RangeError, function() { Array.prototype.toSpliced.call(arrayLike, 0, 0, 1); }); diff --git a/test/built-ins/Array/prototype/with/length-exceeding-array-length-limit.js b/test/built-ins/Array/prototype/with/length-exceeding-array-length-limit.js index b2e8fe29d8c..54d9d12c6fd 100644 --- a/test/built-ins/Array/prototype/with/length-exceeding-array-length-limit.js +++ b/test/built-ins/Array/prototype/with/length-exceeding-array-length-limit.js @@ -4,7 +4,7 @@ /*--- esid: sec-array.prototype.toReversed description: > - Array.prototype.toReversed limits the length to 2 ** 53 - 1 + Array.prototype.toReversed limits the length to 2 ** 32 - 1 info: | Array.prototype.toReversed ( ) @@ -16,24 +16,24 @@ info: | ArrayCreate ( length [, proto ] ) - 1. If length > 2 ** 31 - 1, throw a RangeError exception. + 1. If length > 2 ** 32 - 1, throw a RangeError exception. features: [change-array-by-copy] ---*/ // Object with large "length" property var arrayLike = { - get "0" () { + get "0"() { throw new Test262Error("Get 0"); }, - get "2147483647" () { // 2 ** 31 - 1 + get "4294967295" () { // 2 ** 32 - 1 throw new Test262Error("Get 2147483648"); }, - get "2147483648" () { // 2 ** 31 + get "4294967296" () { // 2 ** 32 throw new Test262Error("Get 2147483648"); }, - length: 2 ** 31 + length: 2 ** 32 }; -assert.throws(TypeError, function() { +assert.throws(RangeError, function() { Array.prototype.with.call(arrayLike, 0, 0); }); From cf150c6ca598b836caeeaaaa8d977b733d31b789 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Mon, 3 Jan 2022 14:59:14 +0100 Subject: [PATCH 14/86] Fix TypedArray `length-property-ignored` tests --- .../prototype/toReversed/length-property-ignored.js | 12 ++++++++---- .../prototype/toSorted/length-property-ignored.js | 12 ++++++++---- .../prototype/toSpliced/length-property-ignored.js | 12 ++++++++---- .../prototype/with/length-property-ignored.js | 12 ++++++++---- 4 files changed, 32 insertions(+), 16 deletions(-) diff --git a/test/built-ins/TypedArray/prototype/toReversed/length-property-ignored.js b/test/built-ins/TypedArray/prototype/toReversed/length-property-ignored.js index 1425e78acad..f6c382f7c2c 100644 --- a/test/built-ins/TypedArray/prototype/toReversed/length-property-ignored.js +++ b/test/built-ins/TypedArray/prototype/toReversed/length-property-ignored.js @@ -18,11 +18,13 @@ features: [TypedArray, change-array-by-copy] testWithTypedArrayConstructors(TA => { var ta = new TA([0, 1, 2]); Object.defineProperty(ta, "length", { value: 2 }) - assert.compareArray(ta.toReversed(), [2, 1, 0]); + var res = ta.toReversed(); + assert.compareArray([res[0], res[1], res[2], res[3]], [2, 1, 0, undefined]); ta = new TA([0, 1, 2]); Object.defineProperty(ta, "length", { value: 5 }); - assert.compareArray(ta.toReversed(), [2, 1, 0]); + res = ta.toReversed(); + assert.compareArray([res[0], res[1], res[2], res[3]], [2, 1, 0, undefined]); }); var length; @@ -34,8 +36,10 @@ testWithTypedArrayConstructors(TA => { var ta = new TA([0, 1, 2]); length = 2; - assert.compareArray(ta.toReversed(), [2, 1, 0]); + var res = ta.toReversed(); + assert.compareArray([res[0], res[1], res[2], res[3]], [2, 1, 0, undefined]); length = 5; - assert.compareArray(ta.toReversed(), [2, 1, 0]); + res = ta.toReversed(); + assert.compareArray([res[0], res[1], res[2], res[3]], [2, 1, 0, undefined]); }); diff --git a/test/built-ins/TypedArray/prototype/toSorted/length-property-ignored.js b/test/built-ins/TypedArray/prototype/toSorted/length-property-ignored.js index dfa7bf84ae9..c0d9a1d7719 100644 --- a/test/built-ins/TypedArray/prototype/toSorted/length-property-ignored.js +++ b/test/built-ins/TypedArray/prototype/toSorted/length-property-ignored.js @@ -18,11 +18,13 @@ features: [TypedArray, change-array-by-copy] testWithTypedArrayConstructors(TA => { var ta = new TA([3, 1, 2]); Object.defineProperty(ta, "length", { value: 2 }) - assert.compareArray(ta.toSorted(), [1, 2, 3]); + var res = ta.toSorted() + assert.compareArray([res[0], res[1], res[2], res[3]], [1, 2, 3, undefined]); ta = new TA([3, 1, 2]); Object.defineProperty(ta, "length", { value: 5 }); - assert.compareArray(ta.toSorted(), [1, 2, 3]); + res = ta.toSorted() + assert.compareArray([res[0], res[1], res[2], res[3]], [1, 2, 3, undefined]); }); var length; @@ -34,8 +36,10 @@ testWithTypedArrayConstructors(TA => { var ta = new TA([3, 1, 2]); length = 2; - assert.compareArray(ta.toSorted(), [1, 2, 3]); + var res = ta.toSorted() + assert.compareArray([res[0], res[1], res[2], res[3]], [1, 2, 3, undefined]); length = 5; - assert.compareArray(ta.toSorted(), [1, 2, 3]); + res = ta.toSorted() + assert.compareArray([res[0], res[1], res[2], res[3]], [1, 2, 3, undefined]); }); diff --git a/test/built-ins/TypedArray/prototype/toSpliced/length-property-ignored.js b/test/built-ins/TypedArray/prototype/toSpliced/length-property-ignored.js index 14dd9e370c6..0273534e4c5 100644 --- a/test/built-ins/TypedArray/prototype/toSpliced/length-property-ignored.js +++ b/test/built-ins/TypedArray/prototype/toSpliced/length-property-ignored.js @@ -18,11 +18,13 @@ features: [TypedArray, change-array-by-copy] testWithTypedArrayConstructors(TA => { var ta = new TA([3, 1, 2]); Object.defineProperty(ta, "length", { value: 2 }) - assert.compareArray(ta.toSpliced(0, 0), [1, 2, 3]); + var res = ta.toSpliced(0, 0, 5); + assert.compareArray([res[0], res[1], res[2], res[3], res[4]], [5, 3, 1, 2, undefined]) ta = new TA([3, 1, 2]); Object.defineProperty(ta, "length", { value: 5 }); - assert.compareArray(ta.toSpliced(0, 0), [1, 2, 3]); + res = ta.toSpliced(0, 0, 5); + assert.compareArray([res[0], res[1], res[2], res[3], res[4]], [5, 3, 1, 2, undefined]) }); var length; @@ -34,8 +36,10 @@ testWithTypedArrayConstructors(TA => { var ta = new TA([3, 1, 2]); length = 2; - assert.compareArray(ta.toSpliced(0, 0), [1, 2, 3]); + var res = ta.toSpliced(0, 0, 5); + assert.compareArray([res[0], res[1], res[2], res[3], res[4]], [5, 3, 1, 2, undefined]) length = 5; - assert.compareArray(ta.toSpliced(0, 0), [1, 2, 3]); + res = ta.toSpliced(0, 0, 5); + assert.compareArray([res[0], res[1], res[2], res[3], res[4]], [5, 3, 1, 2, undefined]) }); diff --git a/test/built-ins/TypedArray/prototype/with/length-property-ignored.js b/test/built-ins/TypedArray/prototype/with/length-property-ignored.js index 4a0f26e2f0a..4b0188c7d7f 100644 --- a/test/built-ins/TypedArray/prototype/with/length-property-ignored.js +++ b/test/built-ins/TypedArray/prototype/with/length-property-ignored.js @@ -18,11 +18,13 @@ features: [TypedArray, change-array-by-copy] testWithTypedArrayConstructors(TA => { var ta = new TA([3, 1, 2]); Object.defineProperty(ta, "length", { value: 2 }) - assert.compareArray(ta.with(0, 0), [1, 2, 3]); + var res = ta.with(0, 0); + assert.compareArray([res[0], res[1], res[2], res[3]], [0, 1, 2, undefined]); ta = new TA([3, 1, 2]); Object.defineProperty(ta, "length", { value: 5 }); - assert.compareArray(ta.with(0, 0), [1, 2, 3]); + res = ta.with(0, 0); + assert.compareArray([res[0], res[1], res[2], res[3]], [0, 1, 2, undefined]); }); var length; @@ -34,8 +36,10 @@ testWithTypedArrayConstructors(TA => { var ta = new TA([3, 1, 2]); length = 2; - assert.compareArray(ta.with(0, 0), [1, 2, 3]); + var res = ta.with(0, 0); + assert.compareArray([res[0], res[1], res[2], res[3]], [0, 1, 2, undefined]); length = 5; - assert.compareArray(ta.with(0, 0), [1, 2, 3]); + res = ta.with(0, 0); + assert.compareArray([res[0], res[1], res[2], res[3]], [0, 1, 2, undefined]); }); From 447e95fe205fba245fada44e84cf96dac86e994e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Mon, 3 Jan 2022 15:39:32 +0100 Subject: [PATCH 15/86] Fix `Array#toSpliced` `length-clamped-to-2pow53minus1.js --- .../Array/prototype/toSpliced/length-clamped-to-2pow53minus1.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/built-ins/Array/prototype/toSpliced/length-clamped-to-2pow53minus1.js b/test/built-ins/Array/prototype/toSpliced/length-clamped-to-2pow53minus1.js index cb7eb2cf916..7946636cc40 100644 --- a/test/built-ins/Array/prototype/toSpliced/length-clamped-to-2pow53minus1.js +++ b/test/built-ins/Array/prototype/toSpliced/length-clamped-to-2pow53minus1.js @@ -28,7 +28,7 @@ var arrayLike = { length: 2 ** 53 + 20, }; -var result = Array.prototype.toSpliced.call(arrayLike, 0, 2 ** 53 - 4); +var result = Array.prototype.toSpliced.call(arrayLike, 0, 2 ** 53 - 3); assert.sameValue(result.length, 2); assert.deepEqual(result, [2 ** 53 - 3, 2 ** 53 - 2]); From dd3eca44c2afd76cfb48bf0178148e1efbe18c0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Mon, 3 Jan 2022 15:53:08 +0100 Subject: [PATCH 16/86] Fix `with/index-casted-to-number.js` tests --- .../Array/prototype/with/index-casted-to-number.js | 2 +- .../prototype/with/index-casted-to-number.js | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test/built-ins/Array/prototype/with/index-casted-to-number.js b/test/built-ins/Array/prototype/with/index-casted-to-number.js index da21e700474..ee479098606 100644 --- a/test/built-ins/Array/prototype/with/index-casted-to-number.js +++ b/test/built-ins/Array/prototype/with/index-casted-to-number.js @@ -22,6 +22,6 @@ var arr = [0, 4, 16]; assert.deepEqual(arr.with(1.2, 7), [0, 7, 16]); assert.deepEqual(arr.with("1", 3), [0, 3, 16]); -assert.deepEqual(arr.with("-1", 5), [1, 5, 6]); +assert.deepEqual(arr.with("-1", 5), [0, 4, 5]); assert.deepEqual(arr.with(NaN, 2), [2, 4, 16]); assert.deepEqual(arr.with("dog", "cat"), ["cat", 4, 16]); diff --git a/test/built-ins/TypedArray/prototype/with/index-casted-to-number.js b/test/built-ins/TypedArray/prototype/with/index-casted-to-number.js index dbebc5bb9ab..8f2821f2f43 100644 --- a/test/built-ins/TypedArray/prototype/with/index-casted-to-number.js +++ b/test/built-ins/TypedArray/prototype/with/index-casted-to-number.js @@ -15,15 +15,15 @@ info: | 5. Else, let actualIndex be len + relativeIndex. ... features: [TypedArray, change-array-by-copy] -includes: [testTypedArray.js, deepEqual.js] +includes: [testTypedArray.js, compareArray.js] ---*/ testWithTypedArrayConstructors(TA => { var arr = new TA([0, 4, 16]); - assert.deepEqual(arr.with(1.2, 7), [0, 7, 16]); - assert.deepEqual(arr.with("1", 3), [0, 3, 16]); - assert.deepEqual(arr.with("-1", 5), [1, 5, 6]); - assert.deepEqual(arr.with(NaN, 2), [2, 4, 16]); - assert.deepEqual(arr.with("dog", "cat"), ["cat", 4, 16]); + assert.compareArray(arr.with(1.2, 7), [0, 7, 16]); + assert.compareArray(arr.with("1", 3), [0, 3, 16]); + assert.compareArray(arr.with("-1", 5), [0, 4, 5]); + assert.compareArray(arr.with(NaN, 2), [2, 4, 16]); + assert.compareArray(arr.with("dog", 33), [33, 4, 16]); }); From a2557f47f6769037862eadc667e8449e2b855210 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Mon, 3 Jan 2022 16:01:43 +0100 Subject: [PATCH 17/86] `TypedArray#with` casts `-0` index to `0` --- test/built-ins/TypedArray/prototype/with/index-negative.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/test/built-ins/TypedArray/prototype/with/index-negative.js b/test/built-ins/TypedArray/prototype/with/index-negative.js index 9e8ff1d1c68..fbf2599d972 100644 --- a/test/built-ins/TypedArray/prototype/with/index-negative.js +++ b/test/built-ins/TypedArray/prototype/with/index-negative.js @@ -23,9 +23,5 @@ testWithTypedArrayConstructors(TA => { assert.compareArray(arr.with(-1, 4), [0, 1, 4]); assert.compareArray(arr.with(-3, 4), [4, 1, 2]); - - // -0 is disallowed as TypedArray index - assert.throws(RangeError, function() { - arr.with(-0, 7); - }); + assert.compareArray(arr.with(-0, 4), [4, 1, 2]); }); From 0368e0888dd626a7629be498b75f52ae2fd12713 Mon Sep 17 00:00:00 2001 From: Ashley Claymore Date: Sun, 9 Jan 2022 17:49:03 +0000 Subject: [PATCH 18/86] Fix Array#toSpliced length-exceeding-array-length-limit.js --- .../toSpliced/length-exceeding-array-length-limit.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/built-ins/Array/prototype/toSpliced/length-exceeding-array-length-limit.js b/test/built-ins/Array/prototype/toSpliced/length-exceeding-array-length-limit.js index 679413a4608..bca5711b3ad 100644 --- a/test/built-ins/Array/prototype/toSpliced/length-exceeding-array-length-limit.js +++ b/test/built-ins/Array/prototype/toSpliced/length-exceeding-array-length-limit.js @@ -12,7 +12,8 @@ info: | 3. Let len be ? LengthOfArrayLike(O). ... 11. Let newLen be len + insertCount - actualDeleteCount. - 12. Let A be ? ArrayCreate(𝔽(newLen)). + 12. If _newLen_ > 2 ** 53< - 1, throw a *TypeError* exception. + 13. Let A be ? ArrayCreate(𝔽(newLen)). ... ArrayCreate ( length [, proto ] ) @@ -43,3 +44,8 @@ arrayLike.length = 2 ** 32 - 1; assert.throws(RangeError, function() { Array.prototype.toSpliced.call(arrayLike, 0, 0, 1); }); + +arrayLike.length = 2 ** 53 - 1; +assert.throws(TypeError, function() { + Array.prototype.toSpliced.call(arrayLike, 0, 0, 1); +}); From 9e692b8827f947f422f875c5ae2d28b8cdc3b13b Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Wed, 30 Mar 2022 22:44:06 -0700 Subject: [PATCH 19/86] Test additional cases for long arrays in Array#toSpliced --- .../length-exceeding-array-length-limit.js | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/built-ins/Array/prototype/toSpliced/length-exceeding-array-length-limit.js b/test/built-ins/Array/prototype/toSpliced/length-exceeding-array-length-limit.js index bca5711b3ad..c9ec3f66261 100644 --- a/test/built-ins/Array/prototype/toSpliced/length-exceeding-array-length-limit.js +++ b/test/built-ins/Array/prototype/toSpliced/length-exceeding-array-length-limit.js @@ -45,7 +45,27 @@ assert.throws(RangeError, function() { Array.prototype.toSpliced.call(arrayLike, 0, 0, 1); }); +arrayLike.length = 2 ** 32; +assert.throws(RangeError, function() { + Array.prototype.toSpliced.call(arrayLike, 0, 0, 1); +}); + +arrayLike.length = 2 ** 32 + 1; +assert.throws(RangeError, function() { + Array.prototype.toSpliced.call(arrayLike, 0, 0, 1); +}); + arrayLike.length = 2 ** 53 - 1; assert.throws(TypeError, function() { Array.prototype.toSpliced.call(arrayLike, 0, 0, 1); }); + +arrayLike.length = 2 ** 53; +assert.throws(TypeError, function() { + Array.prototype.toSpliced.call(arrayLike, 0, 0, 1); +}); + +arrayLike.length = 2 ** 53 + 1; +assert.throws(TypeError, function() { + Array.prototype.toSpliced.call(arrayLike, 0, 0, 1); +}); From 09b2d048272f77a51c6c6180ebed8298082d8a2f Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Fri, 1 Apr 2022 18:20:30 -0700 Subject: [PATCH 20/86] Add feature flags to TypedArray/prototype/toSpliced/deleteCount-undefined.js --- .../TypedArray/prototype/toSpliced/deleteCount-undefined.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/built-ins/TypedArray/prototype/toSpliced/deleteCount-undefined.js b/test/built-ins/TypedArray/prototype/toSpliced/deleteCount-undefined.js index 569efdab16e..327cc980c51 100644 --- a/test/built-ins/TypedArray/prototype/toSpliced/deleteCount-undefined.js +++ b/test/built-ins/TypedArray/prototype/toSpliced/deleteCount-undefined.js @@ -18,6 +18,7 @@ info: | b. Let actualDeleteCount be len - actualStart. ... includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, change-array-by-copy] ---*/ testWithTypedArrayConstructors((TA) => { From 8446c3dfbfd81c06d5209f01b27d3a2bda38ebe9 Mon Sep 17 00:00:00 2001 From: Ashley Claymore Date: Sat, 2 Apr 2022 12:36:53 +0100 Subject: [PATCH 21/86] Add boundary test for long arrays in Array#toSpliced --- .../toSpliced/length-exceeding-array-length-limit.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/test/built-ins/Array/prototype/toSpliced/length-exceeding-array-length-limit.js b/test/built-ins/Array/prototype/toSpliced/length-exceeding-array-length-limit.js index c9ec3f66261..bab02f0aad3 100644 --- a/test/built-ins/Array/prototype/toSpliced/length-exceeding-array-length-limit.js +++ b/test/built-ins/Array/prototype/toSpliced/length-exceeding-array-length-limit.js @@ -28,10 +28,10 @@ var arrayLike = { throw new Test262Error("Get 0"); }, get "4294967295" () { // 2 ** 32 - 1 - throw new Test262Error("Get 2147483648"); + throw new Test262Error("Get 4294967295"); }, get "4294967296" () { // 2 ** 32 - throw new Test262Error("Get 2147483648"); + throw new Test262Error("Get 4294967296"); }, length: 2 ** 32 }; @@ -55,6 +55,11 @@ assert.throws(RangeError, function() { Array.prototype.toSpliced.call(arrayLike, 0, 0, 1); }); +arrayLike.length = 2 ** 52 - 2; +assert.throws(RangeError, function() { + Array.prototype.toSpliced.call(arrayLike, 0, 0, 1); +}); + arrayLike.length = 2 ** 53 - 1; assert.throws(TypeError, function() { Array.prototype.toSpliced.call(arrayLike, 0, 0, 1); From a1e186c0af71ce1ee1c429c6aa05616af08a015a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Mon, 4 Apr 2022 20:11:04 +0200 Subject: [PATCH 22/86] Fix linting --- test/built-ins/Array/prototype/toReversed/not-a-constructor.js | 2 +- test/built-ins/Array/prototype/toSorted/not-a-constructor.js | 2 +- test/built-ins/Array/prototype/toSpliced/not-a-constructor.js | 2 +- test/built-ins/Array/prototype/with/not-a-constructor.js | 2 +- .../TypedArray/prototype/toReversed/not-a-constructor.js | 2 +- .../TypedArray/prototype/toSorted/not-a-constructor.js | 2 +- .../TypedArray/prototype/toSpliced/not-a-constructor.js | 2 +- test/built-ins/TypedArray/prototype/with/index-negative.js | 2 +- .../prototype/with/index-smaller-than-minus-length.js | 2 +- test/built-ins/TypedArray/prototype/with/not-a-constructor.js | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/test/built-ins/Array/prototype/toReversed/not-a-constructor.js b/test/built-ins/Array/prototype/toReversed/not-a-constructor.js index 898b65486bd..9e4e3f9fdac 100644 --- a/test/built-ins/Array/prototype/toReversed/not-a-constructor.js +++ b/test/built-ins/Array/prototype/toReversed/not-a-constructor.js @@ -18,7 +18,7 @@ info: | 7. If IsConstructor(constructor) is false, throw a TypeError exception. ... includes: [isConstructor.js] -features: [change-array-by-copy] +features: [change-array-by-copy, Reflect.construct] ---*/ assert.sameValue( diff --git a/test/built-ins/Array/prototype/toSorted/not-a-constructor.js b/test/built-ins/Array/prototype/toSorted/not-a-constructor.js index 13f729d417b..96edd3225b6 100644 --- a/test/built-ins/Array/prototype/toSorted/not-a-constructor.js +++ b/test/built-ins/Array/prototype/toSorted/not-a-constructor.js @@ -18,7 +18,7 @@ info: | 7. If IsConstructor(constructor) is false, throw a TypeError exception. ... includes: [isConstructor.js] -features: [change-array-by-copy] +features: [change-array-by-copy, Reflect.construct] ---*/ assert.sameValue( diff --git a/test/built-ins/Array/prototype/toSpliced/not-a-constructor.js b/test/built-ins/Array/prototype/toSpliced/not-a-constructor.js index bcdc2c08304..7abcc9a6860 100644 --- a/test/built-ins/Array/prototype/toSpliced/not-a-constructor.js +++ b/test/built-ins/Array/prototype/toSpliced/not-a-constructor.js @@ -18,7 +18,7 @@ info: | 7. If IsConstructor(constructor) is false, throw a TypeError exception. ... includes: [isConstructor.js] -features: [change-array-by-copy] +features: [change-array-by-copy, Reflect.construct] ---*/ assert.sameValue( diff --git a/test/built-ins/Array/prototype/with/not-a-constructor.js b/test/built-ins/Array/prototype/with/not-a-constructor.js index 8e07261c89b..ff93b77a72b 100644 --- a/test/built-ins/Array/prototype/with/not-a-constructor.js +++ b/test/built-ins/Array/prototype/with/not-a-constructor.js @@ -18,7 +18,7 @@ info: | 7. If IsConstructor(constructor) is false, throw a TypeError exception. ... includes: [isConstructor.js] -features: [change-array-by-copy] +features: [change-array-by-copy, Reflect.construct] ---*/ assert.sameValue( diff --git a/test/built-ins/TypedArray/prototype/toReversed/not-a-constructor.js b/test/built-ins/TypedArray/prototype/toReversed/not-a-constructor.js index 76743ab163e..ff4d69ab395 100644 --- a/test/built-ins/TypedArray/prototype/toReversed/not-a-constructor.js +++ b/test/built-ins/TypedArray/prototype/toReversed/not-a-constructor.js @@ -18,7 +18,7 @@ info: | 7. If IsConstructor(constructor) is false, throw a TypeError exception. ... includes: [isConstructor.js, testTypedArray.js] -features: [TypedArray, change-array-by-copy] +features: [TypedArray, change-array-by-copy, Reflect.construct] ---*/ assert.sameValue( diff --git a/test/built-ins/TypedArray/prototype/toSorted/not-a-constructor.js b/test/built-ins/TypedArray/prototype/toSorted/not-a-constructor.js index 54bd24a1611..2620bbadae4 100644 --- a/test/built-ins/TypedArray/prototype/toSorted/not-a-constructor.js +++ b/test/built-ins/TypedArray/prototype/toSorted/not-a-constructor.js @@ -18,7 +18,7 @@ info: | 7. If IsConstructor(constructor) is false, throw a TypeError exception. ... includes: [isConstructor.js, testTypedArray.js] -features: [TypedArray, change-array-by-copy] +features: [TypedArray, change-array-by-copy, Reflect.construct] ---*/ assert.sameValue( diff --git a/test/built-ins/TypedArray/prototype/toSpliced/not-a-constructor.js b/test/built-ins/TypedArray/prototype/toSpliced/not-a-constructor.js index 1bb781bee05..26f5e311ed8 100644 --- a/test/built-ins/TypedArray/prototype/toSpliced/not-a-constructor.js +++ b/test/built-ins/TypedArray/prototype/toSpliced/not-a-constructor.js @@ -18,7 +18,7 @@ info: | 7. If IsConstructor(constructor) is false, throw a TypeError exception. ... includes: [isConstructor.js, testTypedArray.js] -features: [TypedArray, change-array-by-copy] +features: [TypedArray, change-array-by-copy, Reflect.construct] ---*/ assert.sameValue( diff --git a/test/built-ins/TypedArray/prototype/with/index-negative.js b/test/built-ins/TypedArray/prototype/with/index-negative.js index fbf2599d972..c802b39d267 100644 --- a/test/built-ins/TypedArray/prototype/with/index-negative.js +++ b/test/built-ins/TypedArray/prototype/with/index-negative.js @@ -14,7 +14,7 @@ info: | 4. If index >= 0, let actualIndex be relativeIndex. 5. Else, let actualIndex be len + relativeIndex. ... -features: [change-array-by-copy] +features: [TypedArray, change-array-by-copy] includes: [testTypedArray.js, compareArray.js] ---*/ diff --git a/test/built-ins/TypedArray/prototype/with/index-smaller-than-minus-length.js b/test/built-ins/TypedArray/prototype/with/index-smaller-than-minus-length.js index 0b06e1a0bfd..3ddc4e0412b 100644 --- a/test/built-ins/TypedArray/prototype/with/index-smaller-than-minus-length.js +++ b/test/built-ins/TypedArray/prototype/with/index-smaller-than-minus-length.js @@ -15,7 +15,7 @@ info: | 5. Else, let actualIndex be len + relativeIndex. 6. If actualIndex >= len or actualIndex < 0, throw a *RangeError* exception. ... -features: [change-array-by-copy] +features: [TypedArray, change-array-by-copy] includes: [testTypedArray.js] ---*/ diff --git a/test/built-ins/TypedArray/prototype/with/not-a-constructor.js b/test/built-ins/TypedArray/prototype/with/not-a-constructor.js index 45759912644..8f8cae69b7e 100644 --- a/test/built-ins/TypedArray/prototype/with/not-a-constructor.js +++ b/test/built-ins/TypedArray/prototype/with/not-a-constructor.js @@ -18,7 +18,7 @@ info: | 7. If IsConstructor(constructor) is false, throw a TypeError exception. ... includes: [isConstructor.js, testTypedArray.js] -features: [TypedArray, change-array-by-copy] +features: [TypedArray, change-array-by-copy, Reflect.construct] ---*/ assert.sameValue( From 2d89a31914bd652967380038b535fa43b17144cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Sun, 24 Apr 2022 20:17:57 +0200 Subject: [PATCH 23/86] Jordan's review --- .../prototype/with/index-bigger-or-eq-than-length.js | 2 -- .../with/index-smaller-than-minus-length.js | 2 -- .../with/length-exceeding-array-length-limit.js | 12 ++++++------ 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/test/built-ins/Array/prototype/with/index-bigger-or-eq-than-length.js b/test/built-ins/Array/prototype/with/index-bigger-or-eq-than-length.js index f45ecced1e1..5d0db5e9e74 100644 --- a/test/built-ins/Array/prototype/with/index-bigger-or-eq-than-length.js +++ b/test/built-ins/Array/prototype/with/index-bigger-or-eq-than-length.js @@ -18,8 +18,6 @@ info: | features: [change-array-by-copy] ---*/ -var arr = [0, 1, 2]; - assert.throws(RangeError, function() { [0, 1, 2].with(3, 7); }); diff --git a/test/built-ins/Array/prototype/with/index-smaller-than-minus-length.js b/test/built-ins/Array/prototype/with/index-smaller-than-minus-length.js index 1f2f3a4a01b..679a80e9f5c 100644 --- a/test/built-ins/Array/prototype/with/index-smaller-than-minus-length.js +++ b/test/built-ins/Array/prototype/with/index-smaller-than-minus-length.js @@ -18,8 +18,6 @@ info: | features: [change-array-by-copy] ---*/ -var arr = [0, 1, 2]; - [0, 1, 2].with(-3, 7); assert.throws(RangeError, function() { diff --git a/test/built-ins/Array/prototype/with/length-exceeding-array-length-limit.js b/test/built-ins/Array/prototype/with/length-exceeding-array-length-limit.js index 54d9d12c6fd..2000ec247d5 100644 --- a/test/built-ins/Array/prototype/with/length-exceeding-array-length-limit.js +++ b/test/built-ins/Array/prototype/with/length-exceeding-array-length-limit.js @@ -2,16 +2,16 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-array.prototype.toReversed +esid: sec-array.prototype.with description: > - Array.prototype.toReversed limits the length to 2 ** 32 - 1 + Array.prototype.with limits the length to 2 ** 32 - 1 info: | - Array.prototype.toReversed ( ) + Array.prototype.with ( index, value ) ... 2. Let len be ? LengthOfArrayLike(O). ... - 8. Let A be ? ArrayCreate(𝔽(len)). + 7. Let A be ? ArrayCreate(𝔽(len)). ... ArrayCreate ( length [, proto ] ) @@ -26,10 +26,10 @@ var arrayLike = { throw new Test262Error("Get 0"); }, get "4294967295" () { // 2 ** 32 - 1 - throw new Test262Error("Get 2147483648"); + throw new Test262Error("Get 4294967295"); }, get "4294967296" () { // 2 ** 32 - throw new Test262Error("Get 2147483648"); + throw new Test262Error("Get 4294967296"); }, length: 2 ** 32 }; From e924b8f1e92ac027438a0ad0bde041ed03cbc038 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Sun, 24 Apr 2022 20:18:51 +0200 Subject: [PATCH 24/86] Use `compareArray` instead of `deepEqual` --- .../prototype/toReversed/get-descending-order.js | 4 ++-- .../prototype/toReversed/holes-not-preserved.js | 4 ++-- .../Array/prototype/toReversed/immutable.js | 4 ++-- .../prototype/toReversed/length-casted-to-zero.js | 8 ++++---- .../toReversed/length-decreased-while-iterating.js | 4 ++-- .../toReversed/length-increased-while-iterating.js | 4 ++-- .../prototype/toReversed/length-integer-string.js | 6 +++--- .../Array/prototype/toReversed/this-value-boolean.js | 6 +++--- .../prototype/toReversed/zero-or-one-element.js | 6 +++--- .../toSorted/comparefn-called-after-get-elements.js | 4 ++-- .../Array/prototype/toSorted/holes-not-preserved.js | 4 ++-- test/built-ins/Array/prototype/toSorted/immutable.js | 4 ++-- .../prototype/toSorted/length-casted-to-zero.js | 8 ++++---- .../toSorted/length-decreased-while-iterating.js | 4 ++-- .../toSorted/length-increased-while-iterating.js | 4 ++-- .../prototype/toSorted/length-integer-string.js | 6 +++--- .../Array/prototype/toSorted/this-value-boolean.js | 6 +++--- .../Array/prototype/toSorted/zero-or-one-element.js | 6 +++--- ...Count-clamped-between-zero-and-remaining-count.js | 10 +++++----- .../Array/prototype/toSpliced/deleteCount-missing.js | 4 ++-- .../prototype/toSpliced/deleteCount-undefined.js | 4 ++-- .../toSpliced/discarded-element-not-read.js | 4 ++-- .../prototype/toSpliced/elements-read-in-order.js | 6 +++--- .../Array/prototype/toSpliced/frozen-this-value.js | 4 ++-- .../Array/prototype/toSpliced/holes-not-preserved.js | 6 +++--- .../built-ins/Array/prototype/toSpliced/immutable.js | 4 ++-- .../prototype/toSpliced/length-casted-to-zero.js | 8 ++++---- .../toSpliced/length-clamped-to-2pow53minus1.js | 4 ++-- .../toSpliced/length-decreased-while-iterating.js | 4 ++-- .../toSpliced/length-increased-while-iterating.js | 4 ++-- .../prototype/toSpliced/length-integer-string.js | 6 +++--- .../toSpliced/start-and-deleteCount-missing.js | 4 ++-- .../toSpliced/start-and-deleteCount-undefineds.js | 4 ++-- .../prototype/toSpliced/start-bigger-than-length.js | 4 ++-- .../toSpliced/start-neg-infinity-is-zero.js | 4 ++-- .../start-neg-less-than-minus-length-is-zero.js | 4 ++-- .../toSpliced/start-neg-subtracted-from-length.js | 4 ++-- .../start-undefined-and-deleteCount-missing.js | 4 ++-- .../Array/prototype/toSpliced/this-value-boolean.js | 6 +++--- .../Array/prototype/toSpliced/unmodified.js | 4 ++-- .../Array/prototype/with/frozen-this-value.js | 6 +++--- .../Array/prototype/with/holes-not-preserved.js | 4 ++-- test/built-ins/Array/prototype/with/immutable.js | 4 ++-- .../Array/prototype/with/index-casted-to-number.js | 12 ++++++------ .../built-ins/Array/prototype/with/index-negative.js | 8 ++++---- .../with/length-decreased-while-iterating.js | 6 +++--- .../with/length-increased-while-iterating.js | 4 ++-- .../Array/prototype/with/length-integer-string.js | 6 +++--- .../Array/prototype/with/no-get-replaced-index.js | 4 ++-- .../Array/prototype/with/this-value-boolean.js | 6 +++--- 50 files changed, 129 insertions(+), 129 deletions(-) diff --git a/test/built-ins/Array/prototype/toReversed/get-descending-order.js b/test/built-ins/Array/prototype/toReversed/get-descending-order.js index cf0ef324ed2..702418d013a 100644 --- a/test/built-ins/Array/prototype/toReversed/get-descending-order.js +++ b/test/built-ins/Array/prototype/toReversed/get-descending-order.js @@ -17,7 +17,7 @@ info: | c. Let fromValue be ? Get(O, from). ... features: [change-array-by-copy] -includes: [deepEqual.js] +includes: [compareArray.js] ---*/ var order = []; @@ -36,4 +36,4 @@ var arrayLike = { Array.prototype.toReversed.call(arrayLike); -assert.deepEqual(order, [2, 1, 0]); +assert.compareArray(order, [2, 1, 0]); diff --git a/test/built-ins/Array/prototype/toReversed/holes-not-preserved.js b/test/built-ins/Array/prototype/toReversed/holes-not-preserved.js index 800178526d2..0be39fb25b6 100644 --- a/test/built-ins/Array/prototype/toReversed/holes-not-preserved.js +++ b/test/built-ins/Array/prototype/toReversed/holes-not-preserved.js @@ -18,12 +18,12 @@ info: | d. Perform ? CreateDataPropertyOrThrow(A, Pk, fromValue). ... features: [change-array-by-copy] -includes: [deepEqual.js] +includes: [compareArray.js] ---*/ var arr = [0, /* hole */, 2, /* hole */, 4]; Array.prototype[3] = 3; var reversed = arr.toReversed(); -assert.deepEqual(reversed, [4, 3, 2, undefined, 0]); +assert.compareArray(reversed, [4, 3, 2, undefined, 0]); assert(reversed.hasOwnProperty(3)); diff --git a/test/built-ins/Array/prototype/toReversed/immutable.js b/test/built-ins/Array/prototype/toReversed/immutable.js index 0c21742f31b..f25ef8932f9 100644 --- a/test/built-ins/Array/prototype/toReversed/immutable.js +++ b/test/built-ins/Array/prototype/toReversed/immutable.js @@ -6,10 +6,10 @@ esid: sec-array.prototype.toReversed description: > Array.prototype.toReversed does not mutate its this value features: [change-array-by-copy] -includes: [deepEqual.js] +includes: [compareArray.js] ---*/ var arr = [0, 1, 2]; arr.toReversed(); -assert.deepEqual(arr, [0, 1, 2]); +assert.compareArray(arr, [0, 1, 2]); diff --git a/test/built-ins/Array/prototype/toReversed/length-casted-to-zero.js b/test/built-ins/Array/prototype/toReversed/length-casted-to-zero.js index 0ae30c5754c..004542c2d16 100644 --- a/test/built-ins/Array/prototype/toReversed/length-casted-to-zero.js +++ b/test/built-ins/Array/prototype/toReversed/length-casted-to-zero.js @@ -12,9 +12,9 @@ info: | 2. Let len be ? LengthOfArrayLike(O). ... features: [change-array-by-copy] -includes: [deepEqual.js] +includes: [compareArray.js] ---*/ -assert.deepEqual(Array.prototype.toReversed.call({ length: -2 }), []); -assert.deepEqual(Array.prototype.toReversed.call({ length: "dog" }), []); -assert.deepEqual(Array.prototype.toReversed.call({ length: NaN }), []); +assert.compareArray(Array.prototype.toReversed.call({ length: -2 }), []); +assert.compareArray(Array.prototype.toReversed.call({ length: "dog" }), []); +assert.compareArray(Array.prototype.toReversed.call({ length: NaN }), []); diff --git a/test/built-ins/Array/prototype/toReversed/length-decreased-while-iterating.js b/test/built-ins/Array/prototype/toReversed/length-decreased-while-iterating.js index 0d85857a1cc..58d5dbd0500 100644 --- a/test/built-ins/Array/prototype/toReversed/length-decreased-while-iterating.js +++ b/test/built-ins/Array/prototype/toReversed/length-decreased-while-iterating.js @@ -16,7 +16,7 @@ info: | c. Let fromValue be ? Get(O, from). ... features: [change-array-by-copy] -includes: [deepEqual.js] +includes: [compareArray.js] ---*/ var arr = [0, 1, 2, 3, 4]; @@ -29,4 +29,4 @@ Object.defineProperty(arr, "3", { } }); -assert.deepEqual(arr.toReversed(), [4, 3, undefined, 5, 0]); +assert.compareArray(arr.toReversed(), [4, 3, undefined, 5, 0]); diff --git a/test/built-ins/Array/prototype/toReversed/length-increased-while-iterating.js b/test/built-ins/Array/prototype/toReversed/length-increased-while-iterating.js index 756c0adfb38..f0e4ef04c7f 100644 --- a/test/built-ins/Array/prototype/toReversed/length-increased-while-iterating.js +++ b/test/built-ins/Array/prototype/toReversed/length-increased-while-iterating.js @@ -16,7 +16,7 @@ info: | c. Let fromValue be ? Get(O, from). ... features: [change-array-by-copy] -includes: [deepEqual.js] +includes: [compareArray.js] ---*/ var arr = [0, 1, 2]; @@ -27,4 +27,4 @@ Object.defineProperty(arr, "0", { } }); -assert.deepEqual(arr.toReversed(), [2, 1, 0]); +assert.compareArray(arr.toReversed(), [2, 1, 0]); diff --git a/test/built-ins/Array/prototype/toReversed/length-integer-string.js b/test/built-ins/Array/prototype/toReversed/length-integer-string.js index d1a46380811..957bc44e029 100644 --- a/test/built-ins/Array/prototype/toReversed/length-integer-string.js +++ b/test/built-ins/Array/prototype/toReversed/length-integer-string.js @@ -12,10 +12,10 @@ info: | 2. Let len be ? LengthOfArrayLike(O). ... features: [change-array-by-copy] -includes: [deepEqual.js] +includes: [compareArray.js] ---*/ -assert.deepEqual(Array.prototype.toReversed.call({ length: "2", 0: 1, 1: 2, 2: 3 }), [2, 1]); +assert.compareArray(Array.prototype.toReversed.call({ length: "2", 0: 1, 1: 2, 2: 3 }), [2, 1]); var arrayLike = { length: { @@ -26,4 +26,4 @@ var arrayLike = { 2: 3, }; -assert.deepEqual(Array.prototype.toReversed.call(arrayLike), [2, 1]); +assert.compareArray(Array.prototype.toReversed.call(arrayLike), [2, 1]); diff --git a/test/built-ins/Array/prototype/toReversed/this-value-boolean.js b/test/built-ins/Array/prototype/toReversed/this-value-boolean.js index fc4ff780dcb..ccce04a6550 100644 --- a/test/built-ins/Array/prototype/toReversed/this-value-boolean.js +++ b/test/built-ins/Array/prototype/toReversed/this-value-boolean.js @@ -12,8 +12,8 @@ info: | 2. Let len be ? LengthOfArrayLike(O). ... features: [change-array-by-copy] -includes: [deepEqual.js] +includes: [compareArray.js] ---*/ -assert.deepEqual(Array.prototype.toReversed.call(true), []); -assert.deepEqual(Array.prototype.toReversed.call(false), []); +assert.compareArray(Array.prototype.toReversed.call(true), []); +assert.compareArray(Array.prototype.toReversed.call(false), []); diff --git a/test/built-ins/Array/prototype/toReversed/zero-or-one-element.js b/test/built-ins/Array/prototype/toReversed/zero-or-one-element.js index 1cd618f6525..f09c922110c 100644 --- a/test/built-ins/Array/prototype/toReversed/zero-or-one-element.js +++ b/test/built-ins/Array/prototype/toReversed/zero-or-one-element.js @@ -6,15 +6,15 @@ esid: sec-array.prototype.toReversed description: > Array.prototype.toReversed returns a new array even if it has zero or one elements features: [change-array-by-copy] -includes: [deepEqual.js] +includes: [compareArray.js] ---*/ var zero = []; var zeroReversed = zero.toReversed(); assert.notSameValue(zero, zeroReversed); -assert.deepEqual(zero, zeroReversed); +assert.compareArray(zero, zeroReversed); var one = [1]; var oneReversed = one.toReversed(); assert.notSameValue(one, oneReversed); -assert.deepEqual(one, oneReversed); +assert.compareArray(one, oneReversed); diff --git a/test/built-ins/Array/prototype/toSorted/comparefn-called-after-get-elements.js b/test/built-ins/Array/prototype/toSorted/comparefn-called-after-get-elements.js index a1e69f3f9c2..ae0273b1c3b 100644 --- a/test/built-ins/Array/prototype/toSorted/comparefn-called-after-get-elements.js +++ b/test/built-ins/Array/prototype/toSorted/comparefn-called-after-get-elements.js @@ -20,7 +20,7 @@ info: | SortCompare or steps in this algorithm and return that completion. ... features: [change-array-by-copy] -includes: [deepEqual.js] +includes: [compareArray.js] ---*/ var getCalls = []; @@ -41,4 +41,4 @@ assert.throws(StopToSorted, function() { }); }); -assert.deepEqual(getCalls, [0, 1, 2]); +assert.compareArray(getCalls, [0, 1, 2]); diff --git a/test/built-ins/Array/prototype/toSorted/holes-not-preserved.js b/test/built-ins/Array/prototype/toSorted/holes-not-preserved.js index 28a49debdb6..c13559cadfb 100644 --- a/test/built-ins/Array/prototype/toSorted/holes-not-preserved.js +++ b/test/built-ins/Array/prototype/toSorted/holes-not-preserved.js @@ -19,12 +19,12 @@ info: | d. Set k to k + 1. ... features: [change-array-by-copy] -includes: [deepEqual.js] +includes: [compareArray.js] ---*/ var arr = [3, /* hole */, 4, /* hole */, 1]; Array.prototype[3] = 2; var sorted = arr.toSorted(); -assert.deepEqual(sorted, [1, 2, 3, 4, undefined]); +assert.compareArray(sorted, [1, 2, 3, 4, undefined]); assert(sorted.hasOwnProperty(4)); diff --git a/test/built-ins/Array/prototype/toSorted/immutable.js b/test/built-ins/Array/prototype/toSorted/immutable.js index 6c6e4e83daa..6d4e922d19a 100644 --- a/test/built-ins/Array/prototype/toSorted/immutable.js +++ b/test/built-ins/Array/prototype/toSorted/immutable.js @@ -6,10 +6,10 @@ esid: sec-array.prototype.toSorted description: > Array.prototype.toSorted does not mutate its this value features: [change-array-by-copy] -includes: [deepEqual.js] +includes: [compareArray.js] ---*/ var arr = [2, 0, 1]; arr.toSorted(); -assert.deepEqual(arr, [2, 0, 1]); +assert.compareArray(arr, [2, 0, 1]); diff --git a/test/built-ins/Array/prototype/toSorted/length-casted-to-zero.js b/test/built-ins/Array/prototype/toSorted/length-casted-to-zero.js index 3b512799d84..7804f8aca4f 100644 --- a/test/built-ins/Array/prototype/toSorted/length-casted-to-zero.js +++ b/test/built-ins/Array/prototype/toSorted/length-casted-to-zero.js @@ -12,9 +12,9 @@ info: | 3. Let len be ? LengthOfArrayLike(O). ... features: [change-array-by-copy] -includes: [deepEqual.js] +includes: [compareArray.js] ---*/ -assert.deepEqual(Array.prototype.toSorted.call({ length: -2 }), []); -assert.deepEqual(Array.prototype.toSorted.call({ length: "dog" }), []); -assert.deepEqual(Array.prototype.toSorted.call({ length: NaN }), []); +assert.compareArray(Array.prototype.toSorted.call({ length: -2 }), []); +assert.compareArray(Array.prototype.toSorted.call({ length: "dog" }), []); +assert.compareArray(Array.prototype.toSorted.call({ length: NaN }), []); diff --git a/test/built-ins/Array/prototype/toSorted/length-decreased-while-iterating.js b/test/built-ins/Array/prototype/toSorted/length-decreased-while-iterating.js index 42243bb6cf4..47b46de02ce 100644 --- a/test/built-ins/Array/prototype/toSorted/length-decreased-while-iterating.js +++ b/test/built-ins/Array/prototype/toSorted/length-decreased-while-iterating.js @@ -17,7 +17,7 @@ info: | b. Let kValue be ? Get(O, Pk). ... features: [change-array-by-copy] -includes: [deepEqual.js] +includes: [compareArray.js] ---*/ var arr = [5, 1, 4, 6, 3]; @@ -30,4 +30,4 @@ Object.defineProperty(arr, "2", { } }); -assert.deepEqual(arr.toSorted(), [1, 2, 4, 5, undefined]); +assert.compareArray(arr.toSorted(), [1, 2, 4, 5, undefined]); diff --git a/test/built-ins/Array/prototype/toSorted/length-increased-while-iterating.js b/test/built-ins/Array/prototype/toSorted/length-increased-while-iterating.js index a27a744ad95..17b2eb107b0 100644 --- a/test/built-ins/Array/prototype/toSorted/length-increased-while-iterating.js +++ b/test/built-ins/Array/prototype/toSorted/length-increased-while-iterating.js @@ -17,7 +17,7 @@ info: | b. Let kValue be ? Get(O, Pk). ... features: [change-array-by-copy] -includes: [deepEqual.js] +includes: [compareArray.js] ---*/ var arr = [5, 0, 3]; @@ -28,4 +28,4 @@ Object.defineProperty(arr, "0", { } }); -assert.deepEqual(arr.toSorted(), [0, 3, 5]); +assert.compareArray(arr.toSorted(), [0, 3, 5]); diff --git a/test/built-ins/Array/prototype/toSorted/length-integer-string.js b/test/built-ins/Array/prototype/toSorted/length-integer-string.js index 61d93563a16..0684b46ed29 100644 --- a/test/built-ins/Array/prototype/toSorted/length-integer-string.js +++ b/test/built-ins/Array/prototype/toSorted/length-integer-string.js @@ -12,10 +12,10 @@ info: | 3. Let len be ? LengthOfArrayLike(O). ... features: [change-array-by-copy] -includes: [deepEqual.js] +includes: [compareArray.js] ---*/ -assert.deepEqual(Array.prototype.toSorted.call({ length: "2", 0: 4, 1: 0, 2: 1 }), [0, 4]); +assert.compareArray(Array.prototype.toSorted.call({ length: "2", 0: 4, 1: 0, 2: 1 }), [0, 4]); var arrayLike = { length: { @@ -26,4 +26,4 @@ var arrayLike = { 2: 1, }; -assert.deepEqual(Array.prototype.toSorted.call(arrayLike), [0, 4]); +assert.compareArray(Array.prototype.toSorted.call(arrayLike), [0, 4]); diff --git a/test/built-ins/Array/prototype/toSorted/this-value-boolean.js b/test/built-ins/Array/prototype/toSorted/this-value-boolean.js index b03d29d2056..ec163165116 100644 --- a/test/built-ins/Array/prototype/toSorted/this-value-boolean.js +++ b/test/built-ins/Array/prototype/toSorted/this-value-boolean.js @@ -12,8 +12,8 @@ info: | 2. Let len be ? LengthOfArrayLike(O). ... features: [change-array-by-copy] -includes: [deepEqual.js] +includes: [compareArray.js] ---*/ -assert.deepEqual(Array.prototype.toSorted.call(true), []); -assert.deepEqual(Array.prototype.toSorted.call(false), []); +assert.compareArray(Array.prototype.toSorted.call(true), []); +assert.compareArray(Array.prototype.toSorted.call(false), []); diff --git a/test/built-ins/Array/prototype/toSorted/zero-or-one-element.js b/test/built-ins/Array/prototype/toSorted/zero-or-one-element.js index 604bb50bef0..252cf4f17e9 100644 --- a/test/built-ins/Array/prototype/toSorted/zero-or-one-element.js +++ b/test/built-ins/Array/prototype/toSorted/zero-or-one-element.js @@ -6,15 +6,15 @@ esid: sec-array.prototype.toSorted description: > Array.prototype.toSorted returns a new array even if it has zero or one elements features: [change-array-by-copy] -includes: [deepEqual.js] +includes: [compareArray.js] ---*/ var zero = []; var zeroReversed = zero.toSorted(); assert.notSameValue(zero, zeroReversed); -assert.deepEqual(zero, zeroReversed); +assert.compareArray(zero, zeroReversed); var one = [1]; var oneReversed = one.toSorted(); assert.notSameValue(one, oneReversed); -assert.deepEqual(one, oneReversed); +assert.compareArray(one, oneReversed); diff --git a/test/built-ins/Array/prototype/toSpliced/deleteCount-clamped-between-zero-and-remaining-count.js b/test/built-ins/Array/prototype/toSpliced/deleteCount-clamped-between-zero-and-remaining-count.js index 2af91399a01..7b6bdebcff4 100644 --- a/test/built-ins/Array/prototype/toSpliced/deleteCount-clamped-between-zero-and-remaining-count.js +++ b/test/built-ins/Array/prototype/toSpliced/deleteCount-clamped-between-zero-and-remaining-count.js @@ -13,25 +13,25 @@ info: | b. Let actualDeleteCount be the result of clamping dc between 0 and len - actualStart. ... features: [change-array-by-copy] -includes: [deepEqual.js] +includes: [compareArray.js] ---*/ -assert.deepEqual( +assert.compareArray( [0, 1, 2, 3, 4, 5].toSpliced(2, -1), [0, 1, 2, 3, 4, 5] ); -assert.deepEqual( +assert.compareArray( [0, 1, 2, 3, 4, 5].toSpliced(-4, -1), [0, 1, 2, 3, 4, 5] ); -assert.deepEqual( +assert.compareArray( [0, 1, 2, 3, 4, 5].toSpliced(2, 6), [0, 1] ); -assert.deepEqual( +assert.compareArray( [0, 1, 2, 3, 4, 5].toSpliced(-4, 6), [0, 1] ); diff --git a/test/built-ins/Array/prototype/toSpliced/deleteCount-missing.js b/test/built-ins/Array/prototype/toSpliced/deleteCount-missing.js index aef5b36ede8..6472d7ea56b 100644 --- a/test/built-ins/Array/prototype/toSpliced/deleteCount-missing.js +++ b/test/built-ins/Array/prototype/toSpliced/deleteCount-missing.js @@ -12,9 +12,9 @@ info: | a. Let actualDeleteCount be len - actualStart. ... features: [change-array-by-copy] -includes: [deepEqual.js] +includes: [compareArray.js] ---*/ var result = ["first", "second", "third"].toSpliced(1); -assert.deepEqual(result, ["first"]); +assert.compareArray(result, ["first"]); diff --git a/test/built-ins/Array/prototype/toSpliced/deleteCount-undefined.js b/test/built-ins/Array/prototype/toSpliced/deleteCount-undefined.js index 19ae816ef22..9b39aeb6c98 100644 --- a/test/built-ins/Array/prototype/toSpliced/deleteCount-undefined.js +++ b/test/built-ins/Array/prototype/toSpliced/deleteCount-undefined.js @@ -18,9 +18,9 @@ info: | a. Let actualDeleteCount be len - actualStart. ... features: [change-array-by-copy] -includes: [deepEqual.js] +includes: [compareArray.js] ---*/ var result = ["first", "second", "third"].toSpliced(1, undefined); -assert.deepEqual(result, ["first", "second", "third"]); +assert.compareArray(result, ["first", "second", "third"]); diff --git a/test/built-ins/Array/prototype/toSpliced/discarded-element-not-read.js b/test/built-ins/Array/prototype/toSpliced/discarded-element-not-read.js index 8b28f5b03e0..c748ef0b966 100644 --- a/test/built-ins/Array/prototype/toSpliced/discarded-element-not-read.js +++ b/test/built-ins/Array/prototype/toSpliced/discarded-element-not-read.js @@ -18,7 +18,7 @@ info: | a. Let actualDeleteCount be len - actualStart. ... features: [change-array-by-copy] -includes: [deepEqual.js] +includes: [compareArray.js] ---*/ var arrayLike = { @@ -30,4 +30,4 @@ var arrayLike = { }; var result = Array.prototype.toSpliced.call(arrayLike, 2, 1); -assert.deepEqual(result, ["a", "b", "c"]); +assert.compareArray(result, ["a", "b", "c"]); diff --git a/test/built-ins/Array/prototype/toSpliced/elements-read-in-order.js b/test/built-ins/Array/prototype/toSpliced/elements-read-in-order.js index f8704de830d..cfc15f63103 100644 --- a/test/built-ins/Array/prototype/toSpliced/elements-read-in-order.js +++ b/test/built-ins/Array/prototype/toSpliced/elements-read-in-order.js @@ -18,7 +18,7 @@ info: | a. Let actualDeleteCount be len - actualStart. ... features: [change-array-by-copy] -includes: [deepEqual.js] +includes: [compareArray.js] ---*/ var order = []; @@ -32,6 +32,6 @@ var arrayLike = { }; var result = Array.prototype.toSpliced.call(arrayLike, 2, 1); -assert.deepEqual(result, ["a", "b", "c"]); +assert.compareArray(result, ["a", "b", "c"]); -assert.deepEqual(order, [0, 1, 3]); +assert.compareArray(order, [0, 1, 3]); diff --git a/test/built-ins/Array/prototype/toSpliced/frozen-this-value.js b/test/built-ins/Array/prototype/toSpliced/frozen-this-value.js index 674e92ffb5e..8dec633eda2 100644 --- a/test/built-ins/Array/prototype/toSpliced/frozen-this-value.js +++ b/test/built-ins/Array/prototype/toSpliced/frozen-this-value.js @@ -6,7 +6,7 @@ esid: sec-array.prototype.toSpliced description: > Array.prototype.toSpliced works on frozen objects features: [change-array-by-copy] -includes: [deepEqual.js] +includes: [compareArray.js] ---*/ var arr = Object.freeze([2, 0, 1]); @@ -14,4 +14,4 @@ arr.toSpliced(); var arrayLike = Object.freeze({ length: 3, 0: 0, 1: 1, 2: 2 }); -assert.deepEqual(Array.prototype.toSpliced.call(arrayLike, 1, 1, 4, 5), [0, 4, 5, 2]); +assert.compareArray(Array.prototype.toSpliced.call(arrayLike, 1, 1, 4, 5), [0, 4, 5, 2]); diff --git a/test/built-ins/Array/prototype/toSpliced/holes-not-preserved.js b/test/built-ins/Array/prototype/toSpliced/holes-not-preserved.js index 4c6279e41de..2d10ff41678 100644 --- a/test/built-ins/Array/prototype/toSpliced/holes-not-preserved.js +++ b/test/built-ins/Array/prototype/toSpliced/holes-not-preserved.js @@ -23,7 +23,7 @@ info: | d. Perform ? CreateDataPropertyOrThrow(A, Pk, fromValue). e. Set k to k + 1. ... -includes: [deepEqual.js] +includes: [compareArray.js] features: [change-array-by-copy] ---*/ @@ -31,9 +31,9 @@ var arr = [0, /* hole */, 2, /* hole */, 4]; Array.prototype[3] = 3; var spliced = arr.toSpliced(0, 0); -assert.deepEqual(spliced, [0, undefined, 2, 3, 4]); +assert.compareArray(spliced, [0, undefined, 2, 3, 4]); assert(spliced.hasOwnProperty(1)); assert(spliced.hasOwnProperty(3)); spliced = arr.toSpliced(0, 0, -1); -assert.deepEqual(spliced, [-1, 0, undefined, 2, 3, 4]); +assert.compareArray(spliced, [-1, 0, undefined, 2, 3, 4]); diff --git a/test/built-ins/Array/prototype/toSpliced/immutable.js b/test/built-ins/Array/prototype/toSpliced/immutable.js index 9c091c0916c..26b2251dce2 100644 --- a/test/built-ins/Array/prototype/toSpliced/immutable.js +++ b/test/built-ins/Array/prototype/toSpliced/immutable.js @@ -6,10 +6,10 @@ esid: sec-array.prototype.toSpliced description: > Array.prototype.toSpliced does not mutate its this value features: [change-array-by-copy] -includes: [deepEqual.js] +includes: [compareArray.js] ---*/ var arr = [2, 0, 1]; arr.toSpliced(0, 0, -1); -assert.deepEqual(arr, [2, 0, 1]); +assert.compareArray(arr, [2, 0, 1]); diff --git a/test/built-ins/Array/prototype/toSpliced/length-casted-to-zero.js b/test/built-ins/Array/prototype/toSpliced/length-casted-to-zero.js index 8b71f5dbb75..0b694186d44 100644 --- a/test/built-ins/Array/prototype/toSpliced/length-casted-to-zero.js +++ b/test/built-ins/Array/prototype/toSpliced/length-casted-to-zero.js @@ -12,9 +12,9 @@ info: | 2. Let len be ? LengthOfArrayLike(O). ... features: [change-array-by-copy] -includes: [deepEqual.js] +includes: [compareArray.js] ---*/ -assert.deepEqual(Array.prototype.toSpliced.call({ length: -2 }, 0, 0, 2, 3), [2, 3]); -assert.deepEqual(Array.prototype.toSpliced.call({ length: "dog" }, 0, 0, 2, 3), [2, 3]); -assert.deepEqual(Array.prototype.toSpliced.call({ length: NaN }, 0, 0, 2, 3), [2, 3]); +assert.compareArray(Array.prototype.toSpliced.call({ length: -2 }, 0, 0, 2, 3), [2, 3]); +assert.compareArray(Array.prototype.toSpliced.call({ length: "dog" }, 0, 0, 2, 3), [2, 3]); +assert.compareArray(Array.prototype.toSpliced.call({ length: NaN }, 0, 0, 2, 3), [2, 3]); diff --git a/test/built-ins/Array/prototype/toSpliced/length-clamped-to-2pow53minus1.js b/test/built-ins/Array/prototype/toSpliced/length-clamped-to-2pow53minus1.js index 7946636cc40..f9d6456839a 100644 --- a/test/built-ins/Array/prototype/toSpliced/length-clamped-to-2pow53minus1.js +++ b/test/built-ins/Array/prototype/toSpliced/length-clamped-to-2pow53minus1.js @@ -16,7 +16,7 @@ info: | 2. If len ≀ 0, return +0𝔽. 3. Return 𝔽(min(len, 2^53 - 1)) features: [change-array-by-copy] -includes: [deepEqual.js] +includes: [compareArray.js] ---*/ var arrayLike = { @@ -31,4 +31,4 @@ var arrayLike = { var result = Array.prototype.toSpliced.call(arrayLike, 0, 2 ** 53 - 3); assert.sameValue(result.length, 2); -assert.deepEqual(result, [2 ** 53 - 3, 2 ** 53 - 2]); +assert.compareArray(result, [2 ** 53 - 3, 2 ** 53 - 2]); diff --git a/test/built-ins/Array/prototype/toSpliced/length-decreased-while-iterating.js b/test/built-ins/Array/prototype/toSpliced/length-decreased-while-iterating.js index 07ff1ce3bca..5826e7652d8 100644 --- a/test/built-ins/Array/prototype/toSpliced/length-decreased-while-iterating.js +++ b/test/built-ins/Array/prototype/toSpliced/length-decreased-while-iterating.js @@ -28,7 +28,7 @@ info: | e. Set k to k + 1. ... features: [change-array-by-copy] -includes: [deepEqual.js] +includes: [compareArray.js] ---*/ var arr = [0, 1, 2, 3, 4, 5]; @@ -41,4 +41,4 @@ Object.defineProperty(arr, "2", { } }); -assert.deepEqual(arr.toSpliced(0, 0), [0, 1, 2, 6, undefined, undefined]); +assert.compareArray(arr.toSpliced(0, 0), [0, 1, 2, 6, undefined, undefined]); diff --git a/test/built-ins/Array/prototype/toSpliced/length-increased-while-iterating.js b/test/built-ins/Array/prototype/toSpliced/length-increased-while-iterating.js index 03fcf19398b..5f2a5e5bc1a 100644 --- a/test/built-ins/Array/prototype/toSpliced/length-increased-while-iterating.js +++ b/test/built-ins/Array/prototype/toSpliced/length-increased-while-iterating.js @@ -17,7 +17,7 @@ info: | b. Let kValue be ? Get(O, Pk). ... features: [change-array-by-copy] -includes: [deepEqual.js] +includes: [compareArray.js] ---*/ var arr = [0, 1, 2]; @@ -34,4 +34,4 @@ Object.defineProperty(arr, "2", { } }); -assert.deepEqual(arr.toSpliced(1, 0, 0.5), [0, 0.5, 1, 2]); +assert.compareArray(arr.toSpliced(1, 0, 0.5), [0, 0.5, 1, 2]); diff --git a/test/built-ins/Array/prototype/toSpliced/length-integer-string.js b/test/built-ins/Array/prototype/toSpliced/length-integer-string.js index 57d6e7aeca6..8058060f3d2 100644 --- a/test/built-ins/Array/prototype/toSpliced/length-integer-string.js +++ b/test/built-ins/Array/prototype/toSpliced/length-integer-string.js @@ -12,10 +12,10 @@ info: | 2. Let len be ? LengthOfArrayLike(O). ... features: [change-array-by-copy] -includes: [deepEqual.js] +includes: [compareArray.js] ---*/ -assert.deepEqual(Array.prototype.toSpliced.call({ length: "2", 0: 0, 1: 1, 2: 2 }, 0, 0), [0, 1]); +assert.compareArray(Array.prototype.toSpliced.call({ length: "2", 0: 0, 1: 1, 2: 2 }, 0, 0), [0, 1]); var arrayLike = { length: { @@ -26,4 +26,4 @@ var arrayLike = { 2: 2, }; -assert.deepEqual(Array.prototype.toSpliced.call(arrayLike, 0, 0), [0, 1]); +assert.compareArray(Array.prototype.toSpliced.call(arrayLike, 0, 0), [0, 1]); diff --git a/test/built-ins/Array/prototype/toSpliced/start-and-deleteCount-missing.js b/test/built-ins/Array/prototype/toSpliced/start-and-deleteCount-missing.js index 2cb4f9c9eb5..e39ef74e244 100644 --- a/test/built-ins/Array/prototype/toSpliced/start-and-deleteCount-missing.js +++ b/test/built-ins/Array/prototype/toSpliced/start-and-deleteCount-missing.js @@ -16,9 +16,9 @@ info: | a. Let actualDeleteCount be 0. ... features: [change-array-by-copy] -includes: [deepEqual.js] +includes: [compareArray.js] ---*/ var result = ["first", "second", "third"].toSpliced(); -assert.deepEqual(result, ["first", "second", "third"]); +assert.compareArray(result, ["first", "second", "third"]); diff --git a/test/built-ins/Array/prototype/toSpliced/start-and-deleteCount-undefineds.js b/test/built-ins/Array/prototype/toSpliced/start-and-deleteCount-undefineds.js index e6aebd9900d..a072679ab88 100644 --- a/test/built-ins/Array/prototype/toSpliced/start-and-deleteCount-undefineds.js +++ b/test/built-ins/Array/prototype/toSpliced/start-and-deleteCount-undefineds.js @@ -18,9 +18,9 @@ info: | a. Let actualDeleteCount be len - actualStart. ... features: [change-array-by-copy] -includes: [deepEqual.js] +includes: [compareArray.js] ---*/ var result = ["first", "second", "third"].toSpliced(undefined, undefined); -assert.deepEqual(result, ["first", "second", "third"]); +assert.compareArray(result, ["first", "second", "third"]); diff --git a/test/built-ins/Array/prototype/toSpliced/start-bigger-than-length.js b/test/built-ins/Array/prototype/toSpliced/start-bigger-than-length.js index b1e31a32344..b9a5c5acf4b 100644 --- a/test/built-ins/Array/prototype/toSpliced/start-bigger-than-length.js +++ b/test/built-ins/Array/prototype/toSpliced/start-bigger-than-length.js @@ -16,8 +16,8 @@ info: | 6. Else, let actualStart be min(relativeStart, len). ... features: [change-array-by-copy] -includes: [deepEqual.js] +includes: [compareArray.js] ---*/ var result = [0, 1, 2, 3, 4].toSpliced(10, 1, 5, 6); -assert.deepEqual(result, [0, 1, 2, 3, 4, 5, 6]); +assert.compareArray(result, [0, 1, 2, 3, 4, 5, 6]); diff --git a/test/built-ins/Array/prototype/toSpliced/start-neg-infinity-is-zero.js b/test/built-ins/Array/prototype/toSpliced/start-neg-infinity-is-zero.js index 102175ad5ab..3fcac731d5c 100644 --- a/test/built-ins/Array/prototype/toSpliced/start-neg-infinity-is-zero.js +++ b/test/built-ins/Array/prototype/toSpliced/start-neg-infinity-is-zero.js @@ -15,8 +15,8 @@ info: | 5. Else if relativeStart < 0, let actualStart be max(len + relativeStart, 0). ... features: [change-array-by-copy] -includes: [deepEqual.js] +includes: [compareArray.js] ---*/ var result = [0, 1, 2, 3, 4].toSpliced(-Infinity, 2); -assert.deepEqual(result, [2, 3, 4]); +assert.compareArray(result, [2, 3, 4]); diff --git a/test/built-ins/Array/prototype/toSpliced/start-neg-less-than-minus-length-is-zero.js b/test/built-ins/Array/prototype/toSpliced/start-neg-less-than-minus-length-is-zero.js index 8b677bd35f1..ee52077cbad 100644 --- a/test/built-ins/Array/prototype/toSpliced/start-neg-less-than-minus-length-is-zero.js +++ b/test/built-ins/Array/prototype/toSpliced/start-neg-less-than-minus-length-is-zero.js @@ -15,8 +15,8 @@ info: | 5. Else if relativeStart < 0, let actualStart be max(len + relativeStart, 0). ... features: [change-array-by-copy] -includes: [deepEqual.js] +includes: [compareArray.js] ---*/ var result = [0, 1, 2, 3, 4].toSpliced(-20, 2); -assert.deepEqual(result, [2, 3, 4]); +assert.compareArray(result, [2, 3, 4]); diff --git a/test/built-ins/Array/prototype/toSpliced/start-neg-subtracted-from-length.js b/test/built-ins/Array/prototype/toSpliced/start-neg-subtracted-from-length.js index 210d66c605d..7058ed14564 100644 --- a/test/built-ins/Array/prototype/toSpliced/start-neg-subtracted-from-length.js +++ b/test/built-ins/Array/prototype/toSpliced/start-neg-subtracted-from-length.js @@ -15,8 +15,8 @@ info: | 5. Else if relativeStart < 0, let actualStart be max(len + relativeStart, 0). ... features: [change-array-by-copy] -includes: [deepEqual.js] +includes: [compareArray.js] ---*/ var result = [0, 1, 2, 3, 4].toSpliced(-3, 2); -assert.deepEqual(result, [0, 1, 4]); +assert.compareArray(result, [0, 1, 4]); diff --git a/test/built-ins/Array/prototype/toSpliced/start-undefined-and-deleteCount-missing.js b/test/built-ins/Array/prototype/toSpliced/start-undefined-and-deleteCount-missing.js index c237bdb3ced..af52a55ccc1 100644 --- a/test/built-ins/Array/prototype/toSpliced/start-undefined-and-deleteCount-missing.js +++ b/test/built-ins/Array/prototype/toSpliced/start-undefined-and-deleteCount-missing.js @@ -18,9 +18,9 @@ info: | a. Let actualDeleteCount be len - actualStart. ... features: [change-array-by-copy] -includes: [deepEqual.js] +includes: [compareArray.js] ---*/ var result = ["first", "second", "third"].toSpliced(undefined); -assert.deepEqual(result, []); +assert.compareArray(result, []); diff --git a/test/built-ins/Array/prototype/toSpliced/this-value-boolean.js b/test/built-ins/Array/prototype/toSpliced/this-value-boolean.js index 944d6510638..7111b2d443b 100644 --- a/test/built-ins/Array/prototype/toSpliced/this-value-boolean.js +++ b/test/built-ins/Array/prototype/toSpliced/this-value-boolean.js @@ -12,8 +12,8 @@ info: | 2. Let len be ? LengthOfArrayLike(O). ... features: [change-array-by-copy] -includes: [deepEqual.js] +includes: [compareArray.js] ---*/ -assert.deepEqual(Array.prototype.toSpliced.call(true, 0, 0), []); -assert.deepEqual(Array.prototype.toSpliced.call(false, 0, 0), []); +assert.compareArray(Array.prototype.toSpliced.call(true, 0, 0), []); +assert.compareArray(Array.prototype.toSpliced.call(false, 0, 0), []); diff --git a/test/built-ins/Array/prototype/toSpliced/unmodified.js b/test/built-ins/Array/prototype/toSpliced/unmodified.js index 1c7f3c29440..3d15e465902 100644 --- a/test/built-ins/Array/prototype/toSpliced/unmodified.js +++ b/test/built-ins/Array/prototype/toSpliced/unmodified.js @@ -6,10 +6,10 @@ esid: sec-array.prototype.toSpliced description: > Array.prototype.toSpliced returns a new array even if it the result is equal to the original array features: [change-array-by-copy] -includes: [deepEqual.js] +includes: [compareArray.js] ---*/ var arr = [1, 2, 3]; var spliced = arr.toSpliced(1, 0); assert.notSameValue(arr, spliced); -assert.deepEqual(arr, spliced); +assert.compareArray(arr, spliced); diff --git a/test/built-ins/Array/prototype/with/frozen-this-value.js b/test/built-ins/Array/prototype/with/frozen-this-value.js index 97bc0d341c5..e3f58f1b6b3 100644 --- a/test/built-ins/Array/prototype/with/frozen-this-value.js +++ b/test/built-ins/Array/prototype/with/frozen-this-value.js @@ -6,13 +6,13 @@ esid: sec-array.prototype.with description: > Array.prototype.with works on frozen objects features: [change-array-by-copy] -includes: [deepEqual.js] +includes: [compareArray.js] ---*/ var arr = Object.freeze([0, 1, 2]); var result = arr.with(1, 3); -assert.deepEqual(result, [0, 3, 2]); +assert.compareArray(result, [0, 3, 2]); var arrayLike = Object.freeze({ length: 3, 0: 0, 1: 1, 2: 2 }); var result2 = Array.prototype.with.call(arrayLike, 1, 3); -assert.deepEqual(result2, [0, 3, 2]); +assert.compareArray(result2, [0, 3, 2]); diff --git a/test/built-ins/Array/prototype/with/holes-not-preserved.js b/test/built-ins/Array/prototype/with/holes-not-preserved.js index e1040671ffa..a8426843034 100644 --- a/test/built-ins/Array/prototype/with/holes-not-preserved.js +++ b/test/built-ins/Array/prototype/with/holes-not-preserved.js @@ -18,13 +18,13 @@ info: | d. Perform ? CreateDataPropertyOrThrow(A, Pk, fromValue). e. Set k to k + 1. features: [change-array-by-copy] -includes: [deepEqual.js] +includes: [compareArray.js] ---*/ var arr = [0, /* hole */, 2, /* hole */, 4]; Array.prototype[3] = 3; var result = arr.with(2, 6); -assert.deepEqual(result, [0, undefined, 6, 3, 4]); +assert.compareArray(result, [0, undefined, 6, 3, 4]); assert(result.hasOwnProperty(1)); assert(result.hasOwnProperty(3)); diff --git a/test/built-ins/Array/prototype/with/immutable.js b/test/built-ins/Array/prototype/with/immutable.js index d1eeadf815d..ad71b7368cd 100644 --- a/test/built-ins/Array/prototype/with/immutable.js +++ b/test/built-ins/Array/prototype/with/immutable.js @@ -6,10 +6,10 @@ esid: sec-array.prototype.with description: > Array.prototype.with does not mutate its this value features: [change-array-by-copy] -includes: [deepEqual.js] +includes: [compareArray.js] ---*/ var arr = [0, 1, 2]; arr.with(1, 3); -assert.deepEqual(arr, [0, 1, 2]); +assert.compareArray(arr, [0, 1, 2]); diff --git a/test/built-ins/Array/prototype/with/index-casted-to-number.js b/test/built-ins/Array/prototype/with/index-casted-to-number.js index ee479098606..668d871b551 100644 --- a/test/built-ins/Array/prototype/with/index-casted-to-number.js +++ b/test/built-ins/Array/prototype/with/index-casted-to-number.js @@ -15,13 +15,13 @@ info: | 5. Else, let actualIndex be len + relativeIndex. ... features: [change-array-by-copy] -includes: [deepEqual.js] +includes: [compareArray.js] ---*/ var arr = [0, 4, 16]; -assert.deepEqual(arr.with(1.2, 7), [0, 7, 16]); -assert.deepEqual(arr.with("1", 3), [0, 3, 16]); -assert.deepEqual(arr.with("-1", 5), [0, 4, 5]); -assert.deepEqual(arr.with(NaN, 2), [2, 4, 16]); -assert.deepEqual(arr.with("dog", "cat"), ["cat", 4, 16]); +assert.compareArray(arr.with(1.2, 7), [0, 7, 16]); +assert.compareArray(arr.with("1", 3), [0, 3, 16]); +assert.compareArray(arr.with("-1", 5), [0, 4, 5]); +assert.compareArray(arr.with(NaN, 2), [2, 4, 16]); +assert.compareArray(arr.with("dog", "cat"), ["cat", 4, 16]); diff --git a/test/built-ins/Array/prototype/with/index-negative.js b/test/built-ins/Array/prototype/with/index-negative.js index 9185ed08897..8122bc68b0e 100644 --- a/test/built-ins/Array/prototype/with/index-negative.js +++ b/test/built-ins/Array/prototype/with/index-negative.js @@ -15,13 +15,13 @@ info: | 5. Else, let actualIndex be len + relativeIndex. ... features: [change-array-by-copy] -includes: [deepEqual.js] +includes: [compareArray.js] ---*/ var arr = [0, 1, 2]; -assert.deepEqual(arr.with(-1, 4), [0, 1, 4]); -assert.deepEqual(arr.with(-3, 4), [4, 1, 2]); +assert.compareArray(arr.with(-1, 4), [0, 1, 4]); +assert.compareArray(arr.with(-3, 4), [4, 1, 2]); // -0 is not < 0 -assert.deepEqual(arr.with(-0, 4), [4, 1, 2]); +assert.compareArray(arr.with(-0, 4), [4, 1, 2]); diff --git a/test/built-ins/Array/prototype/with/length-decreased-while-iterating.js b/test/built-ins/Array/prototype/with/length-decreased-while-iterating.js index 0abbd1807b6..60afbf55070 100644 --- a/test/built-ins/Array/prototype/with/length-decreased-while-iterating.js +++ b/test/built-ins/Array/prototype/with/length-decreased-while-iterating.js @@ -18,7 +18,7 @@ info: | d. Perform ? CreateDataPropertyOrThrow(A, Pk, fromValue). e. Set k to k + 1. features: [change-array-by-copy] -includes: [deepEqual.js] +includes: [compareArray.js] ---*/ Array.prototype[4] = 5; @@ -29,7 +29,7 @@ var arr = Object.defineProperty([0, 1, 2, 3, 4], "1", { return 1; } }); -assert.deepEqual(arr.with(2, 7), [0, 1, 7, undefined, 5]); +assert.compareArray(arr.with(2, 7), [0, 1, 7, undefined, 5]); arr = Object.defineProperty([0, 1, 2, 3, 4], "1", { get() { @@ -37,4 +37,4 @@ arr = Object.defineProperty([0, 1, 2, 3, 4], "1", { return 1; } }); -assert.deepEqual(arr.with(0, 7), [7, 1, undefined, undefined, 5]); +assert.compareArray(arr.with(0, 7), [7, 1, undefined, undefined, 5]); diff --git a/test/built-ins/Array/prototype/with/length-increased-while-iterating.js b/test/built-ins/Array/prototype/with/length-increased-while-iterating.js index 93c487edc5a..1465bf44a4d 100644 --- a/test/built-ins/Array/prototype/with/length-increased-while-iterating.js +++ b/test/built-ins/Array/prototype/with/length-increased-while-iterating.js @@ -18,7 +18,7 @@ info: | d. Perform ? CreateDataPropertyOrThrow(A, Pk, fromValue). e. Set k to k + 1. features: [change-array-by-copy] -includes: [deepEqual.js] +includes: [compareArray.js] ---*/ var arr = [0, 1, 2]; @@ -29,4 +29,4 @@ Object.defineProperty(arr, "0", { } }); -assert.deepEqual(arr.with(1, 4), [0, 4, 2]); +assert.compareArray(arr.with(1, 4), [0, 4, 2]); diff --git a/test/built-ins/Array/prototype/with/length-integer-string.js b/test/built-ins/Array/prototype/with/length-integer-string.js index 12c2860db30..392ece8b28c 100644 --- a/test/built-ins/Array/prototype/with/length-integer-string.js +++ b/test/built-ins/Array/prototype/with/length-integer-string.js @@ -12,11 +12,11 @@ info: | 2. Let len be ? LengthOfArrayLike(O). ... features: [change-array-by-copy] -includes: [deepEqual.js] +includes: [compareArray.js] ---*/ var arrayLike = { length: "2", 0: 1, 1: 2, 2: 3 }; -assert.deepEqual(Array.prototype.with.call(arrayLike, 0, 4), [4, 2]); +assert.compareArray(Array.prototype.with.call(arrayLike, 0, 4), [4, 2]); var arrayLike = { length: { @@ -27,4 +27,4 @@ var arrayLike = { 2: 3, }; -assert.deepEqual(Array.prototype.with.call(arrayLike, 0, 4), [4, 2]); +assert.compareArray(Array.prototype.with.call(arrayLike, 0, 4), [4, 2]); diff --git a/test/built-ins/Array/prototype/with/no-get-replaced-index.js b/test/built-ins/Array/prototype/with/no-get-replaced-index.js index c6ee2f6dd4d..1d52a400f40 100644 --- a/test/built-ins/Array/prototype/with/no-get-replaced-index.js +++ b/test/built-ins/Array/prototype/with/no-get-replaced-index.js @@ -16,7 +16,7 @@ info: | d. Perform ? CreateDataPropertyOrThrow(A, Pk, fromValue). e. Set k to k + 1. features: [change-array-by-copy] -includes: [deepEqual.js] +includes: [compareArray.js] ---*/ var arr = [0, 1, 2, 3]; @@ -27,4 +27,4 @@ Object.defineProperty(arr, "2", { }); var result = arr.with(2, 6); -assert.deepEqual(result, [0, 1, 6, 3]); +assert.compareArray(result, [0, 1, 6, 3]); diff --git a/test/built-ins/Array/prototype/with/this-value-boolean.js b/test/built-ins/Array/prototype/with/this-value-boolean.js index 044619ba765..921cd634349 100644 --- a/test/built-ins/Array/prototype/with/this-value-boolean.js +++ b/test/built-ins/Array/prototype/with/this-value-boolean.js @@ -12,12 +12,12 @@ info: | 2. Let len be ? LengthOfArrayLike(O). ... features: [change-array-by-copy] -includes: [deepEqual.js] +includes: [compareArray.js] ---*/ Boolean.prototype.length = 2; Boolean.prototype[0] = 0; Boolean.prototype[1] = 1; -assert.deepEqual(Array.prototype.with.call(true, 0, 2), [2, 1]); -assert.deepEqual(Array.prototype.with.call(false, 0, 2), [2, 1]); +assert.compareArray(Array.prototype.with.call(true, 0, 2), [2, 1]); +assert.compareArray(Array.prototype.with.call(false, 0, 2), [2, 1]); From 81e4fe18752c51e6a20639aed6d27ff86666436d Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Mon, 30 May 2022 19:49:18 +0200 Subject: [PATCH 25/86] Verify results in frozen-this-value tests --- .../Array/prototype/toReversed/frozen-this-value.js | 6 ++++-- .../built-ins/Array/prototype/toSorted/frozen-this-value.js | 6 ++++-- .../Array/prototype/toSpliced/frozen-this-value.js | 3 ++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/test/built-ins/Array/prototype/toReversed/frozen-this-value.js b/test/built-ins/Array/prototype/toReversed/frozen-this-value.js index 6b2bfcb6aba..f81f95204d3 100644 --- a/test/built-ins/Array/prototype/toReversed/frozen-this-value.js +++ b/test/built-ins/Array/prototype/toReversed/frozen-this-value.js @@ -9,7 +9,9 @@ features: [change-array-by-copy] ---*/ var arr = Object.freeze([0, 1, 2]); -arr.toReversed(); +var result = arr.toReversed(); +assert.compareArray(result, [2, 1, 0]); var arrayLike = Object.freeze({ length: 3, 0: 0, 1: 1, 2: 2 }); -Array.prototype.toReversed.call(arrayLike); +result = Array.prototype.toReversed.call(arrayLike); +assert.compareArray(result, [2, 1, 0]); diff --git a/test/built-ins/Array/prototype/toSorted/frozen-this-value.js b/test/built-ins/Array/prototype/toSorted/frozen-this-value.js index 03ef85084ae..13b1ea035d6 100644 --- a/test/built-ins/Array/prototype/toSorted/frozen-this-value.js +++ b/test/built-ins/Array/prototype/toSorted/frozen-this-value.js @@ -9,7 +9,9 @@ features: [change-array-by-copy] ---*/ var arr = Object.freeze([2, 0, 1]); -arr.toSorted(); +var result = arr.toSorted(); +assert.compareArray(result, [0, 1, 2]); var arrayLike = Object.freeze({ length: 3, 0: 2, 1: 0, 2: 1 }); -Array.prototype.toSorted.call(arrayLike); +result = Array.prototype.toSorted.call(arrayLike); +assert.compareArray(result, [0, 1, 2]); diff --git a/test/built-ins/Array/prototype/toSpliced/frozen-this-value.js b/test/built-ins/Array/prototype/toSpliced/frozen-this-value.js index 8dec633eda2..d3bd3e7ed80 100644 --- a/test/built-ins/Array/prototype/toSpliced/frozen-this-value.js +++ b/test/built-ins/Array/prototype/toSpliced/frozen-this-value.js @@ -10,7 +10,8 @@ includes: [compareArray.js] ---*/ var arr = Object.freeze([2, 0, 1]); -arr.toSpliced(); +var result = arr.toSpliced(); +assert.compareArray(result, [2, 0, 1]); var arrayLike = Object.freeze({ length: 3, 0: 0, 1: 1, 2: 2 }); From 399af89cde8a8fdfced2c9cd2b37ad0f69ddb56e Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Mon, 30 May 2022 19:58:08 +0200 Subject: [PATCH 26/86] Check that array methods don't return the same value as `this` in immutability tests --- test/built-ins/Array/prototype/toReversed/immutable.js | 1 + test/built-ins/Array/prototype/toSorted/immutable.js | 1 + test/built-ins/Array/prototype/toSpliced/immutable.js | 2 ++ test/built-ins/Array/prototype/with/immutable.js | 2 ++ test/built-ins/TypedArray/prototype/toReversed/immutable.js | 1 + test/built-ins/TypedArray/prototype/toSorted/immutable.js | 1 + test/built-ins/TypedArray/prototype/toSpliced/immutable.js | 2 ++ test/built-ins/TypedArray/prototype/with/immutable.js | 2 ++ 8 files changed, 12 insertions(+) diff --git a/test/built-ins/Array/prototype/toReversed/immutable.js b/test/built-ins/Array/prototype/toReversed/immutable.js index f25ef8932f9..cdee317f72b 100644 --- a/test/built-ins/Array/prototype/toReversed/immutable.js +++ b/test/built-ins/Array/prototype/toReversed/immutable.js @@ -13,3 +13,4 @@ var arr = [0, 1, 2]; arr.toReversed(); assert.compareArray(arr, [0, 1, 2]); +assert.notSameValue(arr.toReversed(), arr); diff --git a/test/built-ins/Array/prototype/toSorted/immutable.js b/test/built-ins/Array/prototype/toSorted/immutable.js index 6d4e922d19a..558005d8851 100644 --- a/test/built-ins/Array/prototype/toSorted/immutable.js +++ b/test/built-ins/Array/prototype/toSorted/immutable.js @@ -13,3 +13,4 @@ var arr = [2, 0, 1]; arr.toSorted(); assert.compareArray(arr, [2, 0, 1]); +assert.notSameValue(arr.toSorted(), arr); diff --git a/test/built-ins/Array/prototype/toSpliced/immutable.js b/test/built-ins/Array/prototype/toSpliced/immutable.js index 26b2251dce2..443ad5fed77 100644 --- a/test/built-ins/Array/prototype/toSpliced/immutable.js +++ b/test/built-ins/Array/prototype/toSpliced/immutable.js @@ -13,3 +13,5 @@ var arr = [2, 0, 1]; arr.toSpliced(0, 0, -1); assert.compareArray(arr, [2, 0, 1]); +assert.notSameValue(arr.toSpliced(0, 0, -1), arr); +assert.notSameValue(arr.toSpliced(0, 1, -1), arr); diff --git a/test/built-ins/Array/prototype/with/immutable.js b/test/built-ins/Array/prototype/with/immutable.js index ad71b7368cd..ae8344d9aee 100644 --- a/test/built-ins/Array/prototype/with/immutable.js +++ b/test/built-ins/Array/prototype/with/immutable.js @@ -13,3 +13,5 @@ var arr = [0, 1, 2]; arr.with(1, 3); assert.compareArray(arr, [0, 1, 2]); +assert.notSameValue(arr.with(1, 3), arr); +assert.notSameValue(arr.with(1, 1), arr); diff --git a/test/built-ins/TypedArray/prototype/toReversed/immutable.js b/test/built-ins/TypedArray/prototype/toReversed/immutable.js index e598850e235..8557e22b6ca 100644 --- a/test/built-ins/TypedArray/prototype/toReversed/immutable.js +++ b/test/built-ins/TypedArray/prototype/toReversed/immutable.js @@ -14,4 +14,5 @@ testWithTypedArrayConstructors(TA => { ta.toReversed(); assert.compareArray(ta, [0, 1, 2]); + assert.notSameValue(ta.toReversed(), ta); }); diff --git a/test/built-ins/TypedArray/prototype/toSorted/immutable.js b/test/built-ins/TypedArray/prototype/toSorted/immutable.js index 719f41a7f44..a27ef3fc70b 100644 --- a/test/built-ins/TypedArray/prototype/toSorted/immutable.js +++ b/test/built-ins/TypedArray/prototype/toSorted/immutable.js @@ -14,4 +14,5 @@ testWithTypedArrayConstructors(TA => { ta.toSorted(); assert.compareArray(ta, [3, 1, 2]); + assert.notSameValue(ta.toSorted(), ta); }); diff --git a/test/built-ins/TypedArray/prototype/toSpliced/immutable.js b/test/built-ins/TypedArray/prototype/toSpliced/immutable.js index ed3b6a9622e..0a969657339 100644 --- a/test/built-ins/TypedArray/prototype/toSpliced/immutable.js +++ b/test/built-ins/TypedArray/prototype/toSpliced/immutable.js @@ -14,4 +14,6 @@ testWithTypedArrayConstructors(TA => { ta.toSpliced(0, 2); assert.compareArray(ta, [3, 1, 2]); + assert.notSameValue(ta.toSpliced(0, 2), ta); + assert.notSameValue(ta.toSpliced(0, 0), ta); }); diff --git a/test/built-ins/TypedArray/prototype/with/immutable.js b/test/built-ins/TypedArray/prototype/with/immutable.js index 348e4f9101e..eff35b607d0 100644 --- a/test/built-ins/TypedArray/prototype/with/immutable.js +++ b/test/built-ins/TypedArray/prototype/with/immutable.js @@ -14,4 +14,6 @@ testWithTypedArrayConstructors(TA => { ta.with(0, 2); assert.compareArray(ta, [3, 1, 2]); + assert.notSameValue(ta.with(0, 2), ta); + assert.notSameValue(ta.with(0, 3), ta); }); From b14685df5888519bd77c1d6b07d191904903e647 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Mon, 30 May 2022 20:01:36 +0200 Subject: [PATCH 27/86] Throw Test262Error in toSorted() tests --- .../toSorted/comparefn-called-after-get-elements.js | 6 ++---- .../prototype/toSorted/comparefn-stop-after-error.js | 12 +++++------- .../prototype/toSorted/comparefn-stop-after-error.js | 4 +--- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/test/built-ins/Array/prototype/toSorted/comparefn-called-after-get-elements.js b/test/built-ins/Array/prototype/toSorted/comparefn-called-after-get-elements.js index ae0273b1c3b..b58e763cf60 100644 --- a/test/built-ins/Array/prototype/toSorted/comparefn-called-after-get-elements.js +++ b/test/built-ins/Array/prototype/toSorted/comparefn-called-after-get-elements.js @@ -33,11 +33,9 @@ var arrayLike = { } -function StopToSorted() {} - -assert.throws(StopToSorted, function() { +assert.throws(Test262Error, function() { Array.prototype.toSorted.call(arrayLike, () => { - throw new StopToSorted(); + throw new Test262Error(); }); }); diff --git a/test/built-ins/Array/prototype/toSorted/comparefn-stop-after-error.js b/test/built-ins/Array/prototype/toSorted/comparefn-stop-after-error.js index 40e89830ccb..e3b1ddc4ff9 100644 --- a/test/built-ins/Array/prototype/toSorted/comparefn-stop-after-error.js +++ b/test/built-ins/Array/prototype/toSorted/comparefn-stop-after-error.js @@ -4,7 +4,7 @@ /*--- esid: sec-array.prototype.toSorted description: > - Array.prototype.toSorted doesn't call copmareFn if there is an error + Array.prototype.toSorted doesn't call compareFn if there is an error info: | Array.prototype.toSorted ( compareFn ) @@ -17,15 +17,13 @@ info: | features: [change-array-by-copy] ---*/ -function StopToSorted() {} - var arrayLike = { length: 1, - get 0() { throw new StopToSorted(); }, + get 0() { throw new Test262Error(); }, }; var called = false; -assert.throws(StopToSorted, function() { +assert.throws(Test262Error, function() { Array.prototype.toSorted.call(arrayLike, () => { called = true; }); @@ -33,12 +31,12 @@ assert.throws(StopToSorted, function() { assert.sameValue(called, false); called = false; -assert.throws(StopToSorted, function() { +assert.throws(Test262Error, function() { var first = true; [1, 2, 3].toSorted(() => { if (first) { first = false; - throw new StopToSorted(); + throw new Test262Error(); } called = true; }); diff --git a/test/built-ins/TypedArray/prototype/toSorted/comparefn-stop-after-error.js b/test/built-ins/TypedArray/prototype/toSorted/comparefn-stop-after-error.js index f623afdee51..cb9db9132c7 100644 --- a/test/built-ins/TypedArray/prototype/toSorted/comparefn-stop-after-error.js +++ b/test/built-ins/TypedArray/prototype/toSorted/comparefn-stop-after-error.js @@ -18,8 +18,6 @@ includes: [testTypedArray.js] features: [TypedArray, change-array-by-copy] ---*/ -function StopToSorted() {} - testWithTypedArrayConstructors(TA => { var calls = 0; var ta = new TA([3, 1, 2]); @@ -27,7 +25,7 @@ testWithTypedArrayConstructors(TA => { ta.toSorted(() => { if (calls === 0) { calls++; - throw new StopToSorted(); + throw new Test262Error(); } calls++; }); From 07a732a6c25c0cc0e068bf0969f381a83b91fffe Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Thu, 2 Jun 2022 06:36:52 +0200 Subject: [PATCH 28/86] Add array cases to toReversed/get-descending-order and toSpliced/elements-read-in-order --- .../prototype/toReversed/get-descending-order.js | 10 ++++++++++ .../prototype/toSpliced/elements-read-in-order.js | 11 +++++++++++ 2 files changed, 21 insertions(+) diff --git a/test/built-ins/Array/prototype/toReversed/get-descending-order.js b/test/built-ins/Array/prototype/toReversed/get-descending-order.js index 702418d013a..0372be7da51 100644 --- a/test/built-ins/Array/prototype/toReversed/get-descending-order.js +++ b/test/built-ins/Array/prototype/toReversed/get-descending-order.js @@ -37,3 +37,13 @@ var arrayLike = { Array.prototype.toReversed.call(arrayLike); assert.compareArray(order, [2, 1, 0]); + +order = []; +var arr = [0, 1, 2]; +Object.defineProperty(arr, 0, { get: function() { order.push(0); } }); +Object.defineProperty(arr, 1, { get: function() { order.push(1); } }); +Object.defineProperty(arr, 2, { get: function() { order.push(2); } }); + +Array.prototype.toReversed.call(arr); + +assert.compareArray(order, [2, 1, 0]); diff --git a/test/built-ins/Array/prototype/toSpliced/elements-read-in-order.js b/test/built-ins/Array/prototype/toSpliced/elements-read-in-order.js index cfc15f63103..b9987db6b40 100644 --- a/test/built-ins/Array/prototype/toSpliced/elements-read-in-order.js +++ b/test/built-ins/Array/prototype/toSpliced/elements-read-in-order.js @@ -35,3 +35,14 @@ var result = Array.prototype.toSpliced.call(arrayLike, 2, 1); assert.compareArray(result, ["a", "b", "c"]); assert.compareArray(order, [0, 1, 3]); + +order = []; +var arr = [0, 1, "none", 3]; +Object.defineProperty(arr, 0, { get: function() { order.push(0); return "a" } }); +Object.defineProperty(arr, 1, { get: function() { order.push(1); return "b" } }); +Object.defineProperty(arr, 3, { get: function() { order.push(3); return "c" } }); + +result = Array.prototype.toSpliced.call(arr, 2, 1); +assert.compareArray(result, ["a", "b", "c"]); + +assert.compareArray(order, [0, 1, 3]); From 2dcbe3bf2eb81191aa52749762b3fa80a29d2bc6 Mon Sep 17 00:00:00 2001 From: Ashley Claymore Date: Thu, 23 Jun 2022 21:23:34 +0100 Subject: [PATCH 29/86] Test TypedArray#with coverts number before loop --- .../prototype/with/early-type-coercion.js | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 test/built-ins/TypedArray/prototype/with/early-type-coercion.js diff --git a/test/built-ins/TypedArray/prototype/with/early-type-coercion.js b/test/built-ins/TypedArray/prototype/with/early-type-coercion.js new file mode 100644 index 00000000000..c428a0bd392 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/with/early-type-coercion.js @@ -0,0 +1,31 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.with +description: > + %TypedArray%.prototype.with invokes ToNumber before copying +info: | + %TypedArray%.prototype.with ( index, value ) + + ... + 7. If _O_.[[ContentType]] is ~BigInt~, set _value_ to ? ToBigInt(_value_). + 8. Else, set _value_ to ? ToNumber(_value_). + ... +features: [TypedArray, change-array-by-copy] +includes: [testTypedArray.js, compareArray.js] +---*/ + +testWithTypedArrayConstructors(TA => { + var arr = new TA([0, 1, 2]); + + var value = { + valueOf() { + arr[0] = 3; + return 4; + } + }; + + assert.compareArray(arr.with(1, value), [3, 4, 2]); + assert.compareArray(arr, [3, 1, 2]); +}); From 65845bae8d29994b586ea4e3d413650784b2baf0 Mon Sep 17 00:00:00 2001 From: Ashley Claymore Date: Thu, 23 Jun 2022 21:39:17 +0100 Subject: [PATCH 30/86] add missing includes to frozen-this-value tests --- test/built-ins/Array/prototype/toReversed/frozen-this-value.js | 1 + test/built-ins/Array/prototype/toSorted/frozen-this-value.js | 1 + 2 files changed, 2 insertions(+) diff --git a/test/built-ins/Array/prototype/toReversed/frozen-this-value.js b/test/built-ins/Array/prototype/toReversed/frozen-this-value.js index f81f95204d3..62915553487 100644 --- a/test/built-ins/Array/prototype/toReversed/frozen-this-value.js +++ b/test/built-ins/Array/prototype/toReversed/frozen-this-value.js @@ -6,6 +6,7 @@ esid: sec-array.prototype.toReversed description: > Array.prototype.toReversed works on frozen objects features: [change-array-by-copy] +includes: [compareArray.js] ---*/ var arr = Object.freeze([0, 1, 2]); diff --git a/test/built-ins/Array/prototype/toSorted/frozen-this-value.js b/test/built-ins/Array/prototype/toSorted/frozen-this-value.js index 13b1ea035d6..2fc60d56347 100644 --- a/test/built-ins/Array/prototype/toSorted/frozen-this-value.js +++ b/test/built-ins/Array/prototype/toSorted/frozen-this-value.js @@ -6,6 +6,7 @@ esid: sec-array.prototype.toSorted description: > Array.prototype.toSorted works on frozen objects features: [change-array-by-copy] +includes: [compareArray.js] ---*/ var arr = Object.freeze([2, 0, 1]); From 4ebcca2c80915957f48129a3e701ce081d719f72 Mon Sep 17 00:00:00 2001 From: Ashley Claymore Date: Fri, 24 Jun 2022 20:50:52 +0100 Subject: [PATCH 31/86] refer to TypedArray as %TypedArray% --- .../TypedArray/prototype/toReversed/ignores-species.js | 4 ++-- test/built-ins/TypedArray/prototype/toReversed/immutable.js | 2 +- .../prototype/toReversed/length-property-ignored.js | 4 ++-- .../TypedArray/prototype/toReversed/metadata/length.js | 4 ++-- .../TypedArray/prototype/toReversed/metadata/name.js | 6 +++--- .../prototype/toReversed/metadata/property-descriptor.js | 4 ++-- .../TypedArray/prototype/toReversed/not-a-constructor.js | 2 +- .../TypedArray/prototype/toReversed/this-value-invalid.js | 4 ++-- .../TypedArray/prototype/toSorted/ignores-species.js | 4 ++-- test/built-ins/TypedArray/prototype/toSorted/immutable.js | 2 +- .../prototype/toSorted/length-property-ignored.js | 4 ++-- .../TypedArray/prototype/toSorted/metadata/length.js | 4 ++-- .../TypedArray/prototype/toSorted/metadata/name.js | 6 +++--- .../prototype/toSorted/metadata/property-descriptor.js | 4 ++-- .../TypedArray/prototype/toSorted/not-a-constructor.js | 2 +- .../TypedArray/prototype/toSorted/this-value-invalid.js | 4 ++-- .../TypedArray/prototype/toSpliced/deleteCount-undefined.js | 6 +++--- .../prototype/toSpliced/length-property-ignored.js | 4 ++-- test/built-ins/TypedArray/prototype/with/index-negative.js | 6 +++--- .../prototype/with/index-smaller-than-minus-length.js | 6 +++--- 20 files changed, 41 insertions(+), 41 deletions(-) diff --git a/test/built-ins/TypedArray/prototype/toReversed/ignores-species.js b/test/built-ins/TypedArray/prototype/toReversed/ignores-species.js index 91f5527e58e..ed1ad0cfafe 100644 --- a/test/built-ins/TypedArray/prototype/toReversed/ignores-species.js +++ b/test/built-ins/TypedArray/prototype/toReversed/ignores-species.js @@ -4,9 +4,9 @@ /*--- esid: sec-%typedarray%.prototype.toReversed description: > - TypedArray.prototype.toReversed ignores @@species + %TypedArray%.prototype.toReversed ignores @@species info: | - TypedArray.prototype.toReversed ( ) + %TypedArray%.prototype.toReversed ( ) ... 5. Let A be ? TypedArraySpeciesCreate(O, Β« 𝔽(len) Β», true). diff --git a/test/built-ins/TypedArray/prototype/toReversed/immutable.js b/test/built-ins/TypedArray/prototype/toReversed/immutable.js index 8557e22b6ca..98ad180e926 100644 --- a/test/built-ins/TypedArray/prototype/toReversed/immutable.js +++ b/test/built-ins/TypedArray/prototype/toReversed/immutable.js @@ -4,7 +4,7 @@ /*--- esid: sec-%typedarray%.prototype.toReversed description: > - TypedArray.prototype.toReversed does not mutate its this value + %TypedArray%.prototype.toReversed does not mutate its this value includes: [testTypedArray.js, compareArray.js] features: [TypedArray, change-array-by-copy] ---*/ diff --git a/test/built-ins/TypedArray/prototype/toReversed/length-property-ignored.js b/test/built-ins/TypedArray/prototype/toReversed/length-property-ignored.js index f6c382f7c2c..5d460b1cfd0 100644 --- a/test/built-ins/TypedArray/prototype/toReversed/length-property-ignored.js +++ b/test/built-ins/TypedArray/prototype/toReversed/length-property-ignored.js @@ -4,9 +4,9 @@ /*--- esid: sec-%typedarray%.prototype.toReversed description: > - TypedArray.prototype.toReversed creates an empty array if the this value .length is not a positive integer. + %TypedArray%.prototype.toReversed creates an empty array if the this value .length is not a positive integer. info: | - TypedArray.prototype.toReversed ( ) + %TypedArray%.prototype.toReversed ( ) ... 3. Let len be O.[[ArrayLength]]. diff --git a/test/built-ins/TypedArray/prototype/toReversed/metadata/length.js b/test/built-ins/TypedArray/prototype/toReversed/metadata/length.js index 8649664e8b9..95f495340d0 100644 --- a/test/built-ins/TypedArray/prototype/toReversed/metadata/length.js +++ b/test/built-ins/TypedArray/prototype/toReversed/metadata/length.js @@ -2,9 +2,9 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-typedarray.prototype.toReversed +esid: sec-%typedarray%.prototype.toReversed description: > - The "length" property of TypedArray.prototype.toReversed + The "length" property of %TypedArray%.prototype.toReversed info: | 17 ECMAScript Standard Built-in Objects diff --git a/test/built-ins/TypedArray/prototype/toReversed/metadata/name.js b/test/built-ins/TypedArray/prototype/toReversed/metadata/name.js index d1de00b7928..6c301f71216 100644 --- a/test/built-ins/TypedArray/prototype/toReversed/metadata/name.js +++ b/test/built-ins/TypedArray/prototype/toReversed/metadata/name.js @@ -2,11 +2,11 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-typedarray.prototype.toReversed +esid: sec-%typedarray%.prototype.toReversed description: > - TypedArray.prototype.toReversed.name is "toReversed". + %TypedArray%.prototype.toReversed.name is "toReversed". info: | - TypedArray.prototype.toReversed ( ) + %TypedArray%.prototype.toReversed ( ) 17 ECMAScript Standard Built-in Objects: Every built-in Function object, including constructors, that is not diff --git a/test/built-ins/TypedArray/prototype/toReversed/metadata/property-descriptor.js b/test/built-ins/TypedArray/prototype/toReversed/metadata/property-descriptor.js index a3695423dc8..bafa3cb6c18 100644 --- a/test/built-ins/TypedArray/prototype/toReversed/metadata/property-descriptor.js +++ b/test/built-ins/TypedArray/prototype/toReversed/metadata/property-descriptor.js @@ -2,9 +2,9 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-typedarray.prototype.toReversed +esid: sec-%typedarray%.prototype.toReversed description: > - "toReversed" property of TypedArray.prototype + "toReversed" property of %TypedArray%.prototype info: | 17 ECMAScript Standard Built-in Objects diff --git a/test/built-ins/TypedArray/prototype/toReversed/not-a-constructor.js b/test/built-ins/TypedArray/prototype/toReversed/not-a-constructor.js index ff4d69ab395..3b6dec69198 100644 --- a/test/built-ins/TypedArray/prototype/toReversed/not-a-constructor.js +++ b/test/built-ins/TypedArray/prototype/toReversed/not-a-constructor.js @@ -4,7 +4,7 @@ /*--- esid: sec-ecmascript-standard-built-in-objects description: > - TypedArray.prototype.toReversed does not implement [[Construct]], is not new-able + %TypedArray%.prototype.toReversed does not implement [[Construct]], is not new-able info: | ECMAScript Function Objects diff --git a/test/built-ins/TypedArray/prototype/toReversed/this-value-invalid.js b/test/built-ins/TypedArray/prototype/toReversed/this-value-invalid.js index e6102e6dba3..512f527bc7c 100644 --- a/test/built-ins/TypedArray/prototype/toReversed/this-value-invalid.js +++ b/test/built-ins/TypedArray/prototype/toReversed/this-value-invalid.js @@ -4,9 +4,9 @@ /*--- esid: sec-%typedarray%.prototype.toReversed description: > - TypedArray.prototype.toReversed throws if the receiver is null or undefined + %TypedArray%.prototype.toReversed throws if the receiver is null or undefined info: | - TypedArray.prototype.toReversed ( ) + %TypedArray%.prototype.toReversed ( ) 1. Let O be the this value. 2. Perform ? ValidateTypedArray(O). diff --git a/test/built-ins/TypedArray/prototype/toSorted/ignores-species.js b/test/built-ins/TypedArray/prototype/toSorted/ignores-species.js index e0d42026cc1..8bfe0f2f10e 100644 --- a/test/built-ins/TypedArray/prototype/toSorted/ignores-species.js +++ b/test/built-ins/TypedArray/prototype/toSorted/ignores-species.js @@ -4,9 +4,9 @@ /*--- esid: sec-%typedarray%.prototype.toSorted description: > - TypedArray.prototype.toSorted ignores @@species + %TypedArray%.prototype.toSorted ignores @@species info: | - TypedArray.prototype.toSorted ( comparefn ) + %TypedArray%.prototype.toSorted ( comparefn ) ... 5. Let A be ? TypedArraySpeciesCreate(O, Β« 𝔽(len) Β», true). diff --git a/test/built-ins/TypedArray/prototype/toSorted/immutable.js b/test/built-ins/TypedArray/prototype/toSorted/immutable.js index a27ef3fc70b..3913dbbc86f 100644 --- a/test/built-ins/TypedArray/prototype/toSorted/immutable.js +++ b/test/built-ins/TypedArray/prototype/toSorted/immutable.js @@ -4,7 +4,7 @@ /*--- esid: sec-%typedarray%.prototype.toSorted description: > - TypedArray.prototype.toSorted does not mutate its this value + %TypedArray%.prototype.toSorted does not mutate its this value includes: [testTypedArray.js, compareArray.js] features: [TypedArray, change-array-by-copy] ---*/ diff --git a/test/built-ins/TypedArray/prototype/toSorted/length-property-ignored.js b/test/built-ins/TypedArray/prototype/toSorted/length-property-ignored.js index c0d9a1d7719..842266c30db 100644 --- a/test/built-ins/TypedArray/prototype/toSorted/length-property-ignored.js +++ b/test/built-ins/TypedArray/prototype/toSorted/length-property-ignored.js @@ -4,9 +4,9 @@ /*--- esid: sec-%typedarray%.prototype.toSorted description: > - TypedArray.prototype.toSorted creates an empty array if the this value .length is not a positive integer. + %TypedArray%.prototype.toSorted creates an empty array if the this value .length is not a positive integer. info: | - TypedArray.prototype.toSorted ( comparefn ) + %TypedArray%.prototype.toSorted ( comparefn ) ... 4. Let len be O.[[ArrayLength]]. diff --git a/test/built-ins/TypedArray/prototype/toSorted/metadata/length.js b/test/built-ins/TypedArray/prototype/toSorted/metadata/length.js index e115afd7a6a..13d4370e73f 100644 --- a/test/built-ins/TypedArray/prototype/toSorted/metadata/length.js +++ b/test/built-ins/TypedArray/prototype/toSorted/metadata/length.js @@ -2,9 +2,9 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-typedarray.prototype.toSorted +esid: sec-%typedarray%.prototype.toSorted description: > - The "length" property of TypedArray.prototype.toSorted + The "length" property of %TypedArray%.prototype.toSorted info: | 17 ECMAScript Standard Built-in Objects diff --git a/test/built-ins/TypedArray/prototype/toSorted/metadata/name.js b/test/built-ins/TypedArray/prototype/toSorted/metadata/name.js index 26caf82e657..9d881569d1d 100644 --- a/test/built-ins/TypedArray/prototype/toSorted/metadata/name.js +++ b/test/built-ins/TypedArray/prototype/toSorted/metadata/name.js @@ -2,11 +2,11 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-typedarray.prototype.toSorted +esid: sec-%typedarray%.prototype.toSorted description: > - TypedArray.prototype.toSorted.name is "toSorted". + %TypedArray%.prototype.toSorted.name is "toSorted". info: | - TypedArray.prototype.toSorted ( comparefn ) + %TypedArray%.prototype.toSorted ( comparefn ) 17 ECMAScript Standard Built-in Objects: Every built-in Function object, including constructors, that is not diff --git a/test/built-ins/TypedArray/prototype/toSorted/metadata/property-descriptor.js b/test/built-ins/TypedArray/prototype/toSorted/metadata/property-descriptor.js index 288f1eb0238..41e22cb86f7 100644 --- a/test/built-ins/TypedArray/prototype/toSorted/metadata/property-descriptor.js +++ b/test/built-ins/TypedArray/prototype/toSorted/metadata/property-descriptor.js @@ -2,9 +2,9 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-typedarray.prototype.toSorted +esid: sec-%typedarray%.prototype.toSorted description: > - "toSorted" property of TypedArray.prototype + "toSorted" property of %TypedArray%.prototype info: | 17 ECMAScript Standard Built-in Objects diff --git a/test/built-ins/TypedArray/prototype/toSorted/not-a-constructor.js b/test/built-ins/TypedArray/prototype/toSorted/not-a-constructor.js index 2620bbadae4..745d7a4bca8 100644 --- a/test/built-ins/TypedArray/prototype/toSorted/not-a-constructor.js +++ b/test/built-ins/TypedArray/prototype/toSorted/not-a-constructor.js @@ -4,7 +4,7 @@ /*--- esid: sec-ecmascript-standard-built-in-objects description: > - TypedArray.prototype.toSorted does not implement [[Construct]], is not new-able + %TypedArray%.prototype.toSorted does not implement [[Construct]], is not new-able info: | ECMAScript Function Objects diff --git a/test/built-ins/TypedArray/prototype/toSorted/this-value-invalid.js b/test/built-ins/TypedArray/prototype/toSorted/this-value-invalid.js index 192aebdd8b5..4b8a59d512a 100644 --- a/test/built-ins/TypedArray/prototype/toSorted/this-value-invalid.js +++ b/test/built-ins/TypedArray/prototype/toSorted/this-value-invalid.js @@ -4,9 +4,9 @@ /*--- esid: sec-%typedarray%.prototype.toSorted description: > - TypedArray.prototype.toSorted throws if the receiver is null or undefined + %TypedArray%.prototype.toSorted throws if the receiver is null or undefined info: | - TypedArray.prototype.toSorted ( ) + %TypedArray%.prototype.toSorted ( ) 1. Let O be the this value. 2. Perform ? ValidateTypedArray(O). diff --git a/test/built-ins/TypedArray/prototype/toSpliced/deleteCount-undefined.js b/test/built-ins/TypedArray/prototype/toSpliced/deleteCount-undefined.js index 327cc980c51..9e8a36250a2 100644 --- a/test/built-ins/TypedArray/prototype/toSpliced/deleteCount-undefined.js +++ b/test/built-ins/TypedArray/prototype/toSpliced/deleteCount-undefined.js @@ -2,10 +2,10 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-array.prototype.toSpliced -description: Array.prototype.toSpliced(number, undefined) returns a copy of the original array +esid: sec-%typedarray%.prototype.toSpliced +description: %TypedArray%.prototype.toSpliced(number, undefined) returns a copy of the original array info: | - 22.1.3.25 Array.prototype.toSpliced (start, deleteCount , ...items ) + 22.1.3.25 %TypedArray%.prototype.toSpliced (start, deleteCount , ...items ) ... 4. Let relativeStart be ? ToIntegerOrInfinity(start). diff --git a/test/built-ins/TypedArray/prototype/toSpliced/length-property-ignored.js b/test/built-ins/TypedArray/prototype/toSpliced/length-property-ignored.js index 0273534e4c5..1c82f5f3a02 100644 --- a/test/built-ins/TypedArray/prototype/toSpliced/length-property-ignored.js +++ b/test/built-ins/TypedArray/prototype/toSpliced/length-property-ignored.js @@ -4,9 +4,9 @@ /*--- esid: sec-%typedarray%.prototype.toSpliced description: > - TypedArray.prototype.toSpliced reads the TypedArray length ignoring the .length property + %TypedArray%.prototype.toSpliced reads the TypedArray length ignoring the .length property info: | - TypedArray.prototype.toSpliced ( start, deleteCount, ...items ) + %TypedArray%.prototype.toSpliced ( start, deleteCount, ...items ) ... 4. Let len be O.[[ArrayLength]]. diff --git a/test/built-ins/TypedArray/prototype/with/index-negative.js b/test/built-ins/TypedArray/prototype/with/index-negative.js index c802b39d267..ec7d3075fab 100644 --- a/test/built-ins/TypedArray/prototype/with/index-negative.js +++ b/test/built-ins/TypedArray/prototype/with/index-negative.js @@ -2,11 +2,11 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-array.prototype.with +esid: sec-%typedarray%.prototype.with description: > - Array.prototype.with adds length to index if it's negative. + %TypedArray%.prototype.with adds length to index if it's negative. info: | - Array.prototype.with ( index, value ) + %TypedArray%.prototype.with ( index, value ) ... 2. Let len be ? LengthOfArrayLike(O). diff --git a/test/built-ins/TypedArray/prototype/with/index-smaller-than-minus-length.js b/test/built-ins/TypedArray/prototype/with/index-smaller-than-minus-length.js index 3ddc4e0412b..14c0da21532 100644 --- a/test/built-ins/TypedArray/prototype/with/index-smaller-than-minus-length.js +++ b/test/built-ins/TypedArray/prototype/with/index-smaller-than-minus-length.js @@ -2,11 +2,11 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-array.prototype.with +esid: sec-%typedarray%.prototype.with description: > - Array.prototype.with throws if the (negative) index is smaller than -length. + %TypedArray%.prototype.with throws if the (negative) index is smaller than -length. info: | - Array.prototype.with ( index, value ) + %TypedArray%.prototype.with ( index, value ) ... 2. Let len be ? LengthOfArrayLike(O). From 22631f77e76f2da01709acade6ab0f47cf9d58ee Mon Sep 17 00:00:00 2001 From: Ashley Claymore Date: Wed, 29 Jun 2022 15:26:45 +0100 Subject: [PATCH 32/86] update test description --- .../TypedArray/prototype/toReversed/length-property-ignored.js | 2 +- .../TypedArray/prototype/toSorted/length-property-ignored.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/built-ins/TypedArray/prototype/toReversed/length-property-ignored.js b/test/built-ins/TypedArray/prototype/toReversed/length-property-ignored.js index 5d460b1cfd0..faf2ef78558 100644 --- a/test/built-ins/TypedArray/prototype/toReversed/length-property-ignored.js +++ b/test/built-ins/TypedArray/prototype/toReversed/length-property-ignored.js @@ -4,7 +4,7 @@ /*--- esid: sec-%typedarray%.prototype.toReversed description: > - %TypedArray%.prototype.toReversed creates an empty array if the this value .length is not a positive integer. + %TypedArray%.prototype.toReversed does not read a "length" property info: | %TypedArray%.prototype.toReversed ( ) diff --git a/test/built-ins/TypedArray/prototype/toSorted/length-property-ignored.js b/test/built-ins/TypedArray/prototype/toSorted/length-property-ignored.js index 842266c30db..3da9441837f 100644 --- a/test/built-ins/TypedArray/prototype/toSorted/length-property-ignored.js +++ b/test/built-ins/TypedArray/prototype/toSorted/length-property-ignored.js @@ -4,7 +4,7 @@ /*--- esid: sec-%typedarray%.prototype.toSorted description: > - %TypedArray%.prototype.toSorted creates an empty array if the this value .length is not a positive integer. + %TypedArray%.prototype.toSorted does not read a "length" property info: | %TypedArray%.prototype.toSorted ( comparefn ) From cf785ae9390266f95517b45863812635aeee7140 Mon Sep 17 00:00:00 2001 From: Ashley Claymore Date: Thu, 30 Jun 2022 22:02:29 +0100 Subject: [PATCH 33/86] fixup: yaml is now valid --- .../TypedArray/prototype/toSpliced/deleteCount-undefined.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/built-ins/TypedArray/prototype/toSpliced/deleteCount-undefined.js b/test/built-ins/TypedArray/prototype/toSpliced/deleteCount-undefined.js index 9e8a36250a2..628cfd1132e 100644 --- a/test/built-ins/TypedArray/prototype/toSpliced/deleteCount-undefined.js +++ b/test/built-ins/TypedArray/prototype/toSpliced/deleteCount-undefined.js @@ -3,7 +3,7 @@ /*--- esid: sec-%typedarray%.prototype.toSpliced -description: %TypedArray%.prototype.toSpliced(number, undefined) returns a copy of the original array +description: '%TypedArray%.prototype.toSpliced(number, undefined) returns a copy of the original array' info: | 22.1.3.25 %TypedArray%.prototype.toSpliced (start, deleteCount , ...items ) From 11663bb5f577c342473b3042a5947ee94cd3fbb3 Mon Sep 17 00:00:00 2001 From: Ashley Claymore Date: Wed, 27 Jul 2022 15:26:06 +0100 Subject: [PATCH 34/86] fixup: typo toSpliced -> with --- test/built-ins/TypedArray/prototype/with/metadata/length.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/built-ins/TypedArray/prototype/with/metadata/length.js b/test/built-ins/TypedArray/prototype/with/metadata/length.js index 2cd73a715a0..5e160c6f6c2 100644 --- a/test/built-ins/TypedArray/prototype/with/metadata/length.js +++ b/test/built-ins/TypedArray/prototype/with/metadata/length.js @@ -2,9 +2,9 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-%typedarray%.prototype.toSpliced +esid: sec-%typedarray%.prototype.with description: > - The "length" property of %TypedArray%.prototype.toSpliced + The "length" property of %TypedArray%.prototype.with info: | 17 ECMAScript Standard Built-in Objects @@ -22,7 +22,7 @@ includes: [testTypedArray.js, propertyHelper.js] features: [TypedArray, change-array-by-copy] ---*/ -verifyProperty(TypedArray.prototype.toSpliced, "length", { +verifyProperty(TypedArray.prototype.with, "length", { value: 2, writable: false, enumerable: false, From 48f3a51f809648a29875fa787937c94537049b4f Mon Sep 17 00:00:00 2001 From: Ashley Claymore Date: Wed, 27 Jul 2022 15:30:43 +0100 Subject: [PATCH 35/86] TypedArray toSpliced tests are no longer needed --- ...lamped-between-zero-and-remaining-count.js | 40 ----------------- .../toSpliced/deleteCount-missing.js | 24 ---------- .../toSpliced/deleteCount-undefined.js | 29 ------------ .../prototype/toSpliced/ignores-species.js | 42 ----------------- .../prototype/toSpliced/immutable.js | 19 -------- .../toSpliced/length-property-ignored.js | 45 ------------------- .../prototype/toSpliced/metadata/length.js | 30 ------------- .../prototype/toSpliced/metadata/name.js | 28 ------------ .../toSpliced/metadata/property-descriptor.js | 25 ----------- .../prototype/toSpliced/not-a-constructor.js | 33 -------------- .../start-and-deleteCount-missing.js | 25 ----------- .../start-and-deleteCount-undefineds.js | 29 ------------ .../toSpliced/start-bigger-than-length.js | 25 ----------- .../toSpliced/start-neg-infinity-is-zero.js | 24 ---------- ...tart-neg-less-than-minus-length-is-zero.js | 24 ---------- .../start-neg-subtracted-from-length.js | 24 ---------- ...start-undefined-and-deleteCount-missing.js | 29 ------------ .../prototype/toSpliced/this-value-invalid.js | 35 --------------- 18 files changed, 530 deletions(-) delete mode 100644 test/built-ins/TypedArray/prototype/toSpliced/deleteCount-clamped-between-zero-and-remaining-count.js delete mode 100644 test/built-ins/TypedArray/prototype/toSpliced/deleteCount-missing.js delete mode 100644 test/built-ins/TypedArray/prototype/toSpliced/deleteCount-undefined.js delete mode 100644 test/built-ins/TypedArray/prototype/toSpliced/ignores-species.js delete mode 100644 test/built-ins/TypedArray/prototype/toSpliced/immutable.js delete mode 100644 test/built-ins/TypedArray/prototype/toSpliced/length-property-ignored.js delete mode 100644 test/built-ins/TypedArray/prototype/toSpliced/metadata/length.js delete mode 100644 test/built-ins/TypedArray/prototype/toSpliced/metadata/name.js delete mode 100644 test/built-ins/TypedArray/prototype/toSpliced/metadata/property-descriptor.js delete mode 100644 test/built-ins/TypedArray/prototype/toSpliced/not-a-constructor.js delete mode 100644 test/built-ins/TypedArray/prototype/toSpliced/start-and-deleteCount-missing.js delete mode 100644 test/built-ins/TypedArray/prototype/toSpliced/start-and-deleteCount-undefineds.js delete mode 100644 test/built-ins/TypedArray/prototype/toSpliced/start-bigger-than-length.js delete mode 100644 test/built-ins/TypedArray/prototype/toSpliced/start-neg-infinity-is-zero.js delete mode 100644 test/built-ins/TypedArray/prototype/toSpliced/start-neg-less-than-minus-length-is-zero.js delete mode 100644 test/built-ins/TypedArray/prototype/toSpliced/start-neg-subtracted-from-length.js delete mode 100644 test/built-ins/TypedArray/prototype/toSpliced/start-undefined-and-deleteCount-missing.js delete mode 100644 test/built-ins/TypedArray/prototype/toSpliced/this-value-invalid.js diff --git a/test/built-ins/TypedArray/prototype/toSpliced/deleteCount-clamped-between-zero-and-remaining-count.js b/test/built-ins/TypedArray/prototype/toSpliced/deleteCount-clamped-between-zero-and-remaining-count.js deleted file mode 100644 index 0adada4e52f..00000000000 --- a/test/built-ins/TypedArray/prototype/toSpliced/deleteCount-clamped-between-zero-and-remaining-count.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2021 Igalia. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-%typedarray%.prototype.toSpliced -description: deleteCount is clamped between zero and len - actualStart -info: | - 22.1.3.25 %TypedArray%.prototype.toSpliced (start, deleteCount , ...items ) - - ... - 10. Else, - a. Let insertCount be the number of elements in items. - b. Let dc be ? ToIntegerOrInfinity(deleteCount). - c. Let actualDeleteCount be the result of clamping dc between 0 and len - actualStart. - ... -includes: [testTypedArray.js, compareArray.js] -features: [TypedArray, change-array-by-copy] ----*/ - -testWithTypedArrayConstructors((TA) => { - assert.compareArray( - new TA([0, 1, 2, 3, 4, 5]).toSpliced(2, -1), - [0, 1, 2, 3, 4, 5] - ); - - assert.compareArray( - new TA([0, 1, 2, 3, 4, 5]).toSpliced(-4, -1), - [0, 1, 2, 3, 4, 5] - ); - - assert.compareArray( - new TA([0, 1, 2, 3, 4, 5]).toSpliced(2, 6), - [0, 1] - ); - - assert.compareArray( - new TA([0, 1, 2, 3, 4, 5]).toSpliced(-4, 6), - [0, 1] - ); -}); diff --git a/test/built-ins/TypedArray/prototype/toSpliced/deleteCount-missing.js b/test/built-ins/TypedArray/prototype/toSpliced/deleteCount-missing.js deleted file mode 100644 index 34a4b293d6a..00000000000 --- a/test/built-ins/TypedArray/prototype/toSpliced/deleteCount-missing.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-%typedarray%.prototype.toSpliced -description: '%TypedArray%.prototype.toSpliced deletes the elements after start when called with one argument' -info: | - 22.1.3.25 %TypedArray%.prototype.toSpliced (start, deleteCount , ...items ) - - ... - 9. Else if deleteCount is not present, then - a. Let insertCount be 0. - b. Let actualDeleteCount be len - actualStart. - ... -includes: [testTypedArray.js, compareArray.js] -features: [TypedArray, change-array-by-copy] ----*/ - -testWithTypedArrayConstructors((TA) => { - assert.compareArray( - new TA([1, 2, 3]).toSpliced(1), - [1] - ); -}); diff --git a/test/built-ins/TypedArray/prototype/toSpliced/deleteCount-undefined.js b/test/built-ins/TypedArray/prototype/toSpliced/deleteCount-undefined.js deleted file mode 100644 index 628cfd1132e..00000000000 --- a/test/built-ins/TypedArray/prototype/toSpliced/deleteCount-undefined.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2021 Igalia. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-%typedarray%.prototype.toSpliced -description: '%TypedArray%.prototype.toSpliced(number, undefined) returns a copy of the original array' -info: | - 22.1.3.25 %TypedArray%.prototype.toSpliced (start, deleteCount , ...items ) - - ... - 4. Let relativeStart be ? ToIntegerOrInfinity(start). - ... - 7. Else, let actualStart be min(relativeStart, len). - 8. If start is not present, then - ... - 9. Else if deleteCount is not present, then - a. Let insertCount be 0. - b. Let actualDeleteCount be len - actualStart. - ... -includes: [testTypedArray.js, compareArray.js] -features: [TypedArray, change-array-by-copy] ----*/ - -testWithTypedArrayConstructors((TA) => { - assert.compareArray( - new TA([1, 2, 3]).toSpliced(1, undefined), - [1, 2, 3] - ); -}); diff --git a/test/built-ins/TypedArray/prototype/toSpliced/ignores-species.js b/test/built-ins/TypedArray/prototype/toSpliced/ignores-species.js deleted file mode 100644 index ae963456d6a..00000000000 --- a/test/built-ins/TypedArray/prototype/toSpliced/ignores-species.js +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2021 Igalia. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-%typedarray%.prototype.toSpliced -description: > - %TypedArray%.prototype.toSpliced ignores @@species -info: | - %TypedArray%.prototype.toSpliced ( start, deleteCount, ...items ) - - ... - 12. Let A be ? TypedArraySpeciesCreate(O, Β« 𝔽(len) Β», true). - ... - - TypedArraySpeciesCreate ( exemplar, argumentList [ , noSpeciesOverride ] ) - ... - 2. Let defaultConstructor be the intrinsic object listed in column one of Table 63 for exemplar.[[TypedArrayName]]. - 3. If noSpeciesOverride is true, let constructor be defaultConstructor. - ... -includes: [testTypedArray.js] -features: [TypedArray, change-array-by-copy] ----*/ - -testWithTypedArrayConstructors(TA => { - var ta = new TA([1, 2, 3]); - ta.constructor = TA === Uint8Array ? Int32Array : Uint8Array; - assert.sameValue(Object.getPrototypeOf(ta.toSpliced(0, 2)), TA.prototype); - - ta = new TA([1, 2, 3]); - ta.constructor = { - [Symbol.species]: TA === Uint8Array ? Int32Array : Uint8Array, - }; - assert.sameValue(Object.getPrototypeOf(ta.toSpliced(0, 2)), TA.prototype); - - ta = new TA(); - Object.defineProperty(ta, "constructor", { - get() { - throw new Test262Error("Should not get .constructor"); - } - }); - ta.toSpliced(0, 2); -}); diff --git a/test/built-ins/TypedArray/prototype/toSpliced/immutable.js b/test/built-ins/TypedArray/prototype/toSpliced/immutable.js deleted file mode 100644 index 0a969657339..00000000000 --- a/test/built-ins/TypedArray/prototype/toSpliced/immutable.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-%typedarray%.prototype.toSpliced -description: > - %TypedArray%.prototype.toSpliced does not mutate its this value -includes: [testTypedArray.js, compareArray.js] -features: [TypedArray, change-array-by-copy] ----*/ - -testWithTypedArrayConstructors(TA => { - var ta = new TA([3, 1, 2]); - ta.toSpliced(0, 2); - - assert.compareArray(ta, [3, 1, 2]); - assert.notSameValue(ta.toSpliced(0, 2), ta); - assert.notSameValue(ta.toSpliced(0, 0), ta); -}); diff --git a/test/built-ins/TypedArray/prototype/toSpliced/length-property-ignored.js b/test/built-ins/TypedArray/prototype/toSpliced/length-property-ignored.js deleted file mode 100644 index 1c82f5f3a02..00000000000 --- a/test/built-ins/TypedArray/prototype/toSpliced/length-property-ignored.js +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2021 Igalia. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-%typedarray%.prototype.toSpliced -description: > - %TypedArray%.prototype.toSpliced reads the TypedArray length ignoring the .length property -info: | - %TypedArray%.prototype.toSpliced ( start, deleteCount, ...items ) - - ... - 4. Let len be O.[[ArrayLength]]. - ... -includes: [testTypedArray.js, compareArray.js] -features: [TypedArray, change-array-by-copy] ----*/ - -testWithTypedArrayConstructors(TA => { - var ta = new TA([3, 1, 2]); - Object.defineProperty(ta, "length", { value: 2 }) - var res = ta.toSpliced(0, 0, 5); - assert.compareArray([res[0], res[1], res[2], res[3], res[4]], [5, 3, 1, 2, undefined]) - - ta = new TA([3, 1, 2]); - Object.defineProperty(ta, "length", { value: 5 }); - res = ta.toSpliced(0, 0, 5); - assert.compareArray([res[0], res[1], res[2], res[3], res[4]], [5, 3, 1, 2, undefined]) -}); - -var length; -Object.defineProperty(TypedArray.prototype, "length", { - get: () => length, -}); - -testWithTypedArrayConstructors(TA => { - var ta = new TA([3, 1, 2]); - - length = 2; - var res = ta.toSpliced(0, 0, 5); - assert.compareArray([res[0], res[1], res[2], res[3], res[4]], [5, 3, 1, 2, undefined]) - - length = 5; - res = ta.toSpliced(0, 0, 5); - assert.compareArray([res[0], res[1], res[2], res[3], res[4]], [5, 3, 1, 2, undefined]) -}); diff --git a/test/built-ins/TypedArray/prototype/toSpliced/metadata/length.js b/test/built-ins/TypedArray/prototype/toSpliced/metadata/length.js deleted file mode 100644 index 2cd73a715a0..00000000000 --- a/test/built-ins/TypedArray/prototype/toSpliced/metadata/length.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2021 Igalia. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-%typedarray%.prototype.toSpliced -description: > - The "length" property of %TypedArray%.prototype.toSpliced -info: | - 17 ECMAScript Standard Built-in Objects - - Every built-in function object, including constructors, has a length property - whose value is an integer. Unless otherwise specified, this value is equal to - the largest number of named arguments shown in the subclause headings for the - function description. Optional parameters (which are indicated with brackets: - [ ]) or rest parameters (which are shown using the form Β«...nameΒ») are not - included in the default argument count. - - Unless otherwise specified, the length property of a built-in function object - has the attributes { [[Writable]]: false, [[Enumerable]]: false, - [[Configurable]]: true }. -includes: [testTypedArray.js, propertyHelper.js] -features: [TypedArray, change-array-by-copy] ----*/ - -verifyProperty(TypedArray.prototype.toSpliced, "length", { - value: 2, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/TypedArray/prototype/toSpliced/metadata/name.js b/test/built-ins/TypedArray/prototype/toSpliced/metadata/name.js deleted file mode 100644 index a00696be4f6..00000000000 --- a/test/built-ins/TypedArray/prototype/toSpliced/metadata/name.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2021 Igalia. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-%typedarray%.prototype.toSpliced -description: > - %TypedArray%.prototype.toSpliced.name is "toSpliced". -info: | - %TypedArray%.prototype.toSpliced ( start, deleteCount, ...items ) - - 17 ECMAScript Standard Built-in Objects: - Every built-in Function object, including constructors, that is not - identified as an anonymous function has a name property whose value - is a String. - - Unless otherwise specified, the name property of a built-in Function - object, if it exists, has the attributes { [[Writable]]: false, - [[Enumerable]]: false, [[Configurable]]: true }. -includes: [testTypedArray.js, propertyHelper.js] -features: [TypedArray, change-array-by-copy] ----*/ - -verifyProperty(TypedArray.prototype.toSpliced, "name", { - value: "toSpliced", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/TypedArray/prototype/toSpliced/metadata/property-descriptor.js b/test/built-ins/TypedArray/prototype/toSpliced/metadata/property-descriptor.js deleted file mode 100644 index 05335b41148..00000000000 --- a/test/built-ins/TypedArray/prototype/toSpliced/metadata/property-descriptor.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-%typedarray%.prototype.toSpliced -description: > - "toSpliced" property of %TypedArray%.prototype -info: | - 17 ECMAScript Standard Built-in Objects - - Every other data property described in clauses 18 through 26 and in Annex B.2 - has the attributes { [[Writable]]: true, [[Enumerable]]: false, - [[Configurable]]: true } unless otherwise specified. -includes: [testTypedArray.js, propertyHelper.js] -features: [TypedArray, change-array-by-copy] ----*/ - -assert.sameValue(typeof TypedArray.prototype.toSpliced, "function", "typeof"); - -verifyProperty(TypedArray.prototype, "toSpliced", { - value: TypedArray.prototype.toSpliced, - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/TypedArray/prototype/toSpliced/not-a-constructor.js b/test/built-ins/TypedArray/prototype/toSpliced/not-a-constructor.js deleted file mode 100644 index 26f5e311ed8..00000000000 --- a/test/built-ins/TypedArray/prototype/toSpliced/not-a-constructor.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-ecmascript-standard-built-in-objects -description: > - %TypedArray%.prototype.toSpliced does not implement [[Construct]], is not new-able -info: | - ECMAScript Function Objects - - Built-in function objects that are not identified as constructors do not - implement the [[Construct]] internal method unless otherwise specified in - the description of a particular function. - - sec-evaluatenew - - ... - 7. If IsConstructor(constructor) is false, throw a TypeError exception. - ... -includes: [isConstructor.js, testTypedArray.js] -features: [TypedArray, change-array-by-copy, Reflect.construct] ----*/ - -assert.sameValue( - isConstructor(TypedArray.prototype.toSpliced), - false, - 'isConstructor(TypedArray.prototype.toSpliced) must return false' -); - -assert.throws(TypeError, () => { - new TypedArray.prototype.toSpliced(); -}, '`new %TypedArray%.prototype.toSpliced()` throws TypeError'); - diff --git a/test/built-ins/TypedArray/prototype/toSpliced/start-and-deleteCount-missing.js b/test/built-ins/TypedArray/prototype/toSpliced/start-and-deleteCount-missing.js deleted file mode 100644 index 12d5696b028..00000000000 --- a/test/built-ins/TypedArray/prototype/toSpliced/start-and-deleteCount-missing.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-%typedarray%.prototype.toSpliced -description: '%TypedArray%.prototype.toSpliced returns a copy of the TypedArray if called with zero arguments' -info: | - 22.1.3.25 %TypedArray%.prototype.toSpliced (start, deleteCount , ...items ) - - ... - 4. Let relativeStart be ? ToIntegerOrInfinity(start). - ... - 7. Else, let actualStart be min(relativeStart, len). - 8. If start is not present, then - a. Let actualDeleteCount be 0. - ... -includes: [testTypedArray.js, compareArray.js] -features: [TypedArray, change-array-by-copy] ----*/ - -testWithTypedArrayConstructors((TA) => { - var result = new TA([1, 2, 3]).toSpliced(); - - assert.compareArray(result, [1, 2, 3]); -}); diff --git a/test/built-ins/TypedArray/prototype/toSpliced/start-and-deleteCount-undefineds.js b/test/built-ins/TypedArray/prototype/toSpliced/start-and-deleteCount-undefineds.js deleted file mode 100644 index b9752bca1ad..00000000000 --- a/test/built-ins/TypedArray/prototype/toSpliced/start-and-deleteCount-undefineds.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2021 Igalia. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-%typedarray%.prototype.toSpliced -description: '%TypedArray%.prototype.toSpliced(undefined, undefined) returns a copy of the original TypedArray' -info: | - 22.1.3.25 %TypedArray%.prototype.toSpliced ( start, deleteCount , ...items ) - - ... - 4. Let relativeStart be ? ToIntegerOrInfinity(start). - ... - 7. Else, let actualStart be min(relativeStart, len). - 8. If start is not present, then - a. Let insertCount be 0. - b. Let actualDeleteCount be 0. - 9. Else if deleteCount is not present, then - a. Let insertCount be 0. - b. Let actualDeleteCount be len - actualStart. - ... -includes: [testTypedArray.js, compareArray.js] -features: [TypedArray, change-array-by-copy] ----*/ - -testWithTypedArrayConstructors((TA) => { - var result = new TA([1, 2, 3]).toSpliced(undefined, undefined); - - assert.compareArray(result, [1, 2, 3]); -}); diff --git a/test/built-ins/TypedArray/prototype/toSpliced/start-bigger-than-length.js b/test/built-ins/TypedArray/prototype/toSpliced/start-bigger-than-length.js deleted file mode 100644 index b4f91e39d04..00000000000 --- a/test/built-ins/TypedArray/prototype/toSpliced/start-bigger-than-length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-%typedarray%.prototype.toSpliced -description: > - %TypedArray%.prototype.toSpliced converts the this value length to a number. -info: | - %TypedArray%.prototype.toSpliced ( start, deleteCount, ...items ) - - ... - 3. Let len be O.[[ArrayLength]]. - 4. Let relativeStart be ? ToIntegerOrInfinity(start). - 5. If relativeStart is -∞, let actualStart be 0. - 6. Else if relativeStart < 0, let actualStart be max(len + relativeStart, 0). - 7. Else, let actualStart be min(relativeStart, len). - ... -includes: [testTypedArray.js, compareArray.js] -features: [TypedArray, change-array-by-copy] ----*/ - -testWithTypedArrayConstructors((TA) => { - var result = new TA([0, 1, 2, 3, 4]).toSpliced(10, 1, 5, 6); - assert.compareArray(result, [0, 1, 2, 3, 4, 5, 6]); -}); diff --git a/test/built-ins/TypedArray/prototype/toSpliced/start-neg-infinity-is-zero.js b/test/built-ins/TypedArray/prototype/toSpliced/start-neg-infinity-is-zero.js deleted file mode 100644 index 952c3fb3e52..00000000000 --- a/test/built-ins/TypedArray/prototype/toSpliced/start-neg-infinity-is-zero.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-%typedarray%.prototype.toSpliced -description: > - %TypedArray%.prototype.toSpliced converts the this value length to a number. -info: | - %TypedArray%.prototype.toSpliced ( start, deleteCount, ...items ) - - ... - 3. Let len be O.[[ArrayLength]]. - 4. Let relativeStart be ? ToIntegerOrInfinity(start). - 5. If relativeStart is -∞, let actualStart be 0. - 6. Else if relativeStart < 0, let actualStart be max(len + relativeStart, 0). - ... -includes: [testTypedArray.js, compareArray.js] -features: [TypedArray, change-array-by-copy] ----*/ - -testWithTypedArrayConstructors((TA) => { - var result = new TA([0, 1, 2, 3, 4]).toSpliced(-Infinity, 2); - assert.compareArray(result, [2, 3, 4]); -}); diff --git a/test/built-ins/TypedArray/prototype/toSpliced/start-neg-less-than-minus-length-is-zero.js b/test/built-ins/TypedArray/prototype/toSpliced/start-neg-less-than-minus-length-is-zero.js deleted file mode 100644 index 6f66dcbcbae..00000000000 --- a/test/built-ins/TypedArray/prototype/toSpliced/start-neg-less-than-minus-length-is-zero.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-%typedarray%.prototype.toSpliced -description: > - %TypedArray%.prototype.toSpliced converts the this value length to a number. -info: | - %TypedArray%.prototype.toSpliced ( start, deleteCount, ...items ) - - ... - 3. Let len be O.[[ArrayLength]]. - 4. Let relativeStart be ? ToIntegerOrInfinity(start). - 5. If relativeStart is -∞, let actualStart be 0. - 6. Else if relativeStart < 0, let actualStart be max(len + relativeStart, 0). - ... -includes: [testTypedArray.js, compareArray.js] -features: [TypedArray, change-array-by-copy] ----*/ - -testWithTypedArrayConstructors((TA) => { - var result = new TA([0, 1, 2, 3, 4]).toSpliced(-20, 2); - assert.compareArray(result, [2, 3, 4]); -}); diff --git a/test/built-ins/TypedArray/prototype/toSpliced/start-neg-subtracted-from-length.js b/test/built-ins/TypedArray/prototype/toSpliced/start-neg-subtracted-from-length.js deleted file mode 100644 index 2f66b793ebe..00000000000 --- a/test/built-ins/TypedArray/prototype/toSpliced/start-neg-subtracted-from-length.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-%typedarray%.prototype.toSpliced -description: > - %TypedArray%.prototype.toSpliced converts the this value length to a number. -info: | - %TypedArray%.prototype.toSpliced ( start, deleteCount, ...items ) - - ... - 3. Let len be O.[[ArrayLength]]. - 4. Let relativeStart be ? ToIntegerOrInfinity(start). - 5. If relativeStart is -∞, let actualStart be 0. - 6. Else if relativeStart < 0, let actualStart be max(len + relativeStart, 0). - ... -includes: [testTypedArray.js, compareArray.js] -features: [TypedArray, change-array-by-copy] ----*/ - -testWithTypedArrayConstructors((TA) => { - var result = new TA([0, 1, 2, 3, 4]).toSpliced(-3, 2); - assert.compareArray(result, [0, 1, 4]); -}); diff --git a/test/built-ins/TypedArray/prototype/toSpliced/start-undefined-and-deleteCount-missing.js b/test/built-ins/TypedArray/prototype/toSpliced/start-undefined-and-deleteCount-missing.js deleted file mode 100644 index 63b8c7e980f..00000000000 --- a/test/built-ins/TypedArray/prototype/toSpliced/start-undefined-and-deleteCount-missing.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2021 Igalia. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-%typedarray%.prototype.toSpliced -description: '%TypedArray%.prototype.toSpliced(undefined) returns an empty array' -info: | - 22.1.3.25 %TypedArray%.prototype.toSpliced ( start, deleteCount , ...items ) - - ... - 4. Let relativeStart be ? ToIntegerOrInfinity(start). - ... - 7. Else, let actualStart be min(relativeStart, len). - ... - 8. If start is not present, then - a. Let insertCount be 0. - b. Let actualDeleteCount be 0. - 8. Else if deleteCount is not present, then - a. Let insertCount be 0. - b. Let actualDeleteCount be len - actualStart. - ... -includes: [testTypedArray.js, compareArray.js] -features: [TypedArray, change-array-by-copy] ----*/ - -testWithTypedArrayConstructors((TA) => { - var result = new TA([1, 2, 3]).toSpliced(undefined); - assert.compareArray(result, []); -}); diff --git a/test/built-ins/TypedArray/prototype/toSpliced/this-value-invalid.js b/test/built-ins/TypedArray/prototype/toSpliced/this-value-invalid.js deleted file mode 100644 index 2505ebdfd26..00000000000 --- a/test/built-ins/TypedArray/prototype/toSpliced/this-value-invalid.js +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2021 Igalia. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-%typedarray%.prototype.toSpliced -description: > - %TypedArray%.prototype.toSpliced throws if the receiver is null or undefined -info: | - %TypedArray%.prototype.toSpliced ( start, deleteCount , ...items ) - - 1. Let O be the this value. - 2. Perform ? ValidateTypedArray(O). - ... -includes: [testTypedArray.js] -features: [TypedArray, change-array-by-copy] ----*/ - -var invalidValues = { - 'null': null, - 'undefined': undefined, - 'true': true, - '"abc"': "abc", - '12': 12, - 'Symbol()': Symbol(), - '[1, 2, 3]': [1, 2, 3], - '{ 0: 1, 1: 2, 2: 3, length: 3 }': { 0: 1, 1: 2, 2: 3, length: 3 }, - 'Uint8Array.prototype': Uint8Array.prototype, -}; - -Object.keys(invalidValues).forEach(desc => { - var value = invalidValues[desc]; - assert.throws(TypeError, () => { - TypedArray.prototype.toSpliced.call(value); - }, `${desc} is not a valid TypedArray`); -}); From 23b7e344b8012079606ee69b4f523af5e69b5078 Mon Sep 17 00:00:00 2001 From: Ashley Claymore Date: Fri, 5 Aug 2022 16:37:46 +0100 Subject: [PATCH 36/86] BigIntTypedArray::with early type coercion tested --- .../with/BigInt/early-type-coercion-bigint.js | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 test/built-ins/TypedArray/prototype/with/BigInt/early-type-coercion-bigint.js diff --git a/test/built-ins/TypedArray/prototype/with/BigInt/early-type-coercion-bigint.js b/test/built-ins/TypedArray/prototype/with/BigInt/early-type-coercion-bigint.js new file mode 100644 index 00000000000..51ca9a7231a --- /dev/null +++ b/test/built-ins/TypedArray/prototype/with/BigInt/early-type-coercion-bigint.js @@ -0,0 +1,31 @@ +// Copyright (C) 2021 Igalia. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.with +description: > + %TypedArray%.prototype.with invokes ToNumber before copying +info: | + %TypedArray%.prototype.with ( index, value ) + + ... + 7. If _O_.[[ContentType]] is ~BigInt~, set _value_ to ? ToBigInt(_value_). + 8. Else, set _value_ to ? ToNumber(_value_). + ... +features: [BigInt, TypedArray, change-array-by-copy] +includes: [testBigIntTypedArray.js, compareArray.js] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + var arr = new TA([0n, 1n, 2n]); + + var value = { + valueOf() { + arr[0] = 3n; + return 4n; + } + }; + + assert.compareArray(arr.with(1, value), [3n, 4n, 2n]); + assert.compareArray(arr, [3n, 1n, 2n]); +}); From 4064cce1c500241440bd53fb3a440eea27000798 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 4 Oct 2022 15:42:26 -0700 Subject: [PATCH 37/86] Update test/built-ins/Array/prototype/toSorted/comparefn-called-after-get-elements.js Co-authored-by: Ms2ger --- .../comparefn-called-after-get-elements.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/test/built-ins/Array/prototype/toSorted/comparefn-called-after-get-elements.js b/test/built-ins/Array/prototype/toSorted/comparefn-called-after-get-elements.js index b58e763cf60..6780946d275 100644 --- a/test/built-ins/Array/prototype/toSorted/comparefn-called-after-get-elements.js +++ b/test/built-ins/Array/prototype/toSorted/comparefn-called-after-get-elements.js @@ -6,18 +6,19 @@ esid: sec-array.prototype.toSorted description: > Array.prototype.toSorted reads all the array elements before calling compareFn info: | - Array.prototype.toSorted ( compareFn ) + SortIndexedProperties ( obj, len, SortCompare, skipHoles ) ... - 6. Repeat, while k < len, + 3. Repeat, while k < len, a. Let Pk be ! ToString(𝔽(k)). - b. Let kValue be ? Get(O, Pk). - c. Append kValue to items. - d. Set k to k + 1. - 7. Sort items using an implementation-defined sequence of + ... + i. Let kValue be ? Get(O, Pk). + ... + 4. Sort items using an implementation-defined sequence of calls to SortCompare. If any such call returns an abrupt completion, stop before performing any further calls to - SortCompare or steps in this algorithm and return that completion. + SortCompare or steps in this algorithm and return that + Completion Record. ... features: [change-array-by-copy] includes: [compareArray.js] From 5bf00ff75e7fc0cf02495ca84c482e4f5e90d0e5 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 4 Oct 2022 15:43:22 -0700 Subject: [PATCH 38/86] Update test/built-ins/Array/prototype/toSorted/comparefn-not-a-function.js Co-authored-by: Ms2ger --- .../Array/prototype/toSorted/comparefn-not-a-function.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/built-ins/Array/prototype/toSorted/comparefn-not-a-function.js b/test/built-ins/Array/prototype/toSorted/comparefn-not-a-function.js index 93332a569df..95b8ee1b6f6 100644 --- a/test/built-ins/Array/prototype/toSorted/comparefn-not-a-function.js +++ b/test/built-ins/Array/prototype/toSorted/comparefn-not-a-function.js @@ -25,9 +25,9 @@ var invalidComparators = [null, true, false, "", /a/g, 42, [], {}, Symbol()]; for (var i = 0; i < invalidComparators.length; i++) { assert.throws(TypeError, function() { [1].toSorted(invalidComparators[i]); - }, String(invalidComparators[i])); + }, String(invalidComparators[i]) + " on an array"); assert.throws(TypeError, function() { Array.prototype.toSorted.call(getLengthThrow, invalidComparators[i]); - }, String(invalidComparators[i])); + }, String(invalidComparators[i]) + " on an object whose 'length' throws"); } From e8ac5c247f65f2e9b381ba54c2018a1af02fe0b2 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 4 Oct 2022 15:43:31 -0700 Subject: [PATCH 39/86] Update test/built-ins/Array/prototype/toSorted/this-value-boolean.js Co-authored-by: Ms2ger --- test/built-ins/Array/prototype/toSorted/this-value-boolean.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/built-ins/Array/prototype/toSorted/this-value-boolean.js b/test/built-ins/Array/prototype/toSorted/this-value-boolean.js index ec163165116..6cecceb10f2 100644 --- a/test/built-ins/Array/prototype/toSorted/this-value-boolean.js +++ b/test/built-ins/Array/prototype/toSorted/this-value-boolean.js @@ -4,7 +4,7 @@ /*--- esid: sec-array.prototype.toSorted description: > - Array.prototype.toSorted throws if the receiver is null or undefined + Array.prototype.toSorted converts booleans to objects info: | Array.prototype.toSorted ( compareFn ) From 6c9c8538f83c569ddeb76f3d594a25cc33b955e7 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 4 Oct 2022 15:45:23 -0700 Subject: [PATCH 40/86] Update test/built-ins/Array/prototype/toSpliced/deleteCount-clamped-between-zero-and-remaining-count.js Co-authored-by: Ms2ger --- .../deleteCount-clamped-between-zero-and-remaining-count.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/built-ins/Array/prototype/toSpliced/deleteCount-clamped-between-zero-and-remaining-count.js b/test/built-ins/Array/prototype/toSpliced/deleteCount-clamped-between-zero-and-remaining-count.js index 7b6bdebcff4..59a809d6a01 100644 --- a/test/built-ins/Array/prototype/toSpliced/deleteCount-clamped-between-zero-and-remaining-count.js +++ b/test/built-ins/Array/prototype/toSpliced/deleteCount-clamped-between-zero-and-remaining-count.js @@ -9,7 +9,7 @@ info: | ... 10. Else, - a. Let actualDeleteCount be len - actualStart. + a. Let dc be ? ToIntegerOrInfinity(deleteCount). b. Let actualDeleteCount be the result of clamping dc between 0 and len - actualStart. ... features: [change-array-by-copy] From 29bd33f94880df209397bbe70312654c024faa9a Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 4 Oct 2022 15:49:03 -0700 Subject: [PATCH 41/86] Update test/built-ins/Array/prototype/toSpliced/discarded-element-not-read.js Co-authored-by: Ms2ger --- .../Array/prototype/toSpliced/discarded-element-not-read.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/built-ins/Array/prototype/toSpliced/discarded-element-not-read.js b/test/built-ins/Array/prototype/toSpliced/discarded-element-not-read.js index c748ef0b966..b57fb438cd9 100644 --- a/test/built-ins/Array/prototype/toSpliced/discarded-element-not-read.js +++ b/test/built-ins/Array/prototype/toSpliced/discarded-element-not-read.js @@ -3,7 +3,7 @@ /*--- esid: sec-array.prototype.toSpliced -description: Array.prototype.toSpliced(undefined, undefined) returns a copy of the original array +description: Array.prototype.toSpliced does not Get the discarded elements in the original array info: | 22.1.3.25 Array.prototype.toSpliced (start, deleteCount , ...items ) From 9e2464143e9ef63a8050623a195167db397509df Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 4 Oct 2022 15:49:26 -0700 Subject: [PATCH 42/86] Update test/built-ins/Array/prototype/toSpliced/elements-read-in-order.js Co-authored-by: Ms2ger --- .../Array/prototype/toSpliced/elements-read-in-order.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/built-ins/Array/prototype/toSpliced/elements-read-in-order.js b/test/built-ins/Array/prototype/toSpliced/elements-read-in-order.js index b9987db6b40..ab92b1a9048 100644 --- a/test/built-ins/Array/prototype/toSpliced/elements-read-in-order.js +++ b/test/built-ins/Array/prototype/toSpliced/elements-read-in-order.js @@ -3,7 +3,7 @@ /*--- esid: sec-array.prototype.toSpliced -description: Array.prototype.toSpliced(undefined, undefined) returns a copy of the original array +description: Array.prototype.toSpliced reads the items of the original array in order info: | 22.1.3.25 Array.prototype.toSpliced (start, deleteCount , ...items ) From 11aa06f54612f3a226b76fe383c9ae0ca82641e9 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 4 Oct 2022 16:02:07 -0700 Subject: [PATCH 43/86] Update test/built-ins/TypedArray/prototype/with/index-negative.js Co-authored-by: Ms2ger --- test/built-ins/TypedArray/prototype/with/index-negative.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/built-ins/TypedArray/prototype/with/index-negative.js b/test/built-ins/TypedArray/prototype/with/index-negative.js index ec7d3075fab..43d141b4b8a 100644 --- a/test/built-ins/TypedArray/prototype/with/index-negative.js +++ b/test/built-ins/TypedArray/prototype/with/index-negative.js @@ -23,5 +23,6 @@ testWithTypedArrayConstructors(TA => { assert.compareArray(arr.with(-1, 4), [0, 1, 4]); assert.compareArray(arr.with(-3, 4), [4, 1, 2]); + // -0 is not negative. assert.compareArray(arr.with(-0, 4), [4, 1, 2]); }); From af1ba685df77bd78c705b6c7518795cd602f9a01 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 4 Oct 2022 17:14:56 -0700 Subject: [PATCH 44/86] Update test/built-ins/Array/prototype/toSorted/comparefn-stop-after-error.js Co-authored-by: Ms2ger --- .../prototype/toSorted/comparefn-stop-after-error.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/test/built-ins/Array/prototype/toSorted/comparefn-stop-after-error.js b/test/built-ins/Array/prototype/toSorted/comparefn-stop-after-error.js index e3b1ddc4ff9..cfe729fcdb0 100644 --- a/test/built-ins/Array/prototype/toSorted/comparefn-stop-after-error.js +++ b/test/built-ins/Array/prototype/toSorted/comparefn-stop-after-error.js @@ -30,15 +30,13 @@ assert.throws(Test262Error, function() { }); assert.sameValue(called, false); -called = false; +called = 0; assert.throws(Test262Error, function() { - var first = true; [1, 2, 3].toSorted(() => { - if (first) { - first = false; + ++called; + if (called === 1) { throw new Test262Error(); } - called = true; }); }); -assert.sameValue(called, false); +assert.sameValue(called, 1); From eb3c90c869e0274eb8014e6de46de92b49d92462 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 4 Oct 2022 17:18:20 -0700 Subject: [PATCH 45/86] Update test/built-ins/Array/prototype/toSorted/ignores-species.js Co-authored-by: Ms2ger --- test/built-ins/Array/prototype/toSorted/ignores-species.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/built-ins/Array/prototype/toSorted/ignores-species.js b/test/built-ins/Array/prototype/toSorted/ignores-species.js index 18ca34229c4..3e067ec6303 100644 --- a/test/built-ins/Array/prototype/toSorted/ignores-species.js +++ b/test/built-ins/Array/prototype/toSorted/ignores-species.js @@ -4,7 +4,7 @@ /*--- esid: sec-array.prototype.toSorted description: > - Array.prototype.toSorted throws if the receiver is null or undefined + Array.prototype.toSorted ignores @@species info: | Array.prototype.toSorted ( compareFn ) From 9e1bd109a32034cddda41d072f8d0b712879009b Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 4 Oct 2022 17:18:35 -0700 Subject: [PATCH 46/86] Update test/built-ins/Array/prototype/toSpliced/ignores-species.js Co-authored-by: Ms2ger --- test/built-ins/Array/prototype/toSpliced/ignores-species.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/built-ins/Array/prototype/toSpliced/ignores-species.js b/test/built-ins/Array/prototype/toSpliced/ignores-species.js index 1343096e0af..ba1e94554a9 100644 --- a/test/built-ins/Array/prototype/toSpliced/ignores-species.js +++ b/test/built-ins/Array/prototype/toSpliced/ignores-species.js @@ -4,7 +4,7 @@ /*--- esid: sec-array.prototype.toSpliced description: > - Array.prototype.toSpliced throws if the receiver is null or undefined + Array.prototype.toSpliced ignores @@species info: | Array.prototype.toSpliced ( start, deleteCount, ...items ) From f9b6b27cf8fdb3d1fdb0ce72f9631fe8f5c1edc1 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 4 Oct 2022 17:59:28 -0700 Subject: [PATCH 47/86] Update test/built-ins/Array/prototype/toSpliced/not-a-constructor.js Co-authored-by: Ms2ger --- test/built-ins/Array/prototype/toSpliced/not-a-constructor.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/built-ins/Array/prototype/toSpliced/not-a-constructor.js b/test/built-ins/Array/prototype/toSpliced/not-a-constructor.js index 7abcc9a6860..8b039747e29 100644 --- a/test/built-ins/Array/prototype/toSpliced/not-a-constructor.js +++ b/test/built-ins/Array/prototype/toSpliced/not-a-constructor.js @@ -30,4 +30,3 @@ assert.sameValue( assert.throws(TypeError, () => { new Array.prototype.toSpliced(); }, '`new Array.prototype.toSpliced()` throws TypeError'); - From dcb2706a6dccd845c259d093a527f4ab1e0387eb Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 4 Oct 2022 18:05:16 -0700 Subject: [PATCH 48/86] Update test/built-ins/Array/prototype/toSpliced/start-bigger-than-length.js Co-authored-by: Ms2ger --- .../Array/prototype/toSpliced/start-bigger-than-length.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/built-ins/Array/prototype/toSpliced/start-bigger-than-length.js b/test/built-ins/Array/prototype/toSpliced/start-bigger-than-length.js index b9a5c5acf4b..ad9f9d06381 100644 --- a/test/built-ins/Array/prototype/toSpliced/start-bigger-than-length.js +++ b/test/built-ins/Array/prototype/toSpliced/start-bigger-than-length.js @@ -4,7 +4,7 @@ /*--- esid: sec-array.prototype.toSpliced description: > - Array.prototype.toSpliced converts the this value length to a number. + Array.prototype.toSpliced clamps the start argument to the this value length. info: | Array.prototype.toSpliced ( start, deleteCount, ...items ) From ce64f8ebacbd7a033a79d4dff28c4214b41cc5e6 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 4 Oct 2022 18:07:28 -0700 Subject: [PATCH 49/86] Update test/built-ins/Array/prototype/toSpliced/start-neg-infinity-is-zero.js Co-authored-by: Ms2ger --- .../Array/prototype/toSpliced/start-neg-infinity-is-zero.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/built-ins/Array/prototype/toSpliced/start-neg-infinity-is-zero.js b/test/built-ins/Array/prototype/toSpliced/start-neg-infinity-is-zero.js index 3fcac731d5c..14c05f64ef7 100644 --- a/test/built-ins/Array/prototype/toSpliced/start-neg-infinity-is-zero.js +++ b/test/built-ins/Array/prototype/toSpliced/start-neg-infinity-is-zero.js @@ -4,7 +4,7 @@ /*--- esid: sec-array.prototype.toSpliced description: > - Array.prototype.toSpliced converts the this value length to a number. + Array.prototype.toSpliced treats negative Infinity as zero for start. info: | Array.prototype.toSpliced ( start, deleteCount, ...items ) From 8844e396dee5f8baa315e2d138bb3741b45609a7 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 4 Oct 2022 18:07:49 -0700 Subject: [PATCH 50/86] Update test/built-ins/Array/prototype/toSpliced/start-neg-less-than-minus-length-is-zero.js Co-authored-by: Ms2ger --- .../toSpliced/start-neg-less-than-minus-length-is-zero.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/built-ins/Array/prototype/toSpliced/start-neg-less-than-minus-length-is-zero.js b/test/built-ins/Array/prototype/toSpliced/start-neg-less-than-minus-length-is-zero.js index ee52077cbad..f0b49fc2ca4 100644 --- a/test/built-ins/Array/prototype/toSpliced/start-neg-less-than-minus-length-is-zero.js +++ b/test/built-ins/Array/prototype/toSpliced/start-neg-less-than-minus-length-is-zero.js @@ -4,7 +4,7 @@ /*--- esid: sec-array.prototype.toSpliced description: > - Array.prototype.toSpliced converts the this value length to a number. + Array.prototype.toSpliced treats a value smaller than -length as zero for start. info: | Array.prototype.toSpliced ( start, deleteCount, ...items ) From b98572ce2b728da4d205fddb2001dfcae93bea89 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 4 Oct 2022 18:08:23 -0700 Subject: [PATCH 51/86] Update test/built-ins/Array/prototype/toSpliced/start-neg-subtracted-from-length.js Co-authored-by: Ms2ger --- .../prototype/toSpliced/start-neg-subtracted-from-length.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/built-ins/Array/prototype/toSpliced/start-neg-subtracted-from-length.js b/test/built-ins/Array/prototype/toSpliced/start-neg-subtracted-from-length.js index 7058ed14564..b0d5264ab83 100644 --- a/test/built-ins/Array/prototype/toSpliced/start-neg-subtracted-from-length.js +++ b/test/built-ins/Array/prototype/toSpliced/start-neg-subtracted-from-length.js @@ -4,7 +4,7 @@ /*--- esid: sec-array.prototype.toSpliced description: > - Array.prototype.toSpliced converts the this value length to a number. + Array.prototype.toSpliced treats a negative start as relative to the end. info: | Array.prototype.toSpliced ( start, deleteCount, ...items ) From 8b3ddd231f1fb6772c89f81f368c02f94beeb6c3 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 4 Oct 2022 18:08:48 -0700 Subject: [PATCH 52/86] Update test/built-ins/Array/prototype/toSpliced/this-value-boolean.js Co-authored-by: Ms2ger --- test/built-ins/Array/prototype/toSpliced/this-value-boolean.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/built-ins/Array/prototype/toSpliced/this-value-boolean.js b/test/built-ins/Array/prototype/toSpliced/this-value-boolean.js index 7111b2d443b..e9de5626f8c 100644 --- a/test/built-ins/Array/prototype/toSpliced/this-value-boolean.js +++ b/test/built-ins/Array/prototype/toSpliced/this-value-boolean.js @@ -4,7 +4,7 @@ /*--- esid: sec-array.prototype.toSpliced description: > - Array.prototype.toSpliced throws if the receiver is null or undefined + Array.prototype.toSpliced converts booleans to objects info: | Array.prototype.toSpliced ( start, deleteCount, ...items ) From 9847c331b749877987fe893700d0c91492cd9beb Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 4 Oct 2022 18:09:13 -0700 Subject: [PATCH 53/86] Update test/built-ins/Array/prototype/with/index-bigger-or-eq-than-length.js Co-authored-by: Ms2ger --- .../Array/prototype/with/index-bigger-or-eq-than-length.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/built-ins/Array/prototype/with/index-bigger-or-eq-than-length.js b/test/built-ins/Array/prototype/with/index-bigger-or-eq-than-length.js index 5d0db5e9e74..3cd03d25ead 100644 --- a/test/built-ins/Array/prototype/with/index-bigger-or-eq-than-length.js +++ b/test/built-ins/Array/prototype/with/index-bigger-or-eq-than-length.js @@ -2,11 +2,11 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-%typedarray%.prototype.with +esid: sec-array.prototype.with description: > - %TypedArray%.prototype.with throws if the index is bigger than or equal to the array length. + Array.prototype.with throws if the index is bigger than or equal to the array length. info: | - %TypedArray%.prototype.with ( index, value ) + Array.prototype.with ( index, value ) ... 2. Let len be ? LengthOfArrayLike(O). From ed6b418198f2ce167f7ff2aa750442ddfb0d7fae Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 4 Oct 2022 18:13:22 -0700 Subject: [PATCH 54/86] Update test/built-ins/TypedArray/prototype/toReversed/ignores-species.js Co-authored-by: Ms2ger --- .../TypedArray/prototype/toReversed/ignores-species.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/built-ins/TypedArray/prototype/toReversed/ignores-species.js b/test/built-ins/TypedArray/prototype/toReversed/ignores-species.js index ed1ad0cfafe..0362ecad72b 100644 --- a/test/built-ins/TypedArray/prototype/toReversed/ignores-species.js +++ b/test/built-ins/TypedArray/prototype/toReversed/ignores-species.js @@ -9,7 +9,7 @@ info: | %TypedArray%.prototype.toReversed ( ) ... - 5. Let A be ? TypedArraySpeciesCreate(O, Β« 𝔽(len) Β», true). + 4. Let A be ? TypedArrayCreateSameType(O, Β« 𝔽(length) Β»). ... TypedArraySpeciesCreate ( exemplar, argumentList [ , noSpeciesOverride ] ) From f0faa9d8e0c3262a2800c9388f37960087b44076 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 4 Oct 2022 18:14:53 -0700 Subject: [PATCH 55/86] Update test/built-ins/TypedArray/prototype/toReversed/length-property-ignored.js Co-authored-by: Ms2ger --- .../TypedArray/prototype/toReversed/length-property-ignored.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/built-ins/TypedArray/prototype/toReversed/length-property-ignored.js b/test/built-ins/TypedArray/prototype/toReversed/length-property-ignored.js index faf2ef78558..5ba55a527f1 100644 --- a/test/built-ins/TypedArray/prototype/toReversed/length-property-ignored.js +++ b/test/built-ins/TypedArray/prototype/toReversed/length-property-ignored.js @@ -9,7 +9,7 @@ info: | %TypedArray%.prototype.toReversed ( ) ... - 3. Let len be O.[[ArrayLength]]. + 3. Let length be O.[[ArrayLength]]. ... includes: [testTypedArray.js, compareArray.js] features: [TypedArray, change-array-by-copy] From 2a79ead1c7f913d27ca44bac6768d77029c5a2bd Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 4 Oct 2022 18:20:19 -0700 Subject: [PATCH 56/86] Update test/built-ins/TypedArray/prototype/toSorted/comparefn-not-a-function.js Co-authored-by: Ms2ger --- .../TypedArray/prototype/toSorted/comparefn-not-a-function.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/built-ins/TypedArray/prototype/toSorted/comparefn-not-a-function.js b/test/built-ins/TypedArray/prototype/toSorted/comparefn-not-a-function.js index 0a88db9fe52..59f96b6aa12 100644 --- a/test/built-ins/TypedArray/prototype/toSorted/comparefn-not-a-function.js +++ b/test/built-ins/TypedArray/prototype/toSorted/comparefn-not-a-function.js @@ -15,7 +15,7 @@ includes: [testTypedArray.js] features: [TypedArray, change-array-by-copy] ---*/ -var invalidComparators = [null, true, false, "", /a/g, 42, [], {}, Symbol()]; +var invalidComparators = [null, true, false, "", /a/g, 42, 42n, [], {}, Symbol()]; testWithTypedArrayConstructors(TA => { const ta = new TA([1]); From 11cc50acba64371ab35a368a3c89cdf75a2ccc27 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 4 Oct 2022 18:23:37 -0700 Subject: [PATCH 57/86] Update test/built-ins/TypedArray/prototype/toSorted/comparefn-stop-after-error.js Co-authored-by: Ms2ger --- .../prototype/toSorted/comparefn-stop-after-error.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/built-ins/TypedArray/prototype/toSorted/comparefn-stop-after-error.js b/test/built-ins/TypedArray/prototype/toSorted/comparefn-stop-after-error.js index cb9db9132c7..e4917eec39e 100644 --- a/test/built-ins/TypedArray/prototype/toSorted/comparefn-stop-after-error.js +++ b/test/built-ins/TypedArray/prototype/toSorted/comparefn-stop-after-error.js @@ -23,11 +23,10 @@ testWithTypedArrayConstructors(TA => { var ta = new TA([3, 1, 2]); try { ta.toSorted(() => { - if (calls === 0) { - calls++; + ++calls; + if (calls === 1) { throw new Test262Error(); } - calls++; }); } catch (e) {} assert.sameValue(calls, 1, "compareFn is not called after an error"); From 0ed49b42b2565cc599a9c63e69bcc8c8949de425 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 4 Oct 2022 18:24:06 -0700 Subject: [PATCH 58/86] Update test/built-ins/TypedArray/prototype/toSorted/ignores-species.js Co-authored-by: Ms2ger --- test/built-ins/TypedArray/prototype/toSorted/ignores-species.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/built-ins/TypedArray/prototype/toSorted/ignores-species.js b/test/built-ins/TypedArray/prototype/toSorted/ignores-species.js index 8bfe0f2f10e..c1fb4732e40 100644 --- a/test/built-ins/TypedArray/prototype/toSorted/ignores-species.js +++ b/test/built-ins/TypedArray/prototype/toSorted/ignores-species.js @@ -9,7 +9,7 @@ info: | %TypedArray%.prototype.toSorted ( comparefn ) ... - 5. Let A be ? TypedArraySpeciesCreate(O, Β« 𝔽(len) Β», true). + 6. Let A be ? TypedArrayCreateSameType(O, Β« 𝔽(len) Β»). ... TypedArraySpeciesCreate ( exemplar, argumentList [ , noSpeciesOverride ] ) From ab0fce277089d5620b03fa77caaed168e7e32f3c Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 4 Oct 2022 18:36:22 -0700 Subject: [PATCH 59/86] Update test/built-ins/TypedArray/prototype/toSorted/this-value-invalid.js Co-authored-by: Ms2ger --- .../TypedArray/prototype/toSorted/this-value-invalid.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/built-ins/TypedArray/prototype/toSorted/this-value-invalid.js b/test/built-ins/TypedArray/prototype/toSorted/this-value-invalid.js index 4b8a59d512a..1debe0e0c63 100644 --- a/test/built-ins/TypedArray/prototype/toSorted/this-value-invalid.js +++ b/test/built-ins/TypedArray/prototype/toSorted/this-value-invalid.js @@ -6,10 +6,10 @@ esid: sec-%typedarray%.prototype.toSorted description: > %TypedArray%.prototype.toSorted throws if the receiver is null or undefined info: | - %TypedArray%.prototype.toSorted ( ) + %TypedArray%.prototype.toSorted ( comparefn ) - 1. Let O be the this value. - 2. Perform ? ValidateTypedArray(O). + 2. Let O be the this value. + 3. Perform ? ValidateTypedArray(O). ... includes: [testTypedArray.js] features: [TypedArray, change-array-by-copy] From 0be6d47c77908fbfd536071cda371ac29c6032a2 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 4 Oct 2022 11:51:31 -0700 Subject: [PATCH 60/86] Symbol.unscopables/change-array-by-copy: renumber steps --- .../prototype/Symbol.unscopables/change-array-by-copy.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/built-ins/Array/prototype/Symbol.unscopables/change-array-by-copy.js b/test/built-ins/Array/prototype/Symbol.unscopables/change-array-by-copy.js index 4582b535228..1b223b391ff 100644 --- a/test/built-ins/Array/prototype/Symbol.unscopables/change-array-by-copy.js +++ b/test/built-ins/Array/prototype/Symbol.unscopables/change-array-by-copy.js @@ -8,9 +8,9 @@ info: | 22.1.3.32 Array.prototype [ @@unscopables ] ... - 11. Perform ! CreateDataPropertyOrThrow(unscopableList, "toReversed", true). - 12. Perform ! CreateDataPropertyOrThrow(unscopableList, "toSorted", true). - 13. Perform ! CreateDataPropertyOrThrow(unscopableList, "toSpliced", true). + 12. Perform ! CreateDataPropertyOrThrow(unscopableList, "toReversed", true). + 13. Perform ! CreateDataPropertyOrThrow(unscopableList, "toSorted", true). + 14. Perform ! CreateDataPropertyOrThrow(unscopableList, "toSpliced", true). ... includes: [propertyHelper.js] features: [Symbol.unscopables, change-array-by-copy] From 0bc64ee48b86973e47ce66a8ae0cebc5adf1bf6e Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 4 Oct 2022 11:52:03 -0700 Subject: [PATCH 61/86] Rename length-integer-string.js to length-tolength.js --- .../toReversed/{length-integer-string.js => length-tolength.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/built-ins/Array/prototype/toReversed/{length-integer-string.js => length-tolength.js} (100%) diff --git a/test/built-ins/Array/prototype/toReversed/length-integer-string.js b/test/built-ins/Array/prototype/toReversed/length-tolength.js similarity index 100% rename from test/built-ins/Array/prototype/toReversed/length-integer-string.js rename to test/built-ins/Array/prototype/toReversed/length-tolength.js From 0381a1abd0f0c74efbd50651a4a319db79f2c1ac Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 4 Oct 2022 11:52:35 -0700 Subject: [PATCH 62/86] Test boolean prototype mutation in this-value-boolean.js --- .../Array/prototype/toReversed/this-value-boolean.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/test/built-ins/Array/prototype/toReversed/this-value-boolean.js b/test/built-ins/Array/prototype/toReversed/this-value-boolean.js index ccce04a6550..8854812c09d 100644 --- a/test/built-ins/Array/prototype/toReversed/this-value-boolean.js +++ b/test/built-ins/Array/prototype/toReversed/this-value-boolean.js @@ -4,7 +4,7 @@ /*--- esid: sec-array.prototype.toReversed description: > - Array.prototype.toReversed throws if the receiver is null or undefined + Array.prototype.toReversed converts booleans to objects info: | Array.prototype.toReversed ( ) @@ -17,3 +17,13 @@ includes: [compareArray.js] assert.compareArray(Array.prototype.toReversed.call(true), []); assert.compareArray(Array.prototype.toReversed.call(false), []); + +/* Add length and indexed properties to `Boolean.prototype` */ +Boolean.prototype.length = function () { return 42; } +assert.compareArray(Array.prototype.toReversed.call(true), []); +assert.compareArray(Array.prototype.toReversed.call(false), []); +delete Boolean.prototype.length; +Boolean.prototype[0] = "monkeys"; +Boolean.prototype[2] = "bogus"; +assert.compareArray(Array.prototype.toReversed.call(true), []); +assert.compareArray(Array.prototype.toReversed.call(false), []); From b5028f2559bd552211518583c43be65b5dc0a791 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 4 Oct 2022 15:44:12 -0700 Subject: [PATCH 63/86] Array.prototype.toSorted: Test a BigInt value as an invalid comparator --- .../Array/prototype/toSorted/comparefn-not-a-function.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/built-ins/Array/prototype/toSorted/comparefn-not-a-function.js b/test/built-ins/Array/prototype/toSorted/comparefn-not-a-function.js index 95b8ee1b6f6..c1fecdc2c64 100644 --- a/test/built-ins/Array/prototype/toSorted/comparefn-not-a-function.js +++ b/test/built-ins/Array/prototype/toSorted/comparefn-not-a-function.js @@ -20,7 +20,7 @@ var getLengthThrow = { } }; -var invalidComparators = [null, true, false, "", /a/g, 42, [], {}, Symbol()]; +var invalidComparators = [null, true, false, "", /a/g, 42, 42n, [], {}, Symbol()]; for (var i = 0; i < invalidComparators.length; i++) { assert.throws(TypeError, function() { From e821daebed91b7b9aa8ae3dddaf8a2af66b08876 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 4 Oct 2022 16:44:09 -0700 Subject: [PATCH 64/86] Fix steps in toSpliced/delete-count-undefined --- .../Array/prototype/toSpliced/deleteCount-undefined.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/built-ins/Array/prototype/toSpliced/deleteCount-undefined.js b/test/built-ins/Array/prototype/toSpliced/deleteCount-undefined.js index 9b39aeb6c98..a0dfb9063e5 100644 --- a/test/built-ins/Array/prototype/toSpliced/deleteCount-undefined.js +++ b/test/built-ins/Array/prototype/toSpliced/deleteCount-undefined.js @@ -14,8 +14,11 @@ info: | ... 8. If start is not present, then a. Let actualDeleteCount be 0. - 8. Else if deleteCount is not present, then + 9. Else if deleteCount is not present, then a. Let actualDeleteCount be len - actualStart. + 10. Else, + a. Let dc be ? ToIntegerOrInfinity(deleteCount). + b. Let actualDeleteCount be the result of clamping dc between 0 and len - actualStart. ... features: [change-array-by-copy] includes: [compareArray.js] From 24b3cc149bc9dbac977c62a2eff432367ee7b051 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 4 Oct 2022 16:45:56 -0700 Subject: [PATCH 65/86] Fix steps in toSpliced/discarded-element-not-read --- .../toSpliced/discarded-element-not-read.js | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/test/built-ins/Array/prototype/toSpliced/discarded-element-not-read.js b/test/built-ins/Array/prototype/toSpliced/discarded-element-not-read.js index b57fb438cd9..286e7319a35 100644 --- a/test/built-ins/Array/prototype/toSpliced/discarded-element-not-read.js +++ b/test/built-ins/Array/prototype/toSpliced/discarded-element-not-read.js @@ -14,9 +14,23 @@ info: | ... 8. If start is not present, then a. Let actualDeleteCount be 0. - 8. Else if deleteCount is not present, then + 9. Else if deleteCount is not present, then a. Let actualDeleteCount be len - actualStart. + 10. Else, + a. Let dc be ? ToIntegerOrInfinity(deleteCount). + b. Let actualDeleteCount be the result of clamping dc between 0 and len - actualStart. + 11. Let newLen be len + insertCount - actualDeleteCount. ... + 15. Let r be actualStart + actualDeleteCount. + ... + 18. Repeat, while i < newLen, + a. Let Pi be ! ToString(𝔽(i)). + b. Let from be ! ToString(𝔽(r)). + c. Let fromValue be ? Get(O, from). + d. Perform ! CreateDataPropertyOrThrow(A, Pi, fromValue). + e. Set i to i + 1. + f. Set r to r + 1. + features: [change-array-by-copy] includes: [compareArray.js] ---*/ @@ -29,5 +43,10 @@ var arrayLike = { length: 4, }; +/* + * In this example, just before step 18, i == 2 and r == 3. + * So A[2] is set to arrayLike[3] and arrayLike[2] is never read + * (since i and r both increase monotonically). + */ var result = Array.prototype.toSpliced.call(arrayLike, 2, 1); assert.compareArray(result, ["a", "b", "c"]); From 2dbaaceea7ff1c588e2e81c1d19ffcae93ce33ec Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 4 Oct 2022 16:46:11 -0700 Subject: [PATCH 66/86] Add hasOwnProperty checks to toSpliced/holes-not-preserved --- test/built-ins/Array/prototype/toSpliced/holes-not-preserved.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/built-ins/Array/prototype/toSpliced/holes-not-preserved.js b/test/built-ins/Array/prototype/toSpliced/holes-not-preserved.js index 2d10ff41678..0173c2bf92e 100644 --- a/test/built-ins/Array/prototype/toSpliced/holes-not-preserved.js +++ b/test/built-ins/Array/prototype/toSpliced/holes-not-preserved.js @@ -37,3 +37,5 @@ assert(spliced.hasOwnProperty(3)); spliced = arr.toSpliced(0, 0, -1); assert.compareArray(spliced, [-1, 0, undefined, 2, 3, 4]); +assert(spliced.hasOwnProperty(1)); +assert(spliced.hasOwnProperty(3)); From 48144a907dd0c9a61bee1658631b7dde13de5e04 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 4 Oct 2022 16:47:35 -0700 Subject: [PATCH 67/86] Fix steps in with/ignores-species --- .../built-ins/TypedArray/prototype/with/ignores-species.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/test/built-ins/TypedArray/prototype/with/ignores-species.js b/test/built-ins/TypedArray/prototype/with/ignores-species.js index 4a1ab24cb08..5c65fdeb013 100644 --- a/test/built-ins/TypedArray/prototype/with/ignores-species.js +++ b/test/built-ins/TypedArray/prototype/with/ignores-species.js @@ -9,13 +9,12 @@ info: | %TypedArray%.prototype.with ( index, value ) ... - 8. Let A be ? TypedArraySpeciesCreate(O, Β« 𝔽(len) Β», true). + 10. Let A be ? TypedArrayCreateSameType(O, Β« 𝔽(len) Β»). ... - TypedArraySpeciesCreate ( exemplar, argumentList [ , noSpeciesOverride ] ) + TypedArrayCreateSameType ( exemplar, argumentList ) ... - 2. Let defaultConstructor be the intrinsic object listed in column one of Table 63 for exemplar.[[TypedArrayName]]. - 3. If noSpeciesOverride is true, let constructor be defaultConstructor. + 2. Let constructor be the intrinsic object listed in column one of Table 63 for exemplar.[[TypedArrayName]]. ... includes: [testTypedArray.js] features: [TypedArray, change-array-by-copy] From 3c3c1ffff8f4c6cca598f0aa344939bc2e9287e8 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 4 Oct 2022 16:47:46 -0700 Subject: [PATCH 68/86] Fix info in with/this-value-invalid --- test/built-ins/TypedArray/prototype/with/this-value-invalid.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/built-ins/TypedArray/prototype/with/this-value-invalid.js b/test/built-ins/TypedArray/prototype/with/this-value-invalid.js index 404d6eae557..5f07a5ae950 100644 --- a/test/built-ins/TypedArray/prototype/with/this-value-invalid.js +++ b/test/built-ins/TypedArray/prototype/with/this-value-invalid.js @@ -6,7 +6,7 @@ esid: sec-%typedarray%.prototype.with description: > %TypedArray%.prototype.with throws if the receiver is null or undefined info: | - %TypedArray%.prototype.with ( start, deleteCount , ...items ) + %TypedArray%.prototype.with ( index, value ) 1. Let O be the this value. 2. Perform ? ValidateTypedArray(O). From 52e7b96d7117d5d4864e23d2e138128b61fae14f Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 4 Oct 2022 17:02:22 -0700 Subject: [PATCH 69/86] Fix steps in toSpliced/elements-read-in-order --- .../prototype/toSpliced/elements-read-in-order.js | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/test/built-ins/Array/prototype/toSpliced/elements-read-in-order.js b/test/built-ins/Array/prototype/toSpliced/elements-read-in-order.js index ab92b1a9048..6a67038cb50 100644 --- a/test/built-ins/Array/prototype/toSpliced/elements-read-in-order.js +++ b/test/built-ins/Array/prototype/toSpliced/elements-read-in-order.js @@ -7,16 +7,8 @@ description: Array.prototype.toSpliced reads the items of the original array in info: | 22.1.3.25 Array.prototype.toSpliced (start, deleteCount , ...items ) - ... - 3. Let relativeStart be ? ToIntegerOrInfinity(start). - ... - 6. Else, let actualStart be min(relativeStart, len). - ... - 8. If start is not present, then - a. Let actualDeleteCount be 0. - 8. Else if deleteCount is not present, then - a. Let actualDeleteCount be len - actualStart. - ... + Steps 14-18 + features: [change-array-by-copy] includes: [compareArray.js] ---*/ From 0395352393df556c6d350900dce0aba1b575c001 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 4 Oct 2022 17:19:32 -0700 Subject: [PATCH 70/86] Fix steps in toSorted/holes-not-preserved --- .../Array/prototype/toSorted/holes-not-preserved.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/test/built-ins/Array/prototype/toSorted/holes-not-preserved.js b/test/built-ins/Array/prototype/toSorted/holes-not-preserved.js index c13559cadfb..e7d69a76e5a 100644 --- a/test/built-ins/Array/prototype/toSorted/holes-not-preserved.js +++ b/test/built-ins/Array/prototype/toSorted/holes-not-preserved.js @@ -9,14 +9,9 @@ info: | Array.prototype.toSorted ( compareFn ) ... - 2. Let len be ? LengthOfArrayLike(O). - 4. Let items be a new empty List. - 5. Let k be 0. - 6. Repeat, while k < len, - a. Let Pk be ! ToString(𝔽(k)). - b. Let kValue be ? Get(O, Pk). - c. Append kValue to items. - d. Set k to k + 1. + 8. Repeat, while j < len, + a. Perform ! CreateDataPropertyOrThrow(A, ! ToString(𝔽(j)), sortedList[j]). + b. Set j to j + 1. ... features: [change-array-by-copy] includes: [compareArray.js] From d20bc2379d09b176c8f4c9868468f511ee73f4b4 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 4 Oct 2022 17:22:01 -0700 Subject: [PATCH 71/86] Change 'Igalia' to 'Igalia, S.L.' in copyright block --- test/built-ins/Array/prototype/toReversed/frozen-this-value.js | 2 +- .../Array/prototype/toReversed/get-descending-order.js | 2 +- .../built-ins/Array/prototype/toReversed/holes-not-preserved.js | 2 +- test/built-ins/Array/prototype/toReversed/ignores-species.js | 2 +- test/built-ins/Array/prototype/toReversed/immutable.js | 2 +- .../Array/prototype/toReversed/length-casted-to-zero.js | 2 +- .../prototype/toReversed/length-decreased-while-iterating.js | 2 +- .../prototype/toReversed/length-exceeding-array-length-limit.js | 2 +- .../prototype/toReversed/length-increased-while-iterating.js | 2 +- test/built-ins/Array/prototype/toReversed/length-tolength.js | 2 +- test/built-ins/Array/prototype/toReversed/metadata/length.js | 2 +- test/built-ins/Array/prototype/toReversed/metadata/name.js | 2 +- .../Array/prototype/toReversed/metadata/property-descriptor.js | 2 +- test/built-ins/Array/prototype/toReversed/not-a-constructor.js | 2 +- test/built-ins/Array/prototype/toReversed/this-value-boolean.js | 2 +- test/built-ins/Array/prototype/toReversed/this-value-nullish.js | 2 +- .../built-ins/Array/prototype/toReversed/zero-or-one-element.js | 2 +- .../prototype/toSorted/comparefn-called-after-get-elements.js | 2 +- .../Array/prototype/toSorted/comparefn-not-a-function.js | 2 +- .../Array/prototype/toSorted/comparefn-stop-after-error.js | 2 +- test/built-ins/Array/prototype/toSorted/frozen-this-value.js | 2 +- test/built-ins/Array/prototype/toSorted/holes-not-preserved.js | 2 +- test/built-ins/Array/prototype/toSorted/ignores-species.js | 2 +- test/built-ins/Array/prototype/toSorted/immutable.js | 2 +- .../built-ins/Array/prototype/toSorted/length-casted-to-zero.js | 2 +- .../prototype/toSorted/length-decreased-while-iterating.js | 2 +- .../prototype/toSorted/length-exceeding-array-length-limit.js | 2 +- .../prototype/toSorted/length-increased-while-iterating.js | 2 +- .../built-ins/Array/prototype/toSorted/length-integer-string.js | 2 +- test/built-ins/Array/prototype/toSorted/metadata/length.js | 2 +- test/built-ins/Array/prototype/toSorted/metadata/name.js | 2 +- .../Array/prototype/toSorted/metadata/property-descriptor.js | 2 +- test/built-ins/Array/prototype/toSorted/not-a-constructor.js | 2 +- test/built-ins/Array/prototype/toSorted/this-value-boolean.js | 2 +- test/built-ins/Array/prototype/toSorted/this-value-nullish.js | 2 +- test/built-ins/Array/prototype/toSorted/zero-or-one-element.js | 2 +- .../deleteCount-clamped-between-zero-and-remaining-count.js | 2 +- test/built-ins/Array/prototype/toSpliced/deleteCount-missing.js | 2 +- .../Array/prototype/toSpliced/deleteCount-undefined.js | 2 +- .../Array/prototype/toSpliced/discarded-element-not-read.js | 2 +- .../Array/prototype/toSpliced/elements-read-in-order.js | 2 +- test/built-ins/Array/prototype/toSpliced/frozen-this-value.js | 2 +- test/built-ins/Array/prototype/toSpliced/holes-not-preserved.js | 2 +- test/built-ins/Array/prototype/toSpliced/ignores-species.js | 2 +- test/built-ins/Array/prototype/toSpliced/immutable.js | 2 +- .../Array/prototype/toSpliced/length-casted-to-zero.js | 2 +- .../Array/prototype/toSpliced/length-clamped-to-2pow53minus1.js | 2 +- .../prototype/toSpliced/length-decreased-while-iterating.js | 2 +- .../prototype/toSpliced/length-exceeding-array-length-limit.js | 2 +- .../prototype/toSpliced/length-increased-while-iterating.js | 2 +- .../Array/prototype/toSpliced/length-integer-string.js | 2 +- test/built-ins/Array/prototype/toSpliced/metadata/length.js | 2 +- test/built-ins/Array/prototype/toSpliced/metadata/name.js | 2 +- .../Array/prototype/toSpliced/metadata/property-descriptor.js | 2 +- test/built-ins/Array/prototype/toSpliced/not-a-constructor.js | 2 +- .../Array/prototype/toSpliced/start-and-deleteCount-missing.js | 2 +- .../prototype/toSpliced/start-and-deleteCount-undefineds.js | 2 +- .../Array/prototype/toSpliced/start-bigger-than-length.js | 2 +- .../Array/prototype/toSpliced/start-neg-infinity-is-zero.js | 2 +- .../toSpliced/start-neg-less-than-minus-length-is-zero.js | 2 +- .../prototype/toSpliced/start-neg-subtracted-from-length.js | 2 +- .../toSpliced/start-undefined-and-deleteCount-missing.js | 2 +- test/built-ins/Array/prototype/toSpliced/this-value-boolean.js | 2 +- test/built-ins/Array/prototype/toSpliced/this-value-nullish.js | 2 +- test/built-ins/Array/prototype/toSpliced/unmodified.js | 2 +- test/built-ins/Array/prototype/with/frozen-this-value.js | 2 +- test/built-ins/Array/prototype/with/holes-not-preserved.js | 2 +- test/built-ins/Array/prototype/with/ignores-species.js | 2 +- test/built-ins/Array/prototype/with/immutable.js | 2 +- .../Array/prototype/with/index-bigger-or-eq-than-length.js | 2 +- test/built-ins/Array/prototype/with/index-casted-to-number.js | 2 +- test/built-ins/Array/prototype/with/index-negative.js | 2 +- .../Array/prototype/with/index-smaller-than-minus-length.js | 2 +- .../Array/prototype/with/length-decreased-while-iterating.js | 2 +- .../Array/prototype/with/length-exceeding-array-length-limit.js | 2 +- .../Array/prototype/with/length-increased-while-iterating.js | 2 +- test/built-ins/Array/prototype/with/length-integer-string.js | 2 +- test/built-ins/Array/prototype/with/metadata/length.js | 2 +- test/built-ins/Array/prototype/with/metadata/name.js | 2 +- .../Array/prototype/with/metadata/property-descriptor.js | 2 +- test/built-ins/Array/prototype/with/no-get-replaced-index.js | 2 +- test/built-ins/Array/prototype/with/not-a-constructor.js | 2 +- test/built-ins/Array/prototype/with/this-value-boolean.js | 2 +- test/built-ins/Array/prototype/with/this-value-nullish.js | 2 +- .../TypedArray/prototype/toReversed/ignores-species.js | 2 +- test/built-ins/TypedArray/prototype/toReversed/immutable.js | 2 +- .../TypedArray/prototype/toReversed/length-property-ignored.js | 2 +- .../TypedArray/prototype/toReversed/metadata/length.js | 2 +- test/built-ins/TypedArray/prototype/toReversed/metadata/name.js | 2 +- .../prototype/toReversed/metadata/property-descriptor.js | 2 +- .../TypedArray/prototype/toReversed/not-a-constructor.js | 2 +- .../TypedArray/prototype/toReversed/this-value-invalid.js | 2 +- .../TypedArray/prototype/toSorted/comparefn-not-a-function.js | 2 +- .../TypedArray/prototype/toSorted/comparefn-stop-after-error.js | 2 +- test/built-ins/TypedArray/prototype/toSorted/ignores-species.js | 2 +- test/built-ins/TypedArray/prototype/toSorted/immutable.js | 2 +- .../TypedArray/prototype/toSorted/length-property-ignored.js | 2 +- test/built-ins/TypedArray/prototype/toSorted/metadata/length.js | 2 +- test/built-ins/TypedArray/prototype/toSorted/metadata/name.js | 2 +- .../prototype/toSorted/metadata/property-descriptor.js | 2 +- .../TypedArray/prototype/toSorted/not-a-constructor.js | 2 +- .../TypedArray/prototype/toSorted/this-value-invalid.js | 2 +- .../prototype/with/BigInt/early-type-coercion-bigint.js | 2 +- test/built-ins/TypedArray/prototype/with/early-type-coercion.js | 2 +- test/built-ins/TypedArray/prototype/with/ignores-species.js | 2 +- test/built-ins/TypedArray/prototype/with/immutable.js | 2 +- .../TypedArray/prototype/with/index-bigger-or-eq-than-length.js | 2 +- .../TypedArray/prototype/with/index-casted-to-number.js | 2 +- test/built-ins/TypedArray/prototype/with/index-negative.js | 2 +- .../prototype/with/index-smaller-than-minus-length.js | 2 +- .../TypedArray/prototype/with/length-property-ignored.js | 2 +- test/built-ins/TypedArray/prototype/with/metadata/length.js | 2 +- test/built-ins/TypedArray/prototype/with/metadata/name.js | 2 +- .../TypedArray/prototype/with/metadata/property-descriptor.js | 2 +- test/built-ins/TypedArray/prototype/with/not-a-constructor.js | 2 +- test/built-ins/TypedArray/prototype/with/this-value-invalid.js | 2 +- 116 files changed, 116 insertions(+), 116 deletions(-) diff --git a/test/built-ins/Array/prototype/toReversed/frozen-this-value.js b/test/built-ins/Array/prototype/toReversed/frozen-this-value.js index 62915553487..2c0cf118a8d 100644 --- a/test/built-ins/Array/prototype/toReversed/frozen-this-value.js +++ b/test/built-ins/Array/prototype/toReversed/frozen-this-value.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toReversed/get-descending-order.js b/test/built-ins/Array/prototype/toReversed/get-descending-order.js index 0372be7da51..c9d324d55ad 100644 --- a/test/built-ins/Array/prototype/toReversed/get-descending-order.js +++ b/test/built-ins/Array/prototype/toReversed/get-descending-order.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toReversed/holes-not-preserved.js b/test/built-ins/Array/prototype/toReversed/holes-not-preserved.js index 0be39fb25b6..90510f186a1 100644 --- a/test/built-ins/Array/prototype/toReversed/holes-not-preserved.js +++ b/test/built-ins/Array/prototype/toReversed/holes-not-preserved.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toReversed/ignores-species.js b/test/built-ins/Array/prototype/toReversed/ignores-species.js index 29328c1e955..6c29739478c 100644 --- a/test/built-ins/Array/prototype/toReversed/ignores-species.js +++ b/test/built-ins/Array/prototype/toReversed/ignores-species.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toReversed/immutable.js b/test/built-ins/Array/prototype/toReversed/immutable.js index cdee317f72b..b3c5883dbda 100644 --- a/test/built-ins/Array/prototype/toReversed/immutable.js +++ b/test/built-ins/Array/prototype/toReversed/immutable.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toReversed/length-casted-to-zero.js b/test/built-ins/Array/prototype/toReversed/length-casted-to-zero.js index 004542c2d16..45768276117 100644 --- a/test/built-ins/Array/prototype/toReversed/length-casted-to-zero.js +++ b/test/built-ins/Array/prototype/toReversed/length-casted-to-zero.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toReversed/length-decreased-while-iterating.js b/test/built-ins/Array/prototype/toReversed/length-decreased-while-iterating.js index 58d5dbd0500..90a40d601a0 100644 --- a/test/built-ins/Array/prototype/toReversed/length-decreased-while-iterating.js +++ b/test/built-ins/Array/prototype/toReversed/length-decreased-while-iterating.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toReversed/length-exceeding-array-length-limit.js b/test/built-ins/Array/prototype/toReversed/length-exceeding-array-length-limit.js index a2deee8c0b3..e3a212a078f 100644 --- a/test/built-ins/Array/prototype/toReversed/length-exceeding-array-length-limit.js +++ b/test/built-ins/Array/prototype/toReversed/length-exceeding-array-length-limit.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toReversed/length-increased-while-iterating.js b/test/built-ins/Array/prototype/toReversed/length-increased-while-iterating.js index f0e4ef04c7f..8f7b0990973 100644 --- a/test/built-ins/Array/prototype/toReversed/length-increased-while-iterating.js +++ b/test/built-ins/Array/prototype/toReversed/length-increased-while-iterating.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toReversed/length-tolength.js b/test/built-ins/Array/prototype/toReversed/length-tolength.js index 957bc44e029..6d175a899d0 100644 --- a/test/built-ins/Array/prototype/toReversed/length-tolength.js +++ b/test/built-ins/Array/prototype/toReversed/length-tolength.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toReversed/metadata/length.js b/test/built-ins/Array/prototype/toReversed/metadata/length.js index 85d98a69da3..bb28f085228 100644 --- a/test/built-ins/Array/prototype/toReversed/metadata/length.js +++ b/test/built-ins/Array/prototype/toReversed/metadata/length.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toReversed/metadata/name.js b/test/built-ins/Array/prototype/toReversed/metadata/name.js index 7ed3e9ad922..5ea28d2c323 100644 --- a/test/built-ins/Array/prototype/toReversed/metadata/name.js +++ b/test/built-ins/Array/prototype/toReversed/metadata/name.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toReversed/metadata/property-descriptor.js b/test/built-ins/Array/prototype/toReversed/metadata/property-descriptor.js index f8c0979d9dc..e0ff507c13e 100644 --- a/test/built-ins/Array/prototype/toReversed/metadata/property-descriptor.js +++ b/test/built-ins/Array/prototype/toReversed/metadata/property-descriptor.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toReversed/not-a-constructor.js b/test/built-ins/Array/prototype/toReversed/not-a-constructor.js index 9e4e3f9fdac..6cfabfe6ff0 100644 --- a/test/built-ins/Array/prototype/toReversed/not-a-constructor.js +++ b/test/built-ins/Array/prototype/toReversed/not-a-constructor.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toReversed/this-value-boolean.js b/test/built-ins/Array/prototype/toReversed/this-value-boolean.js index 8854812c09d..ccba5a2abe3 100644 --- a/test/built-ins/Array/prototype/toReversed/this-value-boolean.js +++ b/test/built-ins/Array/prototype/toReversed/this-value-boolean.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toReversed/this-value-nullish.js b/test/built-ins/Array/prototype/toReversed/this-value-nullish.js index 41371b57c63..b81e99f5921 100644 --- a/test/built-ins/Array/prototype/toReversed/this-value-nullish.js +++ b/test/built-ins/Array/prototype/toReversed/this-value-nullish.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toReversed/zero-or-one-element.js b/test/built-ins/Array/prototype/toReversed/zero-or-one-element.js index f09c922110c..110fa41b653 100644 --- a/test/built-ins/Array/prototype/toReversed/zero-or-one-element.js +++ b/test/built-ins/Array/prototype/toReversed/zero-or-one-element.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toSorted/comparefn-called-after-get-elements.js b/test/built-ins/Array/prototype/toSorted/comparefn-called-after-get-elements.js index 6780946d275..f9d675003e5 100644 --- a/test/built-ins/Array/prototype/toSorted/comparefn-called-after-get-elements.js +++ b/test/built-ins/Array/prototype/toSorted/comparefn-called-after-get-elements.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toSorted/comparefn-not-a-function.js b/test/built-ins/Array/prototype/toSorted/comparefn-not-a-function.js index c1fecdc2c64..427130c1b26 100644 --- a/test/built-ins/Array/prototype/toSorted/comparefn-not-a-function.js +++ b/test/built-ins/Array/prototype/toSorted/comparefn-not-a-function.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toSorted/comparefn-stop-after-error.js b/test/built-ins/Array/prototype/toSorted/comparefn-stop-after-error.js index cfe729fcdb0..4b1838d1e8c 100644 --- a/test/built-ins/Array/prototype/toSorted/comparefn-stop-after-error.js +++ b/test/built-ins/Array/prototype/toSorted/comparefn-stop-after-error.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toSorted/frozen-this-value.js b/test/built-ins/Array/prototype/toSorted/frozen-this-value.js index 2fc60d56347..4d7cad03073 100644 --- a/test/built-ins/Array/prototype/toSorted/frozen-this-value.js +++ b/test/built-ins/Array/prototype/toSorted/frozen-this-value.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toSorted/holes-not-preserved.js b/test/built-ins/Array/prototype/toSorted/holes-not-preserved.js index e7d69a76e5a..f630632df9b 100644 --- a/test/built-ins/Array/prototype/toSorted/holes-not-preserved.js +++ b/test/built-ins/Array/prototype/toSorted/holes-not-preserved.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toSorted/ignores-species.js b/test/built-ins/Array/prototype/toSorted/ignores-species.js index 3e067ec6303..42246a7e35f 100644 --- a/test/built-ins/Array/prototype/toSorted/ignores-species.js +++ b/test/built-ins/Array/prototype/toSorted/ignores-species.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toSorted/immutable.js b/test/built-ins/Array/prototype/toSorted/immutable.js index 558005d8851..57bdb9f020c 100644 --- a/test/built-ins/Array/prototype/toSorted/immutable.js +++ b/test/built-ins/Array/prototype/toSorted/immutable.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toSorted/length-casted-to-zero.js b/test/built-ins/Array/prototype/toSorted/length-casted-to-zero.js index 7804f8aca4f..197c6e3fd75 100644 --- a/test/built-ins/Array/prototype/toSorted/length-casted-to-zero.js +++ b/test/built-ins/Array/prototype/toSorted/length-casted-to-zero.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toSorted/length-decreased-while-iterating.js b/test/built-ins/Array/prototype/toSorted/length-decreased-while-iterating.js index 47b46de02ce..abf2070ae3a 100644 --- a/test/built-ins/Array/prototype/toSorted/length-decreased-while-iterating.js +++ b/test/built-ins/Array/prototype/toSorted/length-decreased-while-iterating.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toSorted/length-exceeding-array-length-limit.js b/test/built-ins/Array/prototype/toSorted/length-exceeding-array-length-limit.js index 3bec52758f3..72ae5353a54 100644 --- a/test/built-ins/Array/prototype/toSorted/length-exceeding-array-length-limit.js +++ b/test/built-ins/Array/prototype/toSorted/length-exceeding-array-length-limit.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toSorted/length-increased-while-iterating.js b/test/built-ins/Array/prototype/toSorted/length-increased-while-iterating.js index 17b2eb107b0..6eebc93fbb5 100644 --- a/test/built-ins/Array/prototype/toSorted/length-increased-while-iterating.js +++ b/test/built-ins/Array/prototype/toSorted/length-increased-while-iterating.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toSorted/length-integer-string.js b/test/built-ins/Array/prototype/toSorted/length-integer-string.js index 0684b46ed29..d84ea0e8814 100644 --- a/test/built-ins/Array/prototype/toSorted/length-integer-string.js +++ b/test/built-ins/Array/prototype/toSorted/length-integer-string.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toSorted/metadata/length.js b/test/built-ins/Array/prototype/toSorted/metadata/length.js index 34bac5998be..b1c447b0ea7 100644 --- a/test/built-ins/Array/prototype/toSorted/metadata/length.js +++ b/test/built-ins/Array/prototype/toSorted/metadata/length.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toSorted/metadata/name.js b/test/built-ins/Array/prototype/toSorted/metadata/name.js index a5ca772efeb..cffc50eabfb 100644 --- a/test/built-ins/Array/prototype/toSorted/metadata/name.js +++ b/test/built-ins/Array/prototype/toSorted/metadata/name.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toSorted/metadata/property-descriptor.js b/test/built-ins/Array/prototype/toSorted/metadata/property-descriptor.js index 27b2e108766..b7550bc62f9 100644 --- a/test/built-ins/Array/prototype/toSorted/metadata/property-descriptor.js +++ b/test/built-ins/Array/prototype/toSorted/metadata/property-descriptor.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toSorted/not-a-constructor.js b/test/built-ins/Array/prototype/toSorted/not-a-constructor.js index 96edd3225b6..8865d181663 100644 --- a/test/built-ins/Array/prototype/toSorted/not-a-constructor.js +++ b/test/built-ins/Array/prototype/toSorted/not-a-constructor.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toSorted/this-value-boolean.js b/test/built-ins/Array/prototype/toSorted/this-value-boolean.js index 6cecceb10f2..7320dd1cee4 100644 --- a/test/built-ins/Array/prototype/toSorted/this-value-boolean.js +++ b/test/built-ins/Array/prototype/toSorted/this-value-boolean.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toSorted/this-value-nullish.js b/test/built-ins/Array/prototype/toSorted/this-value-nullish.js index 2e5b58e22fc..6be9d4cb4f2 100644 --- a/test/built-ins/Array/prototype/toSorted/this-value-nullish.js +++ b/test/built-ins/Array/prototype/toSorted/this-value-nullish.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toSorted/zero-or-one-element.js b/test/built-ins/Array/prototype/toSorted/zero-or-one-element.js index 252cf4f17e9..a692e118bdd 100644 --- a/test/built-ins/Array/prototype/toSorted/zero-or-one-element.js +++ b/test/built-ins/Array/prototype/toSorted/zero-or-one-element.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toSpliced/deleteCount-clamped-between-zero-and-remaining-count.js b/test/built-ins/Array/prototype/toSpliced/deleteCount-clamped-between-zero-and-remaining-count.js index 59a809d6a01..21e2e8ddf32 100644 --- a/test/built-ins/Array/prototype/toSpliced/deleteCount-clamped-between-zero-and-remaining-count.js +++ b/test/built-ins/Array/prototype/toSpliced/deleteCount-clamped-between-zero-and-remaining-count.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toSpliced/deleteCount-missing.js b/test/built-ins/Array/prototype/toSpliced/deleteCount-missing.js index 6472d7ea56b..ffc1589ad68 100644 --- a/test/built-ins/Array/prototype/toSpliced/deleteCount-missing.js +++ b/test/built-ins/Array/prototype/toSpliced/deleteCount-missing.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toSpliced/deleteCount-undefined.js b/test/built-ins/Array/prototype/toSpliced/deleteCount-undefined.js index a0dfb9063e5..b7773892481 100644 --- a/test/built-ins/Array/prototype/toSpliced/deleteCount-undefined.js +++ b/test/built-ins/Array/prototype/toSpliced/deleteCount-undefined.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toSpliced/discarded-element-not-read.js b/test/built-ins/Array/prototype/toSpliced/discarded-element-not-read.js index 286e7319a35..2b31e96cd12 100644 --- a/test/built-ins/Array/prototype/toSpliced/discarded-element-not-read.js +++ b/test/built-ins/Array/prototype/toSpliced/discarded-element-not-read.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toSpliced/elements-read-in-order.js b/test/built-ins/Array/prototype/toSpliced/elements-read-in-order.js index 6a67038cb50..002b31e8ef6 100644 --- a/test/built-ins/Array/prototype/toSpliced/elements-read-in-order.js +++ b/test/built-ins/Array/prototype/toSpliced/elements-read-in-order.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toSpliced/frozen-this-value.js b/test/built-ins/Array/prototype/toSpliced/frozen-this-value.js index d3bd3e7ed80..54e421cc77e 100644 --- a/test/built-ins/Array/prototype/toSpliced/frozen-this-value.js +++ b/test/built-ins/Array/prototype/toSpliced/frozen-this-value.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toSpliced/holes-not-preserved.js b/test/built-ins/Array/prototype/toSpliced/holes-not-preserved.js index 0173c2bf92e..8299c96e247 100644 --- a/test/built-ins/Array/prototype/toSpliced/holes-not-preserved.js +++ b/test/built-ins/Array/prototype/toSpliced/holes-not-preserved.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toSpliced/ignores-species.js b/test/built-ins/Array/prototype/toSpliced/ignores-species.js index ba1e94554a9..b667a01c98a 100644 --- a/test/built-ins/Array/prototype/toSpliced/ignores-species.js +++ b/test/built-ins/Array/prototype/toSpliced/ignores-species.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toSpliced/immutable.js b/test/built-ins/Array/prototype/toSpliced/immutable.js index 443ad5fed77..e43654b0d5b 100644 --- a/test/built-ins/Array/prototype/toSpliced/immutable.js +++ b/test/built-ins/Array/prototype/toSpliced/immutable.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toSpliced/length-casted-to-zero.js b/test/built-ins/Array/prototype/toSpliced/length-casted-to-zero.js index 0b694186d44..92efbe7544c 100644 --- a/test/built-ins/Array/prototype/toSpliced/length-casted-to-zero.js +++ b/test/built-ins/Array/prototype/toSpliced/length-casted-to-zero.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toSpliced/length-clamped-to-2pow53minus1.js b/test/built-ins/Array/prototype/toSpliced/length-clamped-to-2pow53minus1.js index f9d6456839a..5938e729be1 100644 --- a/test/built-ins/Array/prototype/toSpliced/length-clamped-to-2pow53minus1.js +++ b/test/built-ins/Array/prototype/toSpliced/length-clamped-to-2pow53minus1.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toSpliced/length-decreased-while-iterating.js b/test/built-ins/Array/prototype/toSpliced/length-decreased-while-iterating.js index 5826e7652d8..35b2c1740fb 100644 --- a/test/built-ins/Array/prototype/toSpliced/length-decreased-while-iterating.js +++ b/test/built-ins/Array/prototype/toSpliced/length-decreased-while-iterating.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toSpliced/length-exceeding-array-length-limit.js b/test/built-ins/Array/prototype/toSpliced/length-exceeding-array-length-limit.js index bab02f0aad3..ddd2a4dce25 100644 --- a/test/built-ins/Array/prototype/toSpliced/length-exceeding-array-length-limit.js +++ b/test/built-ins/Array/prototype/toSpliced/length-exceeding-array-length-limit.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toSpliced/length-increased-while-iterating.js b/test/built-ins/Array/prototype/toSpliced/length-increased-while-iterating.js index 5f2a5e5bc1a..836be9e6bac 100644 --- a/test/built-ins/Array/prototype/toSpliced/length-increased-while-iterating.js +++ b/test/built-ins/Array/prototype/toSpliced/length-increased-while-iterating.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toSpliced/length-integer-string.js b/test/built-ins/Array/prototype/toSpliced/length-integer-string.js index 8058060f3d2..b8652a445d4 100644 --- a/test/built-ins/Array/prototype/toSpliced/length-integer-string.js +++ b/test/built-ins/Array/prototype/toSpliced/length-integer-string.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toSpliced/metadata/length.js b/test/built-ins/Array/prototype/toSpliced/metadata/length.js index 6f570711c14..fe4c1621b8d 100644 --- a/test/built-ins/Array/prototype/toSpliced/metadata/length.js +++ b/test/built-ins/Array/prototype/toSpliced/metadata/length.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toSpliced/metadata/name.js b/test/built-ins/Array/prototype/toSpliced/metadata/name.js index 2acd12356bb..9bcf1c3b1e0 100644 --- a/test/built-ins/Array/prototype/toSpliced/metadata/name.js +++ b/test/built-ins/Array/prototype/toSpliced/metadata/name.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toSpliced/metadata/property-descriptor.js b/test/built-ins/Array/prototype/toSpliced/metadata/property-descriptor.js index a75b933dbc2..b5eb9316c58 100644 --- a/test/built-ins/Array/prototype/toSpliced/metadata/property-descriptor.js +++ b/test/built-ins/Array/prototype/toSpliced/metadata/property-descriptor.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toSpliced/not-a-constructor.js b/test/built-ins/Array/prototype/toSpliced/not-a-constructor.js index 8b039747e29..b702fa27e39 100644 --- a/test/built-ins/Array/prototype/toSpliced/not-a-constructor.js +++ b/test/built-ins/Array/prototype/toSpliced/not-a-constructor.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toSpliced/start-and-deleteCount-missing.js b/test/built-ins/Array/prototype/toSpliced/start-and-deleteCount-missing.js index e39ef74e244..c68404b79f7 100644 --- a/test/built-ins/Array/prototype/toSpliced/start-and-deleteCount-missing.js +++ b/test/built-ins/Array/prototype/toSpliced/start-and-deleteCount-missing.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toSpliced/start-and-deleteCount-undefineds.js b/test/built-ins/Array/prototype/toSpliced/start-and-deleteCount-undefineds.js index a072679ab88..82781bfad30 100644 --- a/test/built-ins/Array/prototype/toSpliced/start-and-deleteCount-undefineds.js +++ b/test/built-ins/Array/prototype/toSpliced/start-and-deleteCount-undefineds.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toSpliced/start-bigger-than-length.js b/test/built-ins/Array/prototype/toSpliced/start-bigger-than-length.js index ad9f9d06381..77917ef5105 100644 --- a/test/built-ins/Array/prototype/toSpliced/start-bigger-than-length.js +++ b/test/built-ins/Array/prototype/toSpliced/start-bigger-than-length.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toSpliced/start-neg-infinity-is-zero.js b/test/built-ins/Array/prototype/toSpliced/start-neg-infinity-is-zero.js index 14c05f64ef7..fd3240624fe 100644 --- a/test/built-ins/Array/prototype/toSpliced/start-neg-infinity-is-zero.js +++ b/test/built-ins/Array/prototype/toSpliced/start-neg-infinity-is-zero.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toSpliced/start-neg-less-than-minus-length-is-zero.js b/test/built-ins/Array/prototype/toSpliced/start-neg-less-than-minus-length-is-zero.js index f0b49fc2ca4..554090eb36a 100644 --- a/test/built-ins/Array/prototype/toSpliced/start-neg-less-than-minus-length-is-zero.js +++ b/test/built-ins/Array/prototype/toSpliced/start-neg-less-than-minus-length-is-zero.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toSpliced/start-neg-subtracted-from-length.js b/test/built-ins/Array/prototype/toSpliced/start-neg-subtracted-from-length.js index b0d5264ab83..8b631fd470f 100644 --- a/test/built-ins/Array/prototype/toSpliced/start-neg-subtracted-from-length.js +++ b/test/built-ins/Array/prototype/toSpliced/start-neg-subtracted-from-length.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toSpliced/start-undefined-and-deleteCount-missing.js b/test/built-ins/Array/prototype/toSpliced/start-undefined-and-deleteCount-missing.js index af52a55ccc1..e4478454936 100644 --- a/test/built-ins/Array/prototype/toSpliced/start-undefined-and-deleteCount-missing.js +++ b/test/built-ins/Array/prototype/toSpliced/start-undefined-and-deleteCount-missing.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toSpliced/this-value-boolean.js b/test/built-ins/Array/prototype/toSpliced/this-value-boolean.js index e9de5626f8c..c6e9af7440b 100644 --- a/test/built-ins/Array/prototype/toSpliced/this-value-boolean.js +++ b/test/built-ins/Array/prototype/toSpliced/this-value-boolean.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toSpliced/this-value-nullish.js b/test/built-ins/Array/prototype/toSpliced/this-value-nullish.js index a9190743844..fa32e409485 100644 --- a/test/built-ins/Array/prototype/toSpliced/this-value-nullish.js +++ b/test/built-ins/Array/prototype/toSpliced/this-value-nullish.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/toSpliced/unmodified.js b/test/built-ins/Array/prototype/toSpliced/unmodified.js index 3d15e465902..bce38b68e91 100644 --- a/test/built-ins/Array/prototype/toSpliced/unmodified.js +++ b/test/built-ins/Array/prototype/toSpliced/unmodified.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/with/frozen-this-value.js b/test/built-ins/Array/prototype/with/frozen-this-value.js index e3f58f1b6b3..3578de7fba7 100644 --- a/test/built-ins/Array/prototype/with/frozen-this-value.js +++ b/test/built-ins/Array/prototype/with/frozen-this-value.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/with/holes-not-preserved.js b/test/built-ins/Array/prototype/with/holes-not-preserved.js index a8426843034..3d3a260cae6 100644 --- a/test/built-ins/Array/prototype/with/holes-not-preserved.js +++ b/test/built-ins/Array/prototype/with/holes-not-preserved.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/with/ignores-species.js b/test/built-ins/Array/prototype/with/ignores-species.js index 6df66daa27b..b69290c0307 100644 --- a/test/built-ins/Array/prototype/with/ignores-species.js +++ b/test/built-ins/Array/prototype/with/ignores-species.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/with/immutable.js b/test/built-ins/Array/prototype/with/immutable.js index ae8344d9aee..b1dae8e3c18 100644 --- a/test/built-ins/Array/prototype/with/immutable.js +++ b/test/built-ins/Array/prototype/with/immutable.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/with/index-bigger-or-eq-than-length.js b/test/built-ins/Array/prototype/with/index-bigger-or-eq-than-length.js index 3cd03d25ead..932f0861b6b 100644 --- a/test/built-ins/Array/prototype/with/index-bigger-or-eq-than-length.js +++ b/test/built-ins/Array/prototype/with/index-bigger-or-eq-than-length.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/with/index-casted-to-number.js b/test/built-ins/Array/prototype/with/index-casted-to-number.js index 668d871b551..b09da4bf17b 100644 --- a/test/built-ins/Array/prototype/with/index-casted-to-number.js +++ b/test/built-ins/Array/prototype/with/index-casted-to-number.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/with/index-negative.js b/test/built-ins/Array/prototype/with/index-negative.js index 8122bc68b0e..f4db686c172 100644 --- a/test/built-ins/Array/prototype/with/index-negative.js +++ b/test/built-ins/Array/prototype/with/index-negative.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/with/index-smaller-than-minus-length.js b/test/built-ins/Array/prototype/with/index-smaller-than-minus-length.js index 679a80e9f5c..644718f66b1 100644 --- a/test/built-ins/Array/prototype/with/index-smaller-than-minus-length.js +++ b/test/built-ins/Array/prototype/with/index-smaller-than-minus-length.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/with/length-decreased-while-iterating.js b/test/built-ins/Array/prototype/with/length-decreased-while-iterating.js index 60afbf55070..a63fe0b97a9 100644 --- a/test/built-ins/Array/prototype/with/length-decreased-while-iterating.js +++ b/test/built-ins/Array/prototype/with/length-decreased-while-iterating.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/with/length-exceeding-array-length-limit.js b/test/built-ins/Array/prototype/with/length-exceeding-array-length-limit.js index 2000ec247d5..f6f2d7de493 100644 --- a/test/built-ins/Array/prototype/with/length-exceeding-array-length-limit.js +++ b/test/built-ins/Array/prototype/with/length-exceeding-array-length-limit.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/with/length-increased-while-iterating.js b/test/built-ins/Array/prototype/with/length-increased-while-iterating.js index 1465bf44a4d..be56837490d 100644 --- a/test/built-ins/Array/prototype/with/length-increased-while-iterating.js +++ b/test/built-ins/Array/prototype/with/length-increased-while-iterating.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/with/length-integer-string.js b/test/built-ins/Array/prototype/with/length-integer-string.js index 392ece8b28c..e50ce8a010a 100644 --- a/test/built-ins/Array/prototype/with/length-integer-string.js +++ b/test/built-ins/Array/prototype/with/length-integer-string.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/with/metadata/length.js b/test/built-ins/Array/prototype/with/metadata/length.js index 8646fa60211..07afcbfbaea 100644 --- a/test/built-ins/Array/prototype/with/metadata/length.js +++ b/test/built-ins/Array/prototype/with/metadata/length.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/with/metadata/name.js b/test/built-ins/Array/prototype/with/metadata/name.js index d1fc9e04088..d5d849e9667 100644 --- a/test/built-ins/Array/prototype/with/metadata/name.js +++ b/test/built-ins/Array/prototype/with/metadata/name.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/with/metadata/property-descriptor.js b/test/built-ins/Array/prototype/with/metadata/property-descriptor.js index 2f341d2b1d8..13128b08d36 100644 --- a/test/built-ins/Array/prototype/with/metadata/property-descriptor.js +++ b/test/built-ins/Array/prototype/with/metadata/property-descriptor.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/with/no-get-replaced-index.js b/test/built-ins/Array/prototype/with/no-get-replaced-index.js index 1d52a400f40..e31be0c1069 100644 --- a/test/built-ins/Array/prototype/with/no-get-replaced-index.js +++ b/test/built-ins/Array/prototype/with/no-get-replaced-index.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/with/not-a-constructor.js b/test/built-ins/Array/prototype/with/not-a-constructor.js index ff93b77a72b..5c8d8ab652e 100644 --- a/test/built-ins/Array/prototype/with/not-a-constructor.js +++ b/test/built-ins/Array/prototype/with/not-a-constructor.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/with/this-value-boolean.js b/test/built-ins/Array/prototype/with/this-value-boolean.js index 921cd634349..96b09693f3a 100644 --- a/test/built-ins/Array/prototype/with/this-value-boolean.js +++ b/test/built-ins/Array/prototype/with/this-value-boolean.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/Array/prototype/with/this-value-nullish.js b/test/built-ins/Array/prototype/with/this-value-nullish.js index 283ff8087d6..d71deb31e62 100644 --- a/test/built-ins/Array/prototype/with/this-value-nullish.js +++ b/test/built-ins/Array/prototype/with/this-value-nullish.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/TypedArray/prototype/toReversed/ignores-species.js b/test/built-ins/TypedArray/prototype/toReversed/ignores-species.js index 0362ecad72b..939f995b05c 100644 --- a/test/built-ins/TypedArray/prototype/toReversed/ignores-species.js +++ b/test/built-ins/TypedArray/prototype/toReversed/ignores-species.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/TypedArray/prototype/toReversed/immutable.js b/test/built-ins/TypedArray/prototype/toReversed/immutable.js index 98ad180e926..283b99516bc 100644 --- a/test/built-ins/TypedArray/prototype/toReversed/immutable.js +++ b/test/built-ins/TypedArray/prototype/toReversed/immutable.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/TypedArray/prototype/toReversed/length-property-ignored.js b/test/built-ins/TypedArray/prototype/toReversed/length-property-ignored.js index 5ba55a527f1..6ad40e37287 100644 --- a/test/built-ins/TypedArray/prototype/toReversed/length-property-ignored.js +++ b/test/built-ins/TypedArray/prototype/toReversed/length-property-ignored.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/TypedArray/prototype/toReversed/metadata/length.js b/test/built-ins/TypedArray/prototype/toReversed/metadata/length.js index 95f495340d0..a09002e8f0b 100644 --- a/test/built-ins/TypedArray/prototype/toReversed/metadata/length.js +++ b/test/built-ins/TypedArray/prototype/toReversed/metadata/length.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/TypedArray/prototype/toReversed/metadata/name.js b/test/built-ins/TypedArray/prototype/toReversed/metadata/name.js index 6c301f71216..57b51abeaa4 100644 --- a/test/built-ins/TypedArray/prototype/toReversed/metadata/name.js +++ b/test/built-ins/TypedArray/prototype/toReversed/metadata/name.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/TypedArray/prototype/toReversed/metadata/property-descriptor.js b/test/built-ins/TypedArray/prototype/toReversed/metadata/property-descriptor.js index bafa3cb6c18..84811c0edcf 100644 --- a/test/built-ins/TypedArray/prototype/toReversed/metadata/property-descriptor.js +++ b/test/built-ins/TypedArray/prototype/toReversed/metadata/property-descriptor.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/TypedArray/prototype/toReversed/not-a-constructor.js b/test/built-ins/TypedArray/prototype/toReversed/not-a-constructor.js index 3b6dec69198..630eba76ed5 100644 --- a/test/built-ins/TypedArray/prototype/toReversed/not-a-constructor.js +++ b/test/built-ins/TypedArray/prototype/toReversed/not-a-constructor.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/TypedArray/prototype/toReversed/this-value-invalid.js b/test/built-ins/TypedArray/prototype/toReversed/this-value-invalid.js index 512f527bc7c..8fd4c826458 100644 --- a/test/built-ins/TypedArray/prototype/toReversed/this-value-invalid.js +++ b/test/built-ins/TypedArray/prototype/toReversed/this-value-invalid.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/TypedArray/prototype/toSorted/comparefn-not-a-function.js b/test/built-ins/TypedArray/prototype/toSorted/comparefn-not-a-function.js index 59f96b6aa12..c86e546588d 100644 --- a/test/built-ins/TypedArray/prototype/toSorted/comparefn-not-a-function.js +++ b/test/built-ins/TypedArray/prototype/toSorted/comparefn-not-a-function.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/TypedArray/prototype/toSorted/comparefn-stop-after-error.js b/test/built-ins/TypedArray/prototype/toSorted/comparefn-stop-after-error.js index e4917eec39e..b7bc31e0b10 100644 --- a/test/built-ins/TypedArray/prototype/toSorted/comparefn-stop-after-error.js +++ b/test/built-ins/TypedArray/prototype/toSorted/comparefn-stop-after-error.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/TypedArray/prototype/toSorted/ignores-species.js b/test/built-ins/TypedArray/prototype/toSorted/ignores-species.js index c1fb4732e40..8a70bbd066d 100644 --- a/test/built-ins/TypedArray/prototype/toSorted/ignores-species.js +++ b/test/built-ins/TypedArray/prototype/toSorted/ignores-species.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/TypedArray/prototype/toSorted/immutable.js b/test/built-ins/TypedArray/prototype/toSorted/immutable.js index 3913dbbc86f..a528f81ef5e 100644 --- a/test/built-ins/TypedArray/prototype/toSorted/immutable.js +++ b/test/built-ins/TypedArray/prototype/toSorted/immutable.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/TypedArray/prototype/toSorted/length-property-ignored.js b/test/built-ins/TypedArray/prototype/toSorted/length-property-ignored.js index 3da9441837f..7c190ba8fa7 100644 --- a/test/built-ins/TypedArray/prototype/toSorted/length-property-ignored.js +++ b/test/built-ins/TypedArray/prototype/toSorted/length-property-ignored.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/TypedArray/prototype/toSorted/metadata/length.js b/test/built-ins/TypedArray/prototype/toSorted/metadata/length.js index 13d4370e73f..5d38f28627a 100644 --- a/test/built-ins/TypedArray/prototype/toSorted/metadata/length.js +++ b/test/built-ins/TypedArray/prototype/toSorted/metadata/length.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/TypedArray/prototype/toSorted/metadata/name.js b/test/built-ins/TypedArray/prototype/toSorted/metadata/name.js index 9d881569d1d..59bcecfa81f 100644 --- a/test/built-ins/TypedArray/prototype/toSorted/metadata/name.js +++ b/test/built-ins/TypedArray/prototype/toSorted/metadata/name.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/TypedArray/prototype/toSorted/metadata/property-descriptor.js b/test/built-ins/TypedArray/prototype/toSorted/metadata/property-descriptor.js index 41e22cb86f7..a5c4ead9e68 100644 --- a/test/built-ins/TypedArray/prototype/toSorted/metadata/property-descriptor.js +++ b/test/built-ins/TypedArray/prototype/toSorted/metadata/property-descriptor.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/TypedArray/prototype/toSorted/not-a-constructor.js b/test/built-ins/TypedArray/prototype/toSorted/not-a-constructor.js index 745d7a4bca8..6d47d98c71a 100644 --- a/test/built-ins/TypedArray/prototype/toSorted/not-a-constructor.js +++ b/test/built-ins/TypedArray/prototype/toSorted/not-a-constructor.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/TypedArray/prototype/toSorted/this-value-invalid.js b/test/built-ins/TypedArray/prototype/toSorted/this-value-invalid.js index 1debe0e0c63..3c6d8d969fa 100644 --- a/test/built-ins/TypedArray/prototype/toSorted/this-value-invalid.js +++ b/test/built-ins/TypedArray/prototype/toSorted/this-value-invalid.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/TypedArray/prototype/with/BigInt/early-type-coercion-bigint.js b/test/built-ins/TypedArray/prototype/with/BigInt/early-type-coercion-bigint.js index 51ca9a7231a..c1a9141ba7b 100644 --- a/test/built-ins/TypedArray/prototype/with/BigInt/early-type-coercion-bigint.js +++ b/test/built-ins/TypedArray/prototype/with/BigInt/early-type-coercion-bigint.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/TypedArray/prototype/with/early-type-coercion.js b/test/built-ins/TypedArray/prototype/with/early-type-coercion.js index c428a0bd392..2be53157a24 100644 --- a/test/built-ins/TypedArray/prototype/with/early-type-coercion.js +++ b/test/built-ins/TypedArray/prototype/with/early-type-coercion.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/TypedArray/prototype/with/ignores-species.js b/test/built-ins/TypedArray/prototype/with/ignores-species.js index 5c65fdeb013..7ba48035859 100644 --- a/test/built-ins/TypedArray/prototype/with/ignores-species.js +++ b/test/built-ins/TypedArray/prototype/with/ignores-species.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/TypedArray/prototype/with/immutable.js b/test/built-ins/TypedArray/prototype/with/immutable.js index eff35b607d0..265bf1f71e4 100644 --- a/test/built-ins/TypedArray/prototype/with/immutable.js +++ b/test/built-ins/TypedArray/prototype/with/immutable.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/TypedArray/prototype/with/index-bigger-or-eq-than-length.js b/test/built-ins/TypedArray/prototype/with/index-bigger-or-eq-than-length.js index 02f149d4bd9..979676e62e6 100644 --- a/test/built-ins/TypedArray/prototype/with/index-bigger-or-eq-than-length.js +++ b/test/built-ins/TypedArray/prototype/with/index-bigger-or-eq-than-length.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/TypedArray/prototype/with/index-casted-to-number.js b/test/built-ins/TypedArray/prototype/with/index-casted-to-number.js index 8f2821f2f43..22ffe7878d2 100644 --- a/test/built-ins/TypedArray/prototype/with/index-casted-to-number.js +++ b/test/built-ins/TypedArray/prototype/with/index-casted-to-number.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/TypedArray/prototype/with/index-negative.js b/test/built-ins/TypedArray/prototype/with/index-negative.js index 43d141b4b8a..3e49f8f5e1c 100644 --- a/test/built-ins/TypedArray/prototype/with/index-negative.js +++ b/test/built-ins/TypedArray/prototype/with/index-negative.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/TypedArray/prototype/with/index-smaller-than-minus-length.js b/test/built-ins/TypedArray/prototype/with/index-smaller-than-minus-length.js index 14c0da21532..42a5941cdba 100644 --- a/test/built-ins/TypedArray/prototype/with/index-smaller-than-minus-length.js +++ b/test/built-ins/TypedArray/prototype/with/index-smaller-than-minus-length.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/TypedArray/prototype/with/length-property-ignored.js b/test/built-ins/TypedArray/prototype/with/length-property-ignored.js index 4b0188c7d7f..774eb67f5b1 100644 --- a/test/built-ins/TypedArray/prototype/with/length-property-ignored.js +++ b/test/built-ins/TypedArray/prototype/with/length-property-ignored.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/TypedArray/prototype/with/metadata/length.js b/test/built-ins/TypedArray/prototype/with/metadata/length.js index 5e160c6f6c2..954e380e8f8 100644 --- a/test/built-ins/TypedArray/prototype/with/metadata/length.js +++ b/test/built-ins/TypedArray/prototype/with/metadata/length.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/TypedArray/prototype/with/metadata/name.js b/test/built-ins/TypedArray/prototype/with/metadata/name.js index 93e01ef5abd..38665972697 100644 --- a/test/built-ins/TypedArray/prototype/with/metadata/name.js +++ b/test/built-ins/TypedArray/prototype/with/metadata/name.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/TypedArray/prototype/with/metadata/property-descriptor.js b/test/built-ins/TypedArray/prototype/with/metadata/property-descriptor.js index adc9dbfe41d..8d5ae32a751 100644 --- a/test/built-ins/TypedArray/prototype/with/metadata/property-descriptor.js +++ b/test/built-ins/TypedArray/prototype/with/metadata/property-descriptor.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/TypedArray/prototype/with/not-a-constructor.js b/test/built-ins/TypedArray/prototype/with/not-a-constructor.js index 8f8cae69b7e..46fb946367a 100644 --- a/test/built-ins/TypedArray/prototype/with/not-a-constructor.js +++ b/test/built-ins/TypedArray/prototype/with/not-a-constructor.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- diff --git a/test/built-ins/TypedArray/prototype/with/this-value-invalid.js b/test/built-ins/TypedArray/prototype/with/this-value-invalid.js index 5f07a5ae950..aa6d9345b9b 100644 --- a/test/built-ins/TypedArray/prototype/with/this-value-invalid.js +++ b/test/built-ins/TypedArray/prototype/with/this-value-invalid.js @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Igalia. All rights reserved. +// Copyright (C) 2021 Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- From 4e6094f9093dfd8cccc3e2525f644cb91b6e2c82 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 4 Oct 2022 17:24:02 -0700 Subject: [PATCH 72/86] Clarify comment in toSpliced/length-casted-to-zero --- .../Array/prototype/toSpliced/length-casted-to-zero.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/built-ins/Array/prototype/toSpliced/length-casted-to-zero.js b/test/built-ins/Array/prototype/toSpliced/length-casted-to-zero.js index 92efbe7544c..8bb470d5562 100644 --- a/test/built-ins/Array/prototype/toSpliced/length-casted-to-zero.js +++ b/test/built-ins/Array/prototype/toSpliced/length-casted-to-zero.js @@ -4,7 +4,8 @@ /*--- esid: sec-array.prototype.toSpliced description: > - Array.prototype.toSpliced creates an empty array if the this value .length is not a positive integer. + Array.prototype.toSpliced treats its `this` value's `length` property as zero if the + property's value is not a positive integer. info: | Array.prototype.toSpliced ( start, deleteCount, ...items ) From 15b25959a198de78761bcd1dcad3473ceb72d25b Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 4 Oct 2022 17:49:06 -0700 Subject: [PATCH 73/86] Add a test for Array.toSpliced on an array with getters that mutate other elements of the array --- .../toSpliced/mutate-while-iterating.js | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 test/built-ins/Array/prototype/toSpliced/mutate-while-iterating.js diff --git a/test/built-ins/Array/prototype/toSpliced/mutate-while-iterating.js b/test/built-ins/Array/prototype/toSpliced/mutate-while-iterating.js new file mode 100644 index 00000000000..7513ff2e501 --- /dev/null +++ b/test/built-ins/Array/prototype/toSpliced/mutate-while-iterating.js @@ -0,0 +1,46 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced gets array elements one at a time. +info: | + Array.prototype.toSpliced ( start, deleteCount, ...items ) + + ... + 16. Repeat, while i < actualStart, + a. Let Pi be ! ToString(𝔽(i)). + b. Let iValue be ? Get(O, Pi). + c. Perform ! CreateDataPropertyOrThrow(A, Pi, iValue). + d. Set i to i + 1. + ... + 18. Repeat, while i < newLen, + a. Let Pi be ! ToString(𝔽(i)). + b. Let from be ! ToString(𝔽(r)). + c. Let fromValue be ? Get(O, from). + d. Perform ! CreateDataPropertyOrThrow(A, Pi, fromValue). + e. Set i to i + 1. + f. Set r to r + 1. + ... + +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var arr = [0, 1, 2, 3]; +Object.defineProperty(arr, "0", { + get() { + arr[1] = 42; + return 0; + } +}); +Object.defineProperty(arr, "2", { + get() { + arr[0] = 17; + arr[3] = 37; + return 2; + } +}); + +assert.compareArray(arr.toSpliced(1, 0, 0.5), [0, 0.5, 42, 2, 37]); From 9c56d74f3df4508f8b1330c67397dddb20c18b4a Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 4 Oct 2022 18:03:32 -0700 Subject: [PATCH 74/86] Rename toSpliced/length-integer-string to toSpliced/length-to-length --- .../toSpliced/{length-integer-string.js => length-tolength.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/built-ins/Array/prototype/toSpliced/{length-integer-string.js => length-tolength.js} (100%) diff --git a/test/built-ins/Array/prototype/toSpliced/length-integer-string.js b/test/built-ins/Array/prototype/toSpliced/length-tolength.js similarity index 100% rename from test/built-ins/Array/prototype/toSpliced/length-integer-string.js rename to test/built-ins/Array/prototype/toSpliced/length-tolength.js From 17a5bac61d72b507e5f6e00b9054a5ded0f2c37e Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 4 Oct 2022 18:38:53 -0700 Subject: [PATCH 75/86] Use verifyProperty in unscopables test --- .../change-array-by-copy.js | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/test/built-ins/Array/prototype/Symbol.unscopables/change-array-by-copy.js b/test/built-ins/Array/prototype/Symbol.unscopables/change-array-by-copy.js index 1b223b391ff..78ae6896ada 100644 --- a/test/built-ins/Array/prototype/Symbol.unscopables/change-array-by-copy.js +++ b/test/built-ins/Array/prototype/Symbol.unscopables/change-array-by-copy.js @@ -18,19 +18,12 @@ features: [Symbol.unscopables, change-array-by-copy] var unscopables = Array.prototype[Symbol.unscopables]; -assert.sameValue(unscopables.toReversed, true, '`toReversed` property value'); -verifyEnumerable(unscopables, 'toReversed'); -verifyWritable(unscopables, 'toReversed'); -verifyConfigurable(unscopables, 'toReversed'); - -assert.sameValue(unscopables.toSorted, true, '`toSorted` property value'); -verifyEnumerable(unscopables, 'toSorted'); -verifyWritable(unscopables, 'toSorted'); -verifyConfigurable(unscopables, 'toSorted'); - -assert.sameValue(unscopables.toSpliced, true, "`toSpliced` property value"); -verifyEnumerable(unscopables, "toSpliced"); -verifyWritable(unscopables, "toSpliced"); -verifyConfigurable(unscopables, "toSpliced"); +for (unscopable of ["toReversed", "toSorted", "toSpliced"]) { + verifyProperty(unscopables, unscopable, { + value: true, + writable: true, + configurable: true + }) +}; assert.sameValue(Object.hasOwnProperty.call(unscopables, "with"), false, "does not have `with`"); From 90c8d70760986e466134815be3610d2177c6a5c1 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 4 Oct 2022 18:40:01 -0700 Subject: [PATCH 76/86] Update steps for toSorted tests --- .../toSorted/length-decreased-while-iterating.js | 8 +++----- .../toSorted/length-increased-while-iterating.js | 8 +++----- .../TypedArray/prototype/toSorted/ignores-species.js | 5 ++--- .../TypedArray/prototype/toSorted/this-value-invalid.js | 2 +- 4 files changed, 9 insertions(+), 14 deletions(-) diff --git a/test/built-ins/Array/prototype/toSorted/length-decreased-while-iterating.js b/test/built-ins/Array/prototype/toSorted/length-decreased-while-iterating.js index abf2070ae3a..b8d441c3c06 100644 --- a/test/built-ins/Array/prototype/toSorted/length-decreased-while-iterating.js +++ b/test/built-ins/Array/prototype/toSorted/length-decreased-while-iterating.js @@ -11,11 +11,9 @@ info: | ... 3. Let len be ? LengthOfArrayLike(O). ... - 5. Let k be 0. - 6. Repeat, while k < len, - a. Let Pk be ! ToString(𝔽(k)). - b. Let kValue be ? Get(O, Pk). - ... + 6. Let sortedList be ? SortIndexedProperties(obj, len, SortCompare, false). + ... + features: [change-array-by-copy] includes: [compareArray.js] ---*/ diff --git a/test/built-ins/Array/prototype/toSorted/length-increased-while-iterating.js b/test/built-ins/Array/prototype/toSorted/length-increased-while-iterating.js index 6eebc93fbb5..c5614665b50 100644 --- a/test/built-ins/Array/prototype/toSorted/length-increased-while-iterating.js +++ b/test/built-ins/Array/prototype/toSorted/length-increased-while-iterating.js @@ -11,11 +11,9 @@ info: | ... 3. Let len be ? LengthOfArrayLike(O). ... - 5. Let k be 0. - 6. Repeat, while k < len, - a. Let Pk be ! ToString(𝔽(k)). - b. Let kValue be ? Get(O, Pk). - ... + 6. Let sortedList be ? SortIndexedProperties(obj, len, SortCompare, false). + ... + features: [change-array-by-copy] includes: [compareArray.js] ---*/ diff --git a/test/built-ins/TypedArray/prototype/toSorted/ignores-species.js b/test/built-ins/TypedArray/prototype/toSorted/ignores-species.js index 8a70bbd066d..05d6af46a6c 100644 --- a/test/built-ins/TypedArray/prototype/toSorted/ignores-species.js +++ b/test/built-ins/TypedArray/prototype/toSorted/ignores-species.js @@ -12,10 +12,9 @@ info: | 6. Let A be ? TypedArrayCreateSameType(O, Β« 𝔽(len) Β»). ... - TypedArraySpeciesCreate ( exemplar, argumentList [ , noSpeciesOverride ] ) + TypedArrayCreateSameType ( exemplar, argumentList ) ... - 2. Let defaultConstructor be the intrinsic object listed in column one of Table 63 for exemplar.[[TypedArrayName]]. - 3. If noSpeciesOverride is true, let constructor be defaultConstructor. + 2. Let constructor be the intrinsic object listed in column one of Table 63 for exemplar.[[TypedArrayName]]. ... includes: [testTypedArray.js] features: [TypedArray, change-array-by-copy] diff --git a/test/built-ins/TypedArray/prototype/toSorted/this-value-invalid.js b/test/built-ins/TypedArray/prototype/toSorted/this-value-invalid.js index 3c6d8d969fa..f5a24a32627 100644 --- a/test/built-ins/TypedArray/prototype/toSorted/this-value-invalid.js +++ b/test/built-ins/TypedArray/prototype/toSorted/this-value-invalid.js @@ -4,7 +4,7 @@ /*--- esid: sec-%typedarray%.prototype.toSorted description: > - %TypedArray%.prototype.toSorted throws if the receiver is null or undefined + %TypedArray%.prototype.toSorted throws if the receiver is not a valid TypedArray info: | %TypedArray%.prototype.toSorted ( comparefn ) From 77c919f9b4509c924de2169abfbfeb0e74872b7a Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 4 Oct 2022 18:40:37 -0700 Subject: [PATCH 77/86] Rename length-integer-string to length-tolength --- .../toSorted/{length-integer-string.js => length-tolength.js} | 0 .../with/{length-integer-string.js => length-tolength.js} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename test/built-ins/Array/prototype/toSorted/{length-integer-string.js => length-tolength.js} (100%) rename test/built-ins/Array/prototype/with/{length-integer-string.js => length-tolength.js} (100%) diff --git a/test/built-ins/Array/prototype/toSorted/length-integer-string.js b/test/built-ins/Array/prototype/toSorted/length-tolength.js similarity index 100% rename from test/built-ins/Array/prototype/toSorted/length-integer-string.js rename to test/built-ins/Array/prototype/toSorted/length-tolength.js diff --git a/test/built-ins/Array/prototype/with/length-integer-string.js b/test/built-ins/Array/prototype/with/length-tolength.js similarity index 100% rename from test/built-ins/Array/prototype/with/length-integer-string.js rename to test/built-ins/Array/prototype/with/length-tolength.js From 7cc9a9e7b779f03ce619083a0a93468a4e1a6487 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 4 Oct 2022 18:41:06 -0700 Subject: [PATCH 78/86] Check for notSameValue in toSpliced tests --- .../prototype/toSpliced/start-and-deleteCount-missing.js | 7 +++++-- .../toSpliced/start-and-deleteCount-undefineds.js | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/test/built-ins/Array/prototype/toSpliced/start-and-deleteCount-missing.js b/test/built-ins/Array/prototype/toSpliced/start-and-deleteCount-missing.js index c68404b79f7..bfc5825dca2 100644 --- a/test/built-ins/Array/prototype/toSpliced/start-and-deleteCount-missing.js +++ b/test/built-ins/Array/prototype/toSpliced/start-and-deleteCount-missing.js @@ -19,6 +19,9 @@ features: [change-array-by-copy] includes: [compareArray.js] ---*/ -var result = ["first", "second", "third"].toSpliced(); +let arr = ["first", "second", "third"]; +let result = arr.toSpliced(); + +assert.compareArray(result, arr); +assert.notSameValue(result, arr); -assert.compareArray(result, ["first", "second", "third"]); diff --git a/test/built-ins/Array/prototype/toSpliced/start-and-deleteCount-undefineds.js b/test/built-ins/Array/prototype/toSpliced/start-and-deleteCount-undefineds.js index 82781bfad30..0f755fadb3c 100644 --- a/test/built-ins/Array/prototype/toSpliced/start-and-deleteCount-undefineds.js +++ b/test/built-ins/Array/prototype/toSpliced/start-and-deleteCount-undefineds.js @@ -21,6 +21,9 @@ features: [change-array-by-copy] includes: [compareArray.js] ---*/ -var result = ["first", "second", "third"].toSpliced(undefined, undefined); +let arr = ["first", "second", "third"]; +let result = arr.toSpliced(undefined, undefined); + +assert.compareArray(result, arr); +assert.notSameValue(result, arr); -assert.compareArray(result, ["first", "second", "third"]); From c5bbdcf3b4406e35b4b1819fed3276e689a6dbf1 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 4 Oct 2022 18:41:32 -0700 Subject: [PATCH 79/86] Update steps in toReversed tests --- .../TypedArray/prototype/toReversed/ignores-species.js | 5 ++--- .../TypedArray/prototype/toReversed/this-value-invalid.js | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/test/built-ins/TypedArray/prototype/toReversed/ignores-species.js b/test/built-ins/TypedArray/prototype/toReversed/ignores-species.js index 939f995b05c..eccce6b92b0 100644 --- a/test/built-ins/TypedArray/prototype/toReversed/ignores-species.js +++ b/test/built-ins/TypedArray/prototype/toReversed/ignores-species.js @@ -12,10 +12,9 @@ info: | 4. Let A be ? TypedArrayCreateSameType(O, Β« 𝔽(length) Β»). ... - TypedArraySpeciesCreate ( exemplar, argumentList [ , noSpeciesOverride ] ) + TypedArrayCreateSameType ( exemplar, argumentList ) ... - 2. Let defaultConstructor be the intrinsic object listed in column one of Table 63 for exemplar.[[TypedArrayName]]. - 3. If noSpeciesOverride is true, let constructor be defaultConstructor. + 2. Let constructor be the intrinsic object listed in column one of Table 63 for exemplar.[[TypedArrayName]]. ... includes: [testTypedArray.js] features: [TypedArray, change-array-by-copy] diff --git a/test/built-ins/TypedArray/prototype/toReversed/this-value-invalid.js b/test/built-ins/TypedArray/prototype/toReversed/this-value-invalid.js index 8fd4c826458..7f031ce2a93 100644 --- a/test/built-ins/TypedArray/prototype/toReversed/this-value-invalid.js +++ b/test/built-ins/TypedArray/prototype/toReversed/this-value-invalid.js @@ -4,7 +4,7 @@ /*--- esid: sec-%typedarray%.prototype.toReversed description: > - %TypedArray%.prototype.toReversed throws if the receiver is null or undefined + %TypedArray%.prototype.toReversed throws if the receiver is not a valid TypedArray info: | %TypedArray%.prototype.toReversed ( ) From 8e9df5e0d25745192737a873b5df5abbb80e412f Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 4 Oct 2022 18:41:59 -0700 Subject: [PATCH 80/86] Fixes for TypedArray length-property-ignored and this-value-invalid tests Use CompareArray in typed array tests Check BigInts and detached buffers as invalid `this` values in this-value-invalid tests Delete length property after overriding in length-property-ignored.js --- .../toReversed/length-property-ignored.js | 25 +++++++++------ .../toReversed/this-value-invalid.js | 19 ++++++++--- .../toSorted/length-property-ignored.js | 32 +++++++++++-------- .../prototype/toSorted/this-value-invalid.js | 17 +++++++--- .../prototype/with/length-property-ignored.js | 25 +++++++++------ 5 files changed, 76 insertions(+), 42 deletions(-) diff --git a/test/built-ins/TypedArray/prototype/toReversed/length-property-ignored.js b/test/built-ins/TypedArray/prototype/toReversed/length-property-ignored.js index 6ad40e37287..c3a5ed7d859 100644 --- a/test/built-ins/TypedArray/prototype/toReversed/length-property-ignored.js +++ b/test/built-ins/TypedArray/prototype/toReversed/length-property-ignored.js @@ -19,27 +19,32 @@ testWithTypedArrayConstructors(TA => { var ta = new TA([0, 1, 2]); Object.defineProperty(ta, "length", { value: 2 }) var res = ta.toReversed(); - assert.compareArray([res[0], res[1], res[2], res[3]], [2, 1, 0, undefined]); + assert.compareArray(res, [2, 1, 0]); + assert.sameValue(res.length, 3); ta = new TA([0, 1, 2]); Object.defineProperty(ta, "length", { value: 5 }); res = ta.toReversed(); - assert.compareArray([res[0], res[1], res[2], res[3]], [2, 1, 0, undefined]); + assert.compareArray(res, [2, 1, 0]); + assert.sameValue(res.length, 3); }); -var length; -Object.defineProperty(TypedArray.prototype, "length", { - get: () => length, -}); +function setLength(length) { + Object.defineProperty(TypedArray.prototype, "length", { + get: () => length, + }); +} testWithTypedArrayConstructors(TA => { var ta = new TA([0, 1, 2]); - length = 2; + setLength(2); var res = ta.toReversed(); - assert.compareArray([res[0], res[1], res[2], res[3]], [2, 1, 0, undefined]); + setLength(3); + assert.compareArray(res, [2, 1, 0]); - length = 5; + setLength(5); res = ta.toReversed(); - assert.compareArray([res[0], res[1], res[2], res[3]], [2, 1, 0, undefined]); + setLength(3); + assert.compareArray(res, [2, 1, 0]); }); diff --git a/test/built-ins/TypedArray/prototype/toReversed/this-value-invalid.js b/test/built-ins/TypedArray/prototype/toReversed/this-value-invalid.js index 7f031ce2a93..c0b46cf4dd3 100644 --- a/test/built-ins/TypedArray/prototype/toReversed/this-value-invalid.js +++ b/test/built-ins/TypedArray/prototype/toReversed/this-value-invalid.js @@ -25,11 +25,20 @@ var invalidValues = { '[1, 2, 3]': [1, 2, 3], '{ 0: 1, 1: 2, 2: 3, length: 3 }': { 0: 1, 1: 2, 2: 3, length: 3 }, 'Uint8Array.prototype': Uint8Array.prototype, + '1n': 1n, }; -Object.keys(invalidValues).forEach(desc => { - var value = invalidValues[desc]; - assert.throws(TypeError, () => { - TypedArray.prototype.toReversed.call(value); - }, `${desc} is not a valid TypedArray`); +Object.entries(invalidValues).forEach(value => { + assert.throws(TypeError, () => { + TypedArray.prototype.toReversed.call(value[1]); + }, `${value[0]} is not a valid TypedArray`); +}); + +testWithTypedArrayConstructors(function(TA) { + let buffer = new ArrayBuffer(8); + let sample = new TA(buffer, 0, 1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, () => { + sample.toReversed(); + }, `array has a detached buffer`); }); diff --git a/test/built-ins/TypedArray/prototype/toSorted/length-property-ignored.js b/test/built-ins/TypedArray/prototype/toSorted/length-property-ignored.js index 7c190ba8fa7..c150b8d6bb7 100644 --- a/test/built-ins/TypedArray/prototype/toSorted/length-property-ignored.js +++ b/test/built-ins/TypedArray/prototype/toSorted/length-property-ignored.js @@ -19,27 +19,33 @@ testWithTypedArrayConstructors(TA => { var ta = new TA([3, 1, 2]); Object.defineProperty(ta, "length", { value: 2 }) var res = ta.toSorted() - assert.compareArray([res[0], res[1], res[2], res[3]], [1, 2, 3, undefined]); + assert.compareArray(res, [1, 2, 3]); + assert.sameValue(res.length, 3); ta = new TA([3, 1, 2]); Object.defineProperty(ta, "length", { value: 5 }); - res = ta.toSorted() - assert.compareArray([res[0], res[1], res[2], res[3]], [1, 2, 3, undefined]); + res = ta.toSorted(); + assert.compareArray(res, [1, 2, 3]); + assert.sameValue(res.length, 3); }); -var length; -Object.defineProperty(TypedArray.prototype, "length", { - get: () => length, -}); +function setLength(length) { + Object.defineProperty(TypedArray.prototype, "length", { + get: () => length, + }); +} testWithTypedArrayConstructors(TA => { var ta = new TA([3, 1, 2]); - length = 2; - var res = ta.toSorted() - assert.compareArray([res[0], res[1], res[2], res[3]], [1, 2, 3, undefined]); + setLength(2); + var res = ta.toSorted(); + setLength(3); + assert.compareArray(res, [1, 2, 3]); + + setLength(5); + res = ta.toSorted(); + setLength(3); - length = 5; - res = ta.toSorted() - assert.compareArray([res[0], res[1], res[2], res[3]], [1, 2, 3, undefined]); + assert.compareArray(res, [1, 2, 3]); }); diff --git a/test/built-ins/TypedArray/prototype/toSorted/this-value-invalid.js b/test/built-ins/TypedArray/prototype/toSorted/this-value-invalid.js index f5a24a32627..3d4d347c81b 100644 --- a/test/built-ins/TypedArray/prototype/toSorted/this-value-invalid.js +++ b/test/built-ins/TypedArray/prototype/toSorted/this-value-invalid.js @@ -25,11 +25,20 @@ var invalidValues = { '[1, 2, 3]': [1, 2, 3], '{ 0: 1, 1: 2, 2: 3, length: 3 }': { 0: 1, 1: 2, 2: 3, length: 3 }, 'Uint8Array.prototype': Uint8Array.prototype, + '1n': 1n, }; -Object.keys(invalidValues).forEach(desc => { - var value = invalidValues[desc]; +Object.entries(invalidValues).forEach(value => { assert.throws(TypeError, () => { - TypedArray.prototype.toSorted.call(value); - }, `${desc} is not a valid TypedArray`); + TypedArray.prototype.toSorted.call(value[1]); + }, `${value[0]} is not a valid TypedArray`); +}); + +testWithTypedArrayConstructors(function(TA) { + let buffer = new ArrayBuffer(8); + let sample = new TA(buffer, 0, 1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, () => { + sample.toSorted(); + }, `array has a detached buffer`); }); diff --git a/test/built-ins/TypedArray/prototype/with/length-property-ignored.js b/test/built-ins/TypedArray/prototype/with/length-property-ignored.js index 774eb67f5b1..b8276ce51da 100644 --- a/test/built-ins/TypedArray/prototype/with/length-property-ignored.js +++ b/test/built-ins/TypedArray/prototype/with/length-property-ignored.js @@ -19,27 +19,32 @@ testWithTypedArrayConstructors(TA => { var ta = new TA([3, 1, 2]); Object.defineProperty(ta, "length", { value: 2 }) var res = ta.with(0, 0); - assert.compareArray([res[0], res[1], res[2], res[3]], [0, 1, 2, undefined]); + assert.compareArray(res, [0, 1, 2]); + assert.sameValue(res.length, 3); ta = new TA([3, 1, 2]); Object.defineProperty(ta, "length", { value: 5 }); res = ta.with(0, 0); - assert.compareArray([res[0], res[1], res[2], res[3]], [0, 1, 2, undefined]); + assert.compareArray(res, [0, 1, 2]); + assert.sameValue(res.length, 3); }); -var length; -Object.defineProperty(TypedArray.prototype, "length", { - get: () => length, -}); +function setLength(length) { + Object.defineProperty(TypedArray.prototype, "length", { + get: () => length, + }); +} testWithTypedArrayConstructors(TA => { var ta = new TA([3, 1, 2]); - length = 2; + setLength(2); var res = ta.with(0, 0); - assert.compareArray([res[0], res[1], res[2], res[3]], [0, 1, 2, undefined]); + setLength(3); + assert.compareArray(res, [0, 1, 2]); - length = 5; + setLength(5); res = ta.with(0, 0); - assert.compareArray([res[0], res[1], res[2], res[3]], [0, 1, 2, undefined]); + setLength(3); + assert.compareArray(res, [0, 1, 2]); }); From d0c6700b82fb8dd59f0c9656db2bf23e1b993f9b Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 4 Oct 2022 18:42:52 -0700 Subject: [PATCH 81/86] Require calls <= 1 in toSorted/comparefn-stop-after-error --- .../TypedArray/prototype/toSorted/comparefn-stop-after-error.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/built-ins/TypedArray/prototype/toSorted/comparefn-stop-after-error.js b/test/built-ins/TypedArray/prototype/toSorted/comparefn-stop-after-error.js index b7bc31e0b10..3fe2004c15f 100644 --- a/test/built-ins/TypedArray/prototype/toSorted/comparefn-stop-after-error.js +++ b/test/built-ins/TypedArray/prototype/toSorted/comparefn-stop-after-error.js @@ -29,5 +29,5 @@ testWithTypedArrayConstructors(TA => { } }); } catch (e) {} - assert.sameValue(calls, 1, "compareFn is not called after an error"); + assert.sameValue(calls <= 1, true, "compareFn is not called after an error"); }); From 9f81c96d376eba8d43c15c9b1081a2c0e8b3a4cd Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Mon, 17 Oct 2022 16:24:54 -0700 Subject: [PATCH 82/86] Update test/built-ins/TypedArray/prototype/toReversed/this-value-invalid.js Co-authored-by: Ms2ger --- .../TypedArray/prototype/toReversed/this-value-invalid.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/built-ins/TypedArray/prototype/toReversed/this-value-invalid.js b/test/built-ins/TypedArray/prototype/toReversed/this-value-invalid.js index c0b46cf4dd3..648630a9470 100644 --- a/test/built-ins/TypedArray/prototype/toReversed/this-value-invalid.js +++ b/test/built-ins/TypedArray/prototype/toReversed/this-value-invalid.js @@ -38,7 +38,7 @@ testWithTypedArrayConstructors(function(TA) { let buffer = new ArrayBuffer(8); let sample = new TA(buffer, 0, 1); $DETACHBUFFER(sample.buffer); - assert.throws(TypeError, () => { - sample.toReversed(); - }, `array has a detached buffer`); + assert.throws(TypeError, () => { + sample.toReversed(); + }, `array has a detached buffer`); }); From 25aa62fee658479c451d0b0c6a46a0aa9b133b91 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Mon, 17 Oct 2022 17:12:53 -0700 Subject: [PATCH 83/86] Update test/built-ins/TypedArray/prototype/toSorted/this-value-invalid.js Co-authored-by: Ms2ger --- .../TypedArray/prototype/toSorted/this-value-invalid.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/built-ins/TypedArray/prototype/toSorted/this-value-invalid.js b/test/built-ins/TypedArray/prototype/toSorted/this-value-invalid.js index 3d4d347c81b..961c1ff6093 100644 --- a/test/built-ins/TypedArray/prototype/toSorted/this-value-invalid.js +++ b/test/built-ins/TypedArray/prototype/toSorted/this-value-invalid.js @@ -38,7 +38,7 @@ testWithTypedArrayConstructors(function(TA) { let buffer = new ArrayBuffer(8); let sample = new TA(buffer, 0, 1); $DETACHBUFFER(sample.buffer); - assert.throws(TypeError, () => { - sample.toSorted(); - }, `array has a detached buffer`); + assert.throws(TypeError, () => { + sample.toSorted(); + }, `array has a detached buffer`); }); From 67504a60edcd7e07333b6e0aac328f97ff832bcc Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Mon, 17 Oct 2022 17:13:42 -0700 Subject: [PATCH 84/86] Update test/built-ins/Array/prototype/Symbol.unscopables/change-array-by-copy.js Co-authored-by: Ms2ger --- .../Array/prototype/Symbol.unscopables/change-array-by-copy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/built-ins/Array/prototype/Symbol.unscopables/change-array-by-copy.js b/test/built-ins/Array/prototype/Symbol.unscopables/change-array-by-copy.js index 78ae6896ada..4e734f8ee60 100644 --- a/test/built-ins/Array/prototype/Symbol.unscopables/change-array-by-copy.js +++ b/test/built-ins/Array/prototype/Symbol.unscopables/change-array-by-copy.js @@ -18,7 +18,7 @@ features: [Symbol.unscopables, change-array-by-copy] var unscopables = Array.prototype[Symbol.unscopables]; -for (unscopable of ["toReversed", "toSorted", "toSpliced"]) { +for (const unscopable of ["toReversed", "toSorted", "toSpliced"]) { verifyProperty(unscopables, unscopable, { value: true, writable: true, From 5fa7561e523275db984509130664f0fa79e5b23d Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Mon, 17 Oct 2022 17:37:56 -0600 Subject: [PATCH 85/86] Test with Boolean.prototype.length set to a number in this-value-boolean tests --- .../prototype/toReversed/this-value-boolean.js | 6 +++--- .../prototype/toSorted/this-value-boolean.js | 11 +++++++++++ .../prototype/toSpliced/this-value-boolean.js | 10 ++++++++++ .../Array/prototype/with/this-value-boolean.js | 16 ++++++++++++++++ 4 files changed, 40 insertions(+), 3 deletions(-) diff --git a/test/built-ins/Array/prototype/toReversed/this-value-boolean.js b/test/built-ins/Array/prototype/toReversed/this-value-boolean.js index ccba5a2abe3..a9534ccea89 100644 --- a/test/built-ins/Array/prototype/toReversed/this-value-boolean.js +++ b/test/built-ins/Array/prototype/toReversed/this-value-boolean.js @@ -19,9 +19,9 @@ assert.compareArray(Array.prototype.toReversed.call(true), []); assert.compareArray(Array.prototype.toReversed.call(false), []); /* Add length and indexed properties to `Boolean.prototype` */ -Boolean.prototype.length = function () { return 42; } -assert.compareArray(Array.prototype.toReversed.call(true), []); -assert.compareArray(Array.prototype.toReversed.call(false), []); +Boolean.prototype.length = 3; +assert.compareArray(Array.prototype.toReversed.call(true), [undefined, undefined, undefined]); +assert.compareArray(Array.prototype.toReversed.call(false), [undefined, undefined, undefined]); delete Boolean.prototype.length; Boolean.prototype[0] = "monkeys"; Boolean.prototype[2] = "bogus"; diff --git a/test/built-ins/Array/prototype/toSorted/this-value-boolean.js b/test/built-ins/Array/prototype/toSorted/this-value-boolean.js index 7320dd1cee4..27b05c44f4a 100644 --- a/test/built-ins/Array/prototype/toSorted/this-value-boolean.js +++ b/test/built-ins/Array/prototype/toSorted/this-value-boolean.js @@ -17,3 +17,14 @@ includes: [compareArray.js] assert.compareArray(Array.prototype.toSorted.call(true), []); assert.compareArray(Array.prototype.toSorted.call(false), []); + + +/* Add length and indexed properties to `Boolean.prototype` */ +Boolean.prototype.length = 3; +assert.compareArray(Array.prototype.toSorted.call(true), [undefined, undefined, undefined]); +assert.compareArray(Array.prototype.toSorted.call(false), [undefined, undefined, undefined]); +delete Boolean.prototype.length; +Boolean.prototype[0] = "monkeys"; +Boolean.prototype[2] = "bogus"; +assert.compareArray(Array.prototype.toSorted.call(true), []); +assert.compareArray(Array.prototype.toSorted.call(false), []); diff --git a/test/built-ins/Array/prototype/toSpliced/this-value-boolean.js b/test/built-ins/Array/prototype/toSpliced/this-value-boolean.js index c6e9af7440b..fd00b3098d5 100644 --- a/test/built-ins/Array/prototype/toSpliced/this-value-boolean.js +++ b/test/built-ins/Array/prototype/toSpliced/this-value-boolean.js @@ -17,3 +17,13 @@ includes: [compareArray.js] assert.compareArray(Array.prototype.toSpliced.call(true, 0, 0), []); assert.compareArray(Array.prototype.toSpliced.call(false, 0, 0), []); + +/* Add length and indexed properties to `Boolean.prototype` */ +Boolean.prototype.length = 3; +assert.compareArray(Array.prototype.toSpliced.call(true, 0, 0), [undefined, undefined, undefined]); +assert.compareArray(Array.prototype.toSpliced.call(false, 0, 0), [undefined, undefined, undefined]); +delete Boolean.prototype.length; +Boolean.prototype[0] = "monkeys"; +Boolean.prototype[2] = "bogus"; +assert.compareArray(Array.prototype.toSpliced.call(true, 0, 0), []); +assert.compareArray(Array.prototype.toSpliced.call(false, 0, 0), []); diff --git a/test/built-ins/Array/prototype/with/this-value-boolean.js b/test/built-ins/Array/prototype/with/this-value-boolean.js index 96b09693f3a..e46901f24aa 100644 --- a/test/built-ins/Array/prototype/with/this-value-boolean.js +++ b/test/built-ins/Array/prototype/with/this-value-boolean.js @@ -21,3 +21,19 @@ Boolean.prototype[1] = 1; assert.compareArray(Array.prototype.with.call(true, 0, 2), [2, 1]); assert.compareArray(Array.prototype.with.call(false, 0, 2), [2, 1]); + +/* Add length and indexed properties to `Boolean.prototype` */ +Boolean.prototype.length = 3; +delete Boolean.prototype[0]; +delete Boolean.prototype[1]; +assert.compareArray(Array.prototype.with.call(true, 0, 2), [2, undefined, undefined]); +assert.compareArray(Array.prototype.with.call(false, 0, 2), [2, undefined, undefined]); +delete Boolean.prototype.length; +Boolean.prototype[0] = "monkeys"; +Boolean.prototype[2] = "bogus"; +assert.throws(RangeError, + () => compareArray(Array.prototype.with.call(true, 0, 2)), + "Array.prototype.with on object with undefined length"); +assert.throws(RangeError, + () => compareArray(Array.prototype.with.call(false, 0, 2)), + "Array.prototype.with on object with undefined length"); From b8c381f9e6eb076366d8410b0b955569960b64e7 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Mon, 17 Oct 2022 18:12:35 -0600 Subject: [PATCH 86/86] Expand steps in comments in toSpliced/elements-read-in-order --- .../toSpliced/elements-read-in-order.js | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/test/built-ins/Array/prototype/toSpliced/elements-read-in-order.js b/test/built-ins/Array/prototype/toSpliced/elements-read-in-order.js index 002b31e8ef6..9f2d96291d0 100644 --- a/test/built-ins/Array/prototype/toSpliced/elements-read-in-order.js +++ b/test/built-ins/Array/prototype/toSpliced/elements-read-in-order.js @@ -7,7 +7,26 @@ description: Array.prototype.toSpliced reads the items of the original array in info: | 22.1.3.25 Array.prototype.toSpliced (start, deleteCount , ...items ) - Steps 14-18 + ... + 14. Let i be 0. + 15. Let r be actualStart + actualDeleteCount. + 16. Repeat, while i < actualStart, + a. Let Pi be ! ToString(𝔽(i)). + b. Let iValue be ? Get(O, Pi). + c. Perform ! CreateDataPropertyOrThrow(A, Pi, iValue). + d. Set i to i + 1. + 17. For each element E of items, do + a. Let Pi be ! ToString(𝔽(i)). + b. Perform ! CreateDataPropertyOrThrow(A, Pi, E). + c. Set i to i + 1. + 18. Repeat, while i < newLen, + a. Let Pi be ! ToString(𝔽(i)). + b. Let from be ! ToString(𝔽(r)). + c. Let fromValue be ? Get(O, from). + d. Perform ! CreateDataPropertyOrThrow(A, Pi, fromValue). + e. Set i to i + 1. + f. Set r to r + 1. + ... features: [change-array-by-copy] includes: [compareArray.js]