Transform compareArray -> assert.compareArray: test/built-ins/Array/**/*.js (#3238)

This commit is contained in:
Rick Waldron 2021-10-08 16:16:32 -04:00 committed by GitHub
parent 4ce285da7a
commit fc975b171d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 40 deletions

View File

@ -16,22 +16,13 @@ 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]),
'compareArray([].concat(ta, ta), [ta, ta]) must return true'
);
assert.compareArray([].concat(ta, ta), [ta, ta]);
ta[Symbol.isConcatSpreadable] = true;
assert.compareArray([].concat(ta), items, '[].concat(new type(items)) returns items');
assert.compareArray([].concat(ta), items);
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'
);
assert.compareArray([].concat(ta_by_len, ta_by_len), [ta_by_len, ta_by_len]);
ta_by_len[Symbol.isConcatSpreadable] = true;
assert(
compareArray([].concat(ta_by_len), items),
'compareArray([].concat(ta_by_len), items) must return true'
);
assert.compareArray([].concat(ta_by_len), items);
// TypedArray with fake `length`.
ta = new type(1);
@ -43,7 +34,7 @@ function concatTypedArray(type, elems, modulo) {
value: 4000
});
ta[Symbol.isConcatSpreadable] = true;
assert.compareArray([].concat(ta), expected, '[].concat(new type(1)) returns expected');
assert.compareArray([].concat(ta), expected);
}
var max = [Math.pow(2, 8), Math.pow(2, 16), Math.pow(2, 32), false, false];

View File

@ -16,22 +16,13 @@ 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]),
'compareArray([].concat(ta, ta), [ta, ta]) must return true'
);
assert.compareArray([].concat(ta, ta), [ta, ta]);
ta[Symbol.isConcatSpreadable] = true;
assert.compareArray([].concat(ta), items, '[].concat(new type(items)) returns items');
assert.compareArray([].concat(ta), items);
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'
);
assert.compareArray([].concat(ta_by_len, ta_by_len), [ta_by_len, ta_by_len]);
ta_by_len[Symbol.isConcatSpreadable] = true;
assert(
compareArray([].concat(ta_by_len), items),
'compareArray([].concat(ta_by_len), items) must return true'
);
assert.compareArray([].concat(ta_by_len), items);
// TypedArray with fake `length`.
ta = new type(1);
@ -43,7 +34,7 @@ function concatTypedArray(type, elems, modulo) {
value: 4000
});
ta[Symbol.isConcatSpreadable] = true;
assert.compareArray([].concat(ta), expected, '[].concat(new type(1)) returns expected');
assert.compareArray([].concat(ta), expected);
}
var max = [Math.pow(2, 8), Math.pow(2, 16), Math.pow(2, 32), false, false];
[

View File

@ -31,18 +31,22 @@ info: |
includes: [compareArray.js]
---*/
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, 0),
['a', 'b', 'c', 'd', '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(0, 2),
['c', 'd', 'e', 'f', 'e', 'f']
);
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(
['a', 'b', 'c', 'd', 'e', 'f'].copyWithin(3, 0),
['a', 'b', 'c', 'a', 'b', 'c']
);
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');
assert.compareArray(
[0, 1, 2, 3, 4, 5].copyWithin(1, 4),
[0, 4, 5, 3, 4, 5]
);