Skip to content

Commit

Permalink
Use compareArray instead of deepEqual
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo authored and catamorphism committed May 30, 2022
1 parent fe9ef0d commit 71a83f7
Show file tree
Hide file tree
Showing 50 changed files with 129 additions and 129 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand All @@ -36,4 +36,4 @@ var arrayLike = {

Array.prototype.toReversed.call(arrayLike);

assert.deepEqual(order, [2, 1, 0]);
assert.compareArray(order, [2, 1, 0]);
Original file line number Diff line number Diff line change
Expand Up @@ -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));
4 changes: 2 additions & 2 deletions test/built-ins/Array/prototype/toReversed/immutable.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Original file line number Diff line number Diff line change
Expand Up @@ -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 }), []);
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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]);
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -27,4 +27,4 @@ Object.defineProperty(arr, "0", {
}
});

assert.deepEqual(arr.toReversed(), [2, 1, 0]);
assert.compareArray(arr.toReversed(), [2, 1, 0]);
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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]);
Original file line number Diff line number Diff line change
Expand Up @@ -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), []);
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand All @@ -41,4 +41,4 @@ assert.throws(StopToSorted, function() {
});
});

assert.deepEqual(getCalls, [0, 1, 2]);
assert.compareArray(getCalls, [0, 1, 2]);
Original file line number Diff line number Diff line change
Expand Up @@ -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));
4 changes: 2 additions & 2 deletions test/built-ins/Array/prototype/toSorted/immutable.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Original file line number Diff line number Diff line change
Expand Up @@ -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 }), []);
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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]);
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -28,4 +28,4 @@ Object.defineProperty(arr, "0", {
}
});

assert.deepEqual(arr.toSorted(), [0, 3, 5]);
assert.compareArray(arr.toSorted(), [0, 3, 5]);
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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]);
6 changes: 3 additions & 3 deletions test/built-ins/Array/prototype/toSorted/this-value-boolean.js
Original file line number Diff line number Diff line change
Expand Up @@ -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), []);
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Original file line number Diff line number Diff line change
Expand Up @@ -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]
);
Original file line number Diff line number Diff line change
Expand Up @@ -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"]);
Original file line number Diff line number Diff line change
Expand Up @@ -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"]);
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ info: |
a. Let actualDeleteCount be len - actualStart.
...
features: [change-array-by-copy]
includes: [deepEqual.js]
includes: [compareArray.js]
---*/

var arrayLike = {
Expand All @@ -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"]);
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ info: |
a. Let actualDeleteCount be len - actualStart.
...
features: [change-array-by-copy]
includes: [deepEqual.js]
includes: [compareArray.js]
---*/

var order = [];
Expand All @@ -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]);
4 changes: 2 additions & 2 deletions test/built-ins/Array/prototype/toSpliced/frozen-this-value.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ 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]);
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]);
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ info: |
d. Perform ? CreateDataPropertyOrThrow(A, Pk, fromValue).
e. Set k to k + 1.
...
includes: [deepEqual.js]
includes: [compareArray.js]
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.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]);

0 comments on commit 71a83f7

Please sign in to comment.