Skip to content

Commit

Permalink
Revert "Merge pull request #3219 from tc39/rwaldron/migrate-comparear…
Browse files Browse the repository at this point in the history
…ray"

This reverts commit b690cb6, reversing
changes made to 50dd431. This is
necessary because the reverted changeset reduced coverage by an unknown
extent.
  • Loading branch information
jugglinmike authored and rwaldron committed Oct 1, 2021
1 parent c7ca06a commit d9ddf80
Show file tree
Hide file tree
Showing 251 changed files with 2,806 additions and 2,857 deletions.
15 changes: 6 additions & 9 deletions harness/compareArray.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,17 @@ compareArray.isSameValue = function(a, b) {
return a === b;
};

compareArray.format = function(thingWithALengthPropertyAndNumericIndices) {
return `[${[].map.call(thingWithALengthPropertyAndNumericIndices, String).join(', ')}]`;
compareArray.format = function(array) {
return `[${array.map(String).join(', ')}]`;
};

assert.compareArray = function(actual, expected, message) {
message = message === undefined ? '' : message;
assert(actual != null, `First argument shouldn't be nullish. ${message}`);
assert(expected != null, `Second argument shouldn't be nullish. ${message}`);
var format = compareArray.format;
var result = compareArray(actual, expected);

// The following prevents actual and expected from being iterated and evaluated
// more than once unless absolutely necessary.
if (!result) {
assert(false, `Expected ${format(actual)} and ${format(expected)} to have the same contents. ${message}`);
}
assert(
compareArray(actual, expected),
`Expected ${format(actual)} and ${format(expected)} to have the same contents. ${message}`
);
};
2 changes: 1 addition & 1 deletion src/async-generators/yield-spread-arr-multiple.case
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ item.then(({ done, value }) => {
item = iter.next(value);

item.then(({ done, value }) => {
assert.compareArray(value, arr);
assert(compareArray(value, arr));
assert.sameValue(done, false);
}).then($DONE, $DONE);
}).catch($DONE);
2 changes: 1 addition & 1 deletion src/class-elements/redeclaration-symbol.case
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ verifyProperty(c, y, {
configurable: true
});

assert.compareArray(x, ["a", "b", "c"]);
assert(compareArray(x, ["a", "b", "c"]));
2 changes: 1 addition & 1 deletion src/class-elements/redeclaration.case
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ verifyProperty(c, "y", {
configurable: true
});

assert.compareArray(x, ["a", "b", "c", "d"]);
assert(compareArray(x, ["a", "b", "c", "d"]));
2 changes: 1 addition & 1 deletion src/dstr-assignment/obj-rest-order.case
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ Object.defineProperty(o, Symbol('foo'), { get: () => { calls.push("Symbol(foo)")
//- vals
o
//- body
assert.compareArray(calls, [1, 'z', 'a', "Symbol(foo)"]);
assert(compareArray(calls, [1, 'z', 'a', "Symbol(foo)"]));
assert.sameValue(Object.keys(rest).length, 3);
2 changes: 1 addition & 1 deletion src/generators/yield-spread-arr-multiple.case
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ iter.next(false);
item = iter.next(['a', 'b', 'c']);
item = iter.next(item.value);

assert.compareArray(item.value, arr);
assert(compareArray(item.value, arr));
assert.sameValue(item.done, false);
2 changes: 1 addition & 1 deletion src/spread/obj-spread-order.case
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ Object.defineProperty(o, Symbol('foo'), { get: () => { calls.push("Symbol(foo)")
//- params
obj
//- body
assert.compareArray(calls, [1, 'z', 'a', "Symbol(foo)"]);
assert(compareArray(calls, [1, 'z', 'a', "Symbol(foo)"]));
assert.sameValue(Object.keys(obj).length, 3);
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,21 @@ function concatTypedArray(type, elems, modulo) {
ta_by_len[i] = items[i] = modulo === false ? i : elems % modulo;
}
var ta = new type(items);
assert.compareArray([].concat(ta, ta), [ta, ta],
'[].concat(new type(items), new type(items)) must return [ta, ta]'
assert(
compareArray([].concat(ta, ta), [ta, ta]),
'compareArray([].concat(ta, ta), [ta, ta]) must return true'
);
ta[Symbol.isConcatSpreadable] = true;
assert.compareArray([].concat(ta), items, '[].concat(new type(items)) returns items');

assert.compareArray([].concat(ta_by_len, ta_by_len), [ta_by_len, ta_by_len],
'[].concat(new type(elems), new type(elems)) must return [ta_by_len, ta_by_len]'
assert(
compareArray([].concat(ta_by_len, ta_by_len), [ta_by_len, ta_by_len]),
'compareArray([].concat(ta_by_len, ta_by_len), [ta_by_len, ta_by_len]) must return true'
);
ta_by_len[Symbol.isConcatSpreadable] = true;
assert.compareArray([].concat(ta_by_len), items,
'[].concat(new type(elems)) returns items'
assert(
compareArray([].concat(ta_by_len), items),
'compareArray([].concat(ta_by_len), items) must return true'
);

// TypedArray with fake `length`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ function concatTypedArray(type, elems, modulo) {
ta_by_len[i] = items[i] = modulo === false ? i : elems % modulo;
}
var ta = new type(items);
assert.compareArray(
[].concat(ta, ta), [ta, ta],
'[].concat(new type(items), new type(items)) must return [ta, ta]'
assert(
compareArray([].concat(ta, ta), [ta, ta]),
'compareArray([].concat(ta, ta), [ta, ta]) must return true'
);
ta[Symbol.isConcatSpreadable] = true;
assert.compareArray([].concat(ta), items, '[].concat(new type(items)) returns items');

assert.compareArray(
[].concat(ta_by_len, ta_by_len), [ta_by_len, ta_by_len],
'[].concat(new type(elems), new type(elems)) must return [ta_by_len, ta_by_len]'
assert(
compareArray([].concat(ta_by_len, ta_by_len), [ta_by_len, ta_by_len]),
'compareArray([].concat(ta_by_len, ta_by_len), [ta_by_len, ta_by_len]) must return true'
);
ta_by_len[Symbol.isConcatSpreadable] = true;
assert.compareArray(
[].concat(ta_by_len), items,
'[].concat(new type(elems)) returns items'
assert(
compareArray([].concat(ta_by_len), items),
'compareArray([].concat(ta_by_len), items) must return true'
);

// TypedArray with fake `length`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,18 @@ info: |
includes: [compareArray.js]
---*/

assert.compareArray(
['a', 'b', 'c', 'd', 'e', 'f'].copyWithin(0, 0), ['a', 'b', 'c', 'd', 'e', 'f'],
'["a", "b", "c", "d", "e", "f"].copyWithin(0, 0) must return ["a", "b", "c", "d", "e", "f"]'
);
assert(compareArray(
['a', 'b', 'c', 'd', 'e', 'f'].copyWithin(0, 0), ['a', 'b', 'c', 'd', 'e', 'f']
), 'compareArray( ["a", "b", "c", "d", "e", "f"].copyWithin(0, 0), ["a", "b", "c", "d", "e", "f"] ) must return true');

assert.compareArray(
['a', 'b', 'c', 'd', 'e', 'f'].copyWithin(0, 2), ['c', 'd', 'e', 'f', 'e', 'f'],
'["a", "b", "c", "d", "e", "f"].copyWithin(0, 2) must return ["c", "d", "e", "f", "e", "f"]'
);
assert(compareArray(
['a', 'b', 'c', 'd', 'e', 'f'].copyWithin(0, 2), ['c', 'd', 'e', 'f', 'e', 'f']
), 'compareArray( ["a", "b", "c", "d", "e", "f"].copyWithin(0, 2), ["c", "d", "e", "f", "e", "f"] ) must return true');

assert.compareArray(
['a', 'b', 'c', 'd', 'e', 'f'].copyWithin(3, 0), ['a', 'b', 'c', 'a', 'b', 'c'],
'["a", "b", "c", "d", "e", "f"].copyWithin(3, 0) must return ["a", "b", "c", "a", "b", "c"]'
);
assert(compareArray(
['a', 'b', 'c', 'd', 'e', 'f'].copyWithin(3, 0), ['a', 'b', 'c', 'a', 'b', 'c']
), 'compareArray( ["a", "b", "c", "d", "e", "f"].copyWithin(3, 0), ["a", "b", "c", "a", "b", "c"] ) must return true');

assert.compareArray(
[0, 1, 2, 3, 4, 5].copyWithin(1, 4), [0, 4, 5, 3, 4, 5],
'[0, 1, 2, 3, 4, 5].copyWithin(1, 4) must return [0, 4, 5, 3, 4, 5]'
);
assert(compareArray(
[0, 1, 2, 3, 4, 5].copyWithin(1, 4), [0, 4, 5, 3, 4, 5]
), 'compareArray( [0, 1, 2, 3, 4, 5].copyWithin(1, 4), [0, 4, 5, 3, 4, 5] ) must return true');
10 changes: 5 additions & 5 deletions test/built-ins/Map/iterable-calls-set.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ Map.prototype.set = function(k, v) {

var map = new Map(iterable);

assert.sameValue(counter, 2, 'The value of counter is expected to be 2');
assert.sameValue(counter, 2, "`Map.prototype.set` called twice.");

assert.compareArray(results[0], iterable[0], 'The value of results[0] is expected to equal the value of iterable[0]');
assert.compareArray(results[1], iterable[1], 'The value of results[1] is expected to equal the value of iterable[1]');
assert.sameValue(_this[0], map, 'The value of _this[0] is expected to equal the value of map');
assert.sameValue(_this[1], map, 'The value of _this[1] is expected to equal the value of map');
assert(compareArray(results[0], iterable[0]));
assert(compareArray(results[1], iterable[1]));
assert.sameValue(_this[0], map);
assert.sameValue(_this[1], map);
3 changes: 2 additions & 1 deletion test/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-44.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ includes: [compareArray.js]
var str = new String("abc");
str[5] = "de";

var expected = ["0", "1", "2", "5", "length"];
var actual = Object.getOwnPropertyNames(str);

assert.compareArray(actual, ["0", "1", "2", "5", "length"], 'The value of actual is expected to be ["0", "1", "2", "5", "length"]');
assert(compareArray(actual, expected), 'compareArray(actual, expected) !== true');
3 changes: 2 additions & 1 deletion test/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-49.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ includes: [compareArray.js]
---*/

var arr = [0, 1, 2];
var expected = ["0", "1", "2", "length"];
var actual = Object.getOwnPropertyNames(arr);

assert.compareArray(actual, ["0", "1", "2", "length"], 'The value of actual is expected to be ["0", "1", "2", "length"]');
assert(compareArray(actual, expected), 'compareArray(actual, expected) !== true');
3 changes: 2 additions & 1 deletion test/built-ins/Object/getOwnPropertyNames/15.2.3.4-4-b-2.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ Object.defineProperty(obj, "d", {
});

var actual = Object.getOwnPropertyNames(obj);
var expected = ["a", "b", "c", "d"];

assert.compareArray(actual, ["a", "b", "c", "d"], 'The value of actual is expected to be ["a", "b", "c", "d"]');
assert(compareArray(actual, expected), 'compareArray(actual, expected) !== true');
10 changes: 5 additions & 5 deletions test/built-ins/Promise/race/resolved-sequence-with-rejections.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,22 @@ let sequence = [1];
Promise.all([
a.catch(() => {
sequence.push(3);
assert.sameValue(sequence.length, 3, 'The value of sequence.length is expected to be 3');
assert.sameValue(sequence.length, 3);
return checkSequence(sequence, 'Expected to be called first.');
}),
Promise.race([a, b]).catch(() => {
sequence.push(5);
assert.sameValue(sequence.length, 5, 'The value of sequence.length is expected to be 5');
assert.sameValue(sequence.length, 5);
return checkSequence(sequence, 'Expected to be called third.');
}),
b.catch(() => {
sequence.push(4);
assert.sameValue(sequence.length, 4, 'The value of sequence.length is expected to be 4');
assert.sameValue(sequence.length, 4);
return checkSequence(sequence, 'Expected to be called second.');
})
]).then(result => {
assert.compareArray(result, [true, true, true], 'The value of result is expected to be [true, true, true]');
assert.sameValue(sequence.length, 5, 'The value of sequence.length is expected to be 5');
compareArray(result, [true, true, true]);
assert.sameValue(sequence.length, 5);
checkSequence(sequence);
}).then($DONE, $DONE);

Expand Down
10 changes: 5 additions & 5 deletions test/built-ins/Promise/race/resolved-sequence.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,22 @@ let sequence = [1];
Promise.all([
a.then(() => {
sequence.push(3);
assert.sameValue(sequence.length, 3, 'The value of sequence.length is expected to be 3');
assert.sameValue(sequence.length, 3);
return checkSequence(sequence, 'Expected to be called first.');
}),
Promise.race([a, b]).then(() => {
sequence.push(5);
assert.sameValue(sequence.length, 5, 'The value of sequence.length is expected to be 5');
assert.sameValue(sequence.length, 5);
return checkSequence(sequence, 'Expected to be called third.');
}),
b.then(() => {
sequence.push(4);
assert.sameValue(sequence.length, 4, 'The value of sequence.length is expected to be 4');
assert.sameValue(sequence.length, 4);
return checkSequence(sequence, 'Expected to be called second.');
})
]).then(result => {
assert.compareArray(result, [true, true, true], 'The value of result is expected to be [true, true, true]');
assert.sameValue(sequence.length, 5, 'The value of sequence.length is expected to be 5');
compareArray(result, [true, true, true]);
assert.sameValue(sequence.length, 5);
checkSequence(sequence)
}).then($DONE, $DONE);
sequence.push(2);
20 changes: 10 additions & 10 deletions test/built-ins/Proxy/enumerate/removed-does-not-trigger.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,25 @@ for (x in p) {
forInResults.push(x);
}

assert.compareArray(forInResults, ["0", "1", "2"], 'The value of forInResults is expected to be ["0", "1", "2"]');
assert(compareArray(forInResults, ["0", "1", "2"]));

var forOfResults = [];
for (x of p) {
forOfResults.push(x);
}

assert.compareArray(forOfResults, [1, 2, 3], 'The value of forOfResults is expected to be [1, 2, 3]');
assert(compareArray(forOfResults, [1, 2, 3]));

var itor = p[Symbol.iterator]();
var next = itor.next();
assert.sameValue(next.value, 1, 'The value of next.value is expected to be 1');
assert.sameValue(next.done, false, 'The value of next.done is expected to be false');
assert.sameValue(next.value, 1);
assert.sameValue(next.done, false);
next = itor.next();
assert.sameValue(next.value, 2, 'The value of next.value is expected to be 2');
assert.sameValue(next.done, false, 'The value of next.done is expected to be false');
assert.sameValue(next.value, 2);
assert.sameValue(next.done, false);
next = itor.next();
assert.sameValue(next.value, 3, 'The value of next.value is expected to be 3');
assert.sameValue(next.done, false, 'The value of next.done is expected to be false');
assert.sameValue(next.value, 3);
assert.sameValue(next.done, false);
next = itor.next();
assert.sameValue(next.value, undefined, 'The value of next.value is expected to equal undefined');
assert.sameValue(next.done, true, 'The value of next.done is expected to be true');
assert.sameValue(next.value, undefined);
assert.sameValue(next.done, true);
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ Object.defineProperty(o1, 'p', {

var result = Reflect.getOwnPropertyDescriptor(o1, 'p');

assert.compareArray(
Object.getOwnPropertyNames(result),
['get', 'set', 'enumerable', 'configurable'],
'Object.getOwnPropertyNames(Reflect.getOwnPropertyDescriptor(o1, "p")) must return ["get", "set", "enumerable", "configurable"]'
assert(
compareArray(
Object.getOwnPropertyNames(result), ['get', 'set', 'enumerable', 'configurable']
)
);
assert.sameValue(result.enumerable, false, 'The value of result.enumerable is expected to be false');
assert.sameValue(result.configurable, true, 'The value of result.configurable is expected to be true');
assert.sameValue(result.get, fn, 'The value of result.get is expected to equal the value of fn');
assert.sameValue(result.set, undefined, 'The value of result.set is expected to equal undefined');
assert.sameValue(result.enumerable, false);
assert.sameValue(result.configurable, true);
assert.sameValue(result.get, fn);
assert.sameValue(result.set, undefined);
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ var o1 = {

var result = Reflect.getOwnPropertyDescriptor(o1, 'p');

assert.compareArray(
Object.getOwnPropertyNames(result),
['value', 'writable', 'enumerable', 'configurable'],
'Object.getOwnPropertyNames(Reflect.getOwnPropertyDescriptor(o1, "p")) must return ["value", "writable", "enumerable", "configurable"]'
assert(
compareArray(
Object.getOwnPropertyNames(result), ['value', 'writable', 'enumerable', 'configurable']
)
);
assert.sameValue(result.value, 'foo', 'The value of result.value is expected to be "foo"');
assert.sameValue(result.enumerable, true, 'The value of result.enumerable is expected to be true');
assert.sameValue(result.configurable, true, 'The value of result.configurable is expected to be true');
assert.sameValue(result.writable, true, 'The value of result.writable is expected to be true');
assert.sameValue(result.value, 'foo');
assert.sameValue(result.enumerable, true);
assert.sameValue(result.configurable, true);
assert.sameValue(result.writable, true);
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ o[s] = 42;

var result = Reflect.getOwnPropertyDescriptor(o, s);

assert.compareArray(
Object.getOwnPropertyNames(result),
['value', 'writable', 'enumerable', 'configurable'],
'Object.getOwnPropertyNames(Reflect.getOwnPropertyDescriptor(o, s)) must return ["value", "writable", "enumerable", "configurable"]'
assert(
compareArray(
Object.getOwnPropertyNames(result), ['value', 'writable', 'enumerable', 'configurable']
)
);
assert.sameValue(result.value, 42, 'The value of result.value is expected to be 42');
assert.sameValue(result.enumerable, true, 'The value of result.enumerable is expected to be true');
assert.sameValue(result.configurable, true, 'The value of result.configurable is expected to be true');
assert.sameValue(result.writable, true, 'The value of result.writable is expected to be true');
assert.sameValue(result.value, 42);
assert.sameValue(result.enumerable, true);
assert.sameValue(result.configurable, true);
assert.sameValue(result.writable, true);
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,7 @@ var o = Object.create(proto);
o.p1 = 42;
o.p2 = 43;
o.p3 = 44;
assert.compareArray(Reflect.ownKeys(o), ['p1', 'p2', 'p3'], 'Reflect.ownKeys(Object.create(proto)) must return ["p1", "p2", "p3"]');
assert(
compareArray(Reflect.ownKeys(o), ['p1', 'p2', 'p3']),
'return object own keys'
);
4 changes: 2 additions & 2 deletions test/built-ins/Reflect/ownKeys/return-empty-array.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ includes: [compareArray.js]
features: [Reflect]
---*/

assert.compareArray(Reflect.ownKeys({}), [], 'Reflect.ownKeys({}) must return []');
assert(compareArray(Reflect.ownKeys({}), []));

var o = {
d: 42
};
delete o.d;
assert.compareArray(Reflect.ownKeys(o), [], 'Reflect.ownKeys({d: 42}) must return []');
assert(compareArray(Reflect.ownKeys(o), []));
Loading

0 comments on commit d9ddf80

Please sign in to comment.