Merge pull request #3219 from tc39/rwaldron/migrate-comparearray

chore: convert compareArray() to assert.compareArray()
This commit is contained in:
Leo Balter 2021-09-24 12:02:11 -07:00 committed by GitHub
commit b690cb67be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
251 changed files with 2853 additions and 2802 deletions

View File

@ -26,8 +26,8 @@ compareArray.isSameValue = function(a, b) {
return a === b; return a === b;
}; };
compareArray.format = function(array) { compareArray.format = function(thingWithALengthPropertyAndNumericIndices) {
return `[${array.map(String).join(', ')}]`; return `[${[].map.call(thingWithALengthPropertyAndNumericIndices, String).join(', ')}]`;
}; };
assert.compareArray = function(actual, expected, message) { assert.compareArray = function(actual, expected, message) {
@ -35,8 +35,11 @@ assert.compareArray = function(actual, expected, message) {
assert(actual != null, `First argument shouldn't be nullish. ${message}`); assert(actual != null, `First argument shouldn't be nullish. ${message}`);
assert(expected != null, `Second argument shouldn't be nullish. ${message}`); assert(expected != null, `Second argument shouldn't be nullish. ${message}`);
var format = compareArray.format; var format = compareArray.format;
assert( var result = compareArray(actual, expected);
compareArray(actual, expected),
`Expected ${format(actual)} and ${format(expected)} to have the same contents. ${message}` // 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}`);
}
}; };

View File

@ -27,7 +27,7 @@ item.then(({ done, value }) => {
item = iter.next(value); item = iter.next(value);
item.then(({ done, value }) => { item.then(({ done, value }) => {
assert(compareArray(value, arr)); assert.compareArray(value, arr);
assert.sameValue(done, false); assert.sameValue(done, false);
}).then($DONE, $DONE); }).then($DONE, $DONE);
}).catch($DONE); }).catch($DONE);

View File

@ -50,4 +50,4 @@ verifyProperty(c, y, {
configurable: true configurable: true
}); });
assert(compareArray(x, ["a", "b", "c"])); assert.compareArray(x, ["a", "b", "c"]);

View File

@ -50,4 +50,4 @@ verifyProperty(c, "y", {
configurable: true configurable: true
}); });
assert(compareArray(x, ["a", "b", "c", "d"])); assert.compareArray(x, ["a", "b", "c", "d"]);

View File

@ -19,5 +19,5 @@ Object.defineProperty(o, Symbol('foo'), { get: () => { calls.push("Symbol(foo)")
//- vals //- vals
o o
//- body //- body
assert(compareArray(calls, [1, 'z', 'a', "Symbol(foo)"])); assert.compareArray(calls, [1, 'z', 'a', "Symbol(foo)"]);
assert.sameValue(Object.keys(rest).length, 3); assert.sameValue(Object.keys(rest).length, 3);

View File

@ -23,5 +23,5 @@ iter.next(false);
item = iter.next(['a', 'b', 'c']); item = iter.next(['a', 'b', 'c']);
item = iter.next(item.value); item = iter.next(item.value);
assert(compareArray(item.value, arr)); assert.compareArray(item.value, arr);
assert.sameValue(item.done, false); assert.sameValue(item.done, false);

View File

@ -29,5 +29,5 @@ Object.defineProperty(o, Symbol('foo'), { get: () => { calls.push("Symbol(foo)")
//- params //- params
obj obj
//- body //- body
assert(compareArray(calls, [1, 'z', 'a', "Symbol(foo)"])); assert.compareArray(calls, [1, 'z', 'a', "Symbol(foo)"]);
assert.sameValue(Object.keys(obj).length, 3); assert.sameValue(Object.keys(obj).length, 3);

View File

@ -16,21 +16,18 @@ function concatTypedArray(type, elems, modulo) {
ta_by_len[i] = items[i] = modulo === false ? i : elems % modulo; ta_by_len[i] = items[i] = modulo === false ? i : elems % modulo;
} }
var ta = new type(items); var ta = new type(items);
assert( assert.compareArray([].concat(ta, ta), [ta, ta],
compareArray([].concat(ta, ta), [ta, ta]), '[].concat(new type(items), new type(items)) must return [ta, ta]'
'compareArray([].concat(ta, ta), [ta, ta]) must return true'
); );
ta[Symbol.isConcatSpreadable] = true; ta[Symbol.isConcatSpreadable] = true;
assert.compareArray([].concat(ta), items, '[].concat(new type(items)) returns items'); assert.compareArray([].concat(ta), items, '[].concat(new type(items)) returns items');
assert( 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]), '[].concat(new type(elems), new type(elems)) must return [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; ta_by_len[Symbol.isConcatSpreadable] = true;
assert( assert.compareArray([].concat(ta_by_len), items,
compareArray([].concat(ta_by_len), items), '[].concat(new type(elems)) returns items'
'compareArray([].concat(ta_by_len), items) must return true'
); );
// TypedArray with fake `length`. // TypedArray with fake `length`.

View File

@ -16,21 +16,21 @@ function concatTypedArray(type, elems, modulo) {
ta_by_len[i] = items[i] = modulo === false ? i : elems % modulo; ta_by_len[i] = items[i] = modulo === false ? i : elems % modulo;
} }
var ta = new type(items); var ta = new type(items);
assert( assert.compareArray(
compareArray([].concat(ta, ta), [ta, ta]), [].concat(ta, ta), [ta, ta],
'compareArray([].concat(ta, ta), [ta, ta]) must return true' '[].concat(new type(items), new type(items)) must return [ta, ta]'
); );
ta[Symbol.isConcatSpreadable] = true; ta[Symbol.isConcatSpreadable] = true;
assert.compareArray([].concat(ta), items, '[].concat(new type(items)) returns items'); assert.compareArray([].concat(ta), items, '[].concat(new type(items)) returns items');
assert( assert.compareArray(
compareArray([].concat(ta_by_len, ta_by_len), [ta_by_len, ta_by_len]), [].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' '[].concat(new type(elems), new type(elems)) must return [ta_by_len, ta_by_len]'
); );
ta_by_len[Symbol.isConcatSpreadable] = true; ta_by_len[Symbol.isConcatSpreadable] = true;
assert( assert.compareArray(
compareArray([].concat(ta_by_len), items), [].concat(ta_by_len), items,
'compareArray([].concat(ta_by_len), items) must return true' '[].concat(new type(elems)) returns items'
); );
// TypedArray with fake `length`. // TypedArray with fake `length`.

View File

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

View File

@ -34,9 +34,9 @@ Map.prototype.set = function(k, v) {
var map = new Map(iterable); var map = new Map(iterable);
assert.sameValue(counter, 2, "`Map.prototype.set` called twice."); assert.sameValue(counter, 2, 'The value of counter is expected to be 2');
assert(compareArray(results[0], iterable[0])); 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])); 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); assert.sameValue(_this[0], map, 'The value of _this[0] is expected to equal the value of map');
assert.sameValue(_this[1], map); assert.sameValue(_this[1], map, 'The value of _this[1] is expected to equal the value of map');

View File

@ -12,7 +12,6 @@ includes: [compareArray.js]
var str = new String("abc"); var str = new String("abc");
str[5] = "de"; str[5] = "de";
var expected = ["0", "1", "2", "5", "length"];
var actual = Object.getOwnPropertyNames(str); var actual = Object.getOwnPropertyNames(str);
assert(compareArray(actual, expected), 'compareArray(actual, expected) !== true'); assert.compareArray(actual, ["0", "1", "2", "5", "length"], 'The value of actual is expected to be ["0", "1", "2", "5", "length"]');

View File

@ -10,7 +10,6 @@ includes: [compareArray.js]
---*/ ---*/
var arr = [0, 1, 2]; var arr = [0, 1, 2];
var expected = ["0", "1", "2", "length"];
var actual = Object.getOwnPropertyNames(arr); var actual = Object.getOwnPropertyNames(arr);
assert(compareArray(actual, expected), 'compareArray(actual, expected) !== true'); assert.compareArray(actual, ["0", "1", "2", "length"], 'The value of actual is expected to be ["0", "1", "2", "length"]');

View File

@ -36,6 +36,5 @@ Object.defineProperty(obj, "d", {
}); });
var actual = Object.getOwnPropertyNames(obj); var actual = Object.getOwnPropertyNames(obj);
var expected = ["a", "b", "c", "d"];
assert(compareArray(actual, expected), 'compareArray(actual, expected) !== true'); assert.compareArray(actual, ["a", "b", "c", "d"], 'The value of actual is expected to be ["a", "b", "c", "d"]');

View File

@ -30,22 +30,22 @@ let sequence = [1];
Promise.all([ Promise.all([
a.catch(() => { a.catch(() => {
sequence.push(3); sequence.push(3);
assert.sameValue(sequence.length, 3); assert.sameValue(sequence.length, 3, 'The value of sequence.length is expected to be 3');
return checkSequence(sequence, 'Expected to be called first.'); return checkSequence(sequence, 'Expected to be called first.');
}), }),
Promise.race([a, b]).catch(() => { Promise.race([a, b]).catch(() => {
sequence.push(5); sequence.push(5);
assert.sameValue(sequence.length, 5); assert.sameValue(sequence.length, 5, 'The value of sequence.length is expected to be 5');
return checkSequence(sequence, 'Expected to be called third.'); return checkSequence(sequence, 'Expected to be called third.');
}), }),
b.catch(() => { b.catch(() => {
sequence.push(4); sequence.push(4);
assert.sameValue(sequence.length, 4); assert.sameValue(sequence.length, 4, 'The value of sequence.length is expected to be 4');
return checkSequence(sequence, 'Expected to be called second.'); return checkSequence(sequence, 'Expected to be called second.');
}) })
]).then(result => { ]).then(result => {
compareArray(result, [true, true, true]); assert.compareArray(result, [true, true, true], 'The value of result is expected to be [true, true, true]');
assert.sameValue(sequence.length, 5); assert.sameValue(sequence.length, 5, 'The value of sequence.length is expected to be 5');
checkSequence(sequence); checkSequence(sequence);
}).then($DONE, $DONE); }).then($DONE, $DONE);

View File

@ -30,22 +30,22 @@ let sequence = [1];
Promise.all([ Promise.all([
a.then(() => { a.then(() => {
sequence.push(3); sequence.push(3);
assert.sameValue(sequence.length, 3); assert.sameValue(sequence.length, 3, 'The value of sequence.length is expected to be 3');
return checkSequence(sequence, 'Expected to be called first.'); return checkSequence(sequence, 'Expected to be called first.');
}), }),
Promise.race([a, b]).then(() => { Promise.race([a, b]).then(() => {
sequence.push(5); sequence.push(5);
assert.sameValue(sequence.length, 5); assert.sameValue(sequence.length, 5, 'The value of sequence.length is expected to be 5');
return checkSequence(sequence, 'Expected to be called third.'); return checkSequence(sequence, 'Expected to be called third.');
}), }),
b.then(() => { b.then(() => {
sequence.push(4); sequence.push(4);
assert.sameValue(sequence.length, 4); assert.sameValue(sequence.length, 4, 'The value of sequence.length is expected to be 4');
return checkSequence(sequence, 'Expected to be called second.'); return checkSequence(sequence, 'Expected to be called second.');
}) })
]).then(result => { ]).then(result => {
compareArray(result, [true, true, true]); assert.compareArray(result, [true, true, true], 'The value of result is expected to be [true, true, true]');
assert.sameValue(sequence.length, 5); assert.sameValue(sequence.length, 5, 'The value of sequence.length is expected to be 5');
checkSequence(sequence) checkSequence(sequence)
}).then($DONE, $DONE); }).then($DONE, $DONE);
sequence.push(2); sequence.push(2);

View File

@ -23,25 +23,25 @@ for (x in p) {
forInResults.push(x); forInResults.push(x);
} }
assert(compareArray(forInResults, ["0", "1", "2"])); assert.compareArray(forInResults, ["0", "1", "2"], 'The value of forInResults is expected to be ["0", "1", "2"]');
var forOfResults = []; var forOfResults = [];
for (x of p) { for (x of p) {
forOfResults.push(x); forOfResults.push(x);
} }
assert(compareArray(forOfResults, [1, 2, 3])); assert.compareArray(forOfResults, [1, 2, 3], 'The value of forOfResults is expected to be [1, 2, 3]');
var itor = p[Symbol.iterator](); var itor = p[Symbol.iterator]();
var next = itor.next(); var next = itor.next();
assert.sameValue(next.value, 1); assert.sameValue(next.value, 1, 'The value of next.value is expected to be 1');
assert.sameValue(next.done, false); assert.sameValue(next.done, false, 'The value of next.done is expected to be false');
next = itor.next(); next = itor.next();
assert.sameValue(next.value, 2); assert.sameValue(next.value, 2, 'The value of next.value is expected to be 2');
assert.sameValue(next.done, false); assert.sameValue(next.done, false, 'The value of next.done is expected to be false');
next = itor.next(); next = itor.next();
assert.sameValue(next.value, 3); assert.sameValue(next.value, 3, 'The value of next.value is expected to be 3');
assert.sameValue(next.done, false); assert.sameValue(next.done, false, 'The value of next.done is expected to be false');
next = itor.next(); next = itor.next();
assert.sameValue(next.value, undefined); assert.sameValue(next.value, undefined, 'The value of next.value is expected to equal undefined');
assert.sameValue(next.done, true); assert.sameValue(next.done, true, 'The value of next.done is expected to be true');

View File

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

View File

@ -21,12 +21,12 @@ var o1 = {
var result = Reflect.getOwnPropertyDescriptor(o1, 'p'); var result = Reflect.getOwnPropertyDescriptor(o1, 'p');
assert( assert.compareArray(
compareArray( Object.getOwnPropertyNames(result),
Object.getOwnPropertyNames(result), ['value', 'writable', 'enumerable', 'configurable'] ['value', 'writable', 'enumerable', 'configurable'],
) 'Object.getOwnPropertyNames(Reflect.getOwnPropertyDescriptor(o1, "p")) must return ["value", "writable", "enumerable", "configurable"]'
); );
assert.sameValue(result.value, 'foo'); assert.sameValue(result.value, 'foo', 'The value of result.value is expected to be "foo"');
assert.sameValue(result.enumerable, true); assert.sameValue(result.enumerable, true, 'The value of result.enumerable is expected to be true');
assert.sameValue(result.configurable, true); assert.sameValue(result.configurable, true, 'The value of result.configurable is expected to be true');
assert.sameValue(result.writable, true); assert.sameValue(result.writable, true, 'The value of result.writable is expected to be true');

View File

@ -27,12 +27,12 @@ o[s] = 42;
var result = Reflect.getOwnPropertyDescriptor(o, s); var result = Reflect.getOwnPropertyDescriptor(o, s);
assert( assert.compareArray(
compareArray( Object.getOwnPropertyNames(result),
Object.getOwnPropertyNames(result), ['value', 'writable', 'enumerable', 'configurable'] ['value', 'writable', 'enumerable', 'configurable'],
) 'Object.getOwnPropertyNames(Reflect.getOwnPropertyDescriptor(o, s)) must return ["value", "writable", "enumerable", "configurable"]'
); );
assert.sameValue(result.value, 42); assert.sameValue(result.value, 42, 'The value of result.value is expected to be 42');
assert.sameValue(result.enumerable, true); assert.sameValue(result.enumerable, true, 'The value of result.enumerable is expected to be true');
assert.sameValue(result.configurable, true); assert.sameValue(result.configurable, true, 'The value of result.configurable is expected to be true');
assert.sameValue(result.writable, true); assert.sameValue(result.writable, true, 'The value of result.writable is expected to be true');

View File

@ -23,7 +23,4 @@ var o = Object.create(proto);
o.p1 = 42; o.p1 = 42;
o.p2 = 43; o.p2 = 43;
o.p3 = 44; o.p3 = 44;
assert( assert.compareArray(Reflect.ownKeys(o), ['p1', 'p2', 'p3'], 'Reflect.ownKeys(Object.create(proto)) must return ["p1", "p2", "p3"]');
compareArray(Reflect.ownKeys(o), ['p1', 'p2', 'p3']),
'return object own keys'
);

View File

@ -15,10 +15,10 @@ includes: [compareArray.js]
features: [Reflect] features: [Reflect]
---*/ ---*/
assert(compareArray(Reflect.ownKeys({}), [])); assert.compareArray(Reflect.ownKeys({}), [], 'Reflect.ownKeys({}) must return []');
var o = { var o = {
d: 42 d: 42
}; };
delete o.d; delete o.d;
assert(compareArray(Reflect.ownKeys(o), [])); assert.compareArray(Reflect.ownKeys(o), [], 'Reflect.ownKeys({d: 42}) must return []');

View File

@ -15,14 +15,14 @@ includes: [compareArray.js]
features: [Reflect] features: [Reflect]
---*/ ---*/
assert( assert.compareArray(
compareArray(Reflect.ownKeys([]), ['length']), Reflect.ownKeys([]), ['length'],
'return non enumerable `length` from empty array' 'Reflect.ownKeys([]) must return ["length"]'
); );
assert( assert.compareArray(
compareArray(Reflect.ownKeys([, , 2]), ['2', 'length']), Reflect.ownKeys([, , 2]), ['2', 'length'],
'return array keys' 'Reflect.ownKeys([, , 2]) must return ["2", "length"]'
); );
var o = {}; var o = {};
@ -35,4 +35,4 @@ Object.defineProperty(o, 'p2', {
enumerable: false enumerable: false
}); });
assert(compareArray(Reflect.ownKeys(o), ['p1', 'p2'])); assert.compareArray(Reflect.ownKeys(o), ['p1', 'p2'], 'Reflect.ownKeys({}) must return ["p1", "p2"]');

View File

@ -15,16 +15,15 @@ info: |
---*/ ---*/
// Properties created on result.groups in textual order. // Properties created on result.groups in textual order.
assert(compareArray(["fst", "snd"], assert.compareArray(["fst", "snd"], Object.getOwnPropertyNames(
Object.getOwnPropertyNames( /(?<fst>.)|(?<snd>.)/u.exec("abcd").groups), '["fst", "snd"] must return the same value returned by Object.getOwnPropertyNames(\n /(?<fst>.)|(?<snd>.)/u.exec("abcd").groups)');
/(?<fst>.)|(?<snd>.)/u.exec("abcd").groups)));
// Properties are created with Define, not Set // Properties are created with Define, not Set
let counter = 0; let counter = 0;
Object.defineProperty(Object.prototype, 'x', {set() { counter++; }}); Object.defineProperty(Object.prototype, 'x', {set() { counter++; }});
let match = /(?<x>.)/.exec('a'); let match = /(?<x>.)/.exec('a');
let groups = match.groups; let groups = match.groups;
assert.sameValue(counter, 0); assert.sameValue(counter, 0, 'The value of counter is expected to be 0');
// Properties are writable, enumerable and configurable // Properties are writable, enumerable and configurable
// (from CreateDataProperty) // (from CreateDataProperty)

View File

@ -9,38 +9,125 @@ includes: [compareArray.js]
---*/ ---*/
// Unicode mode // Unicode mode
assert(compareArray(["f", "c"], "abcdef".match(/(?<=(?<a>\w){3})f/u))); assert.compareArray(
assert.sameValue("c", "abcdef".match(/(?<=(?<a>\w){3})f/u).groups.a); ["f", "c"],
assert.sameValue("b", "abcdef".match(/(?<=(?<a>\w){4})f/u).groups.a); "abcdef".match(/(?<=(?<a>\w){3})f/u),
assert.sameValue("a", "abcdef".match(/(?<=(?<a>\w)+)f/u).groups.a); '["f", "c"] must return the same value returned by "abcdef".match(/(?<=(?<a>w){3})f/u)'
assert.sameValue(null, "abcdef".match(/(?<=(?<a>\w){6})f/u)); );
assert.sameValue(
"abcdef".match(/(?<=(?<a>\w){3})f/u).groups.a,
"c",
'The value of "abcdef".match(/(?<=(?<a>w){3})f/u).groups.a is expected to be "c"'
);
assert.sameValue(
"abcdef".match(/(?<=(?<a>\w){4})f/u).groups.a,
"b",
'The value of "abcdef".match(/(?<=(?<a>w){4})f/u).groups.a is expected to be "b"'
);
assert.sameValue(
"abcdef".match(/(?<=(?<a>\w)+)f/u).groups.a,
"a",
'The value of "abcdef".match(/(?<=(?<a>w)+)f/u).groups.a is expected to be "a"'
);
assert.sameValue(
"abcdef".match(/(?<=(?<a>\w){6})f/u),
null,
'"abcdef".match(/(?<=(?<a>w){6})f/u) must return null'
);
assert(compareArray(["f", ""], "abcdef".match(/((?<=\w{3}))f/u))); assert.compareArray(
assert(compareArray(["f", ""], "abcdef".match(/(?<a>(?<=\w{3}))f/u))); ["f", ""],
"abcdef".match(/((?<=\w{3}))f/u),
'["f", ""] must return the same value returned by "abcdef".match(/((?<=w{3}))f/u)'
);
assert.compareArray(
["f", ""],
"abcdef".match(/(?<a>(?<=\w{3}))f/u),
'["f", ""] must return the same value returned by "abcdef".match(/(?<a>(?<=w{3}))f/u)'
);
assert(compareArray(["f", undefined], "abcdef".match(/(?<!(?<a>\d){3})f/u))); assert.compareArray(
assert.sameValue(null, "abcdef".match(/(?<!(?<a>\D){3})f/u)); ["f", undefined],
"abcdef".match(/(?<!(?<a>\d){3})f/u),
'["f", undefined] must return the same value returned by "abcdef".match(/(?<!(?<a>d){3})f/u)'
);
assert.sameValue(
"abcdef".match(/(?<!(?<a>\D){3})f/u),
null,
'"abcdef".match(/(?<!(?<a>D){3})f/u) must return null'
);
assert(compareArray(["f", undefined], "abcdef".match(/(?<!(?<a>\D){3})f|f/u))); assert.compareArray(
assert(compareArray(["f", undefined], "abcdef".match(/(?<a>(?<!\D{3}))f|f/u))); ["f", undefined],
"abcdef".match(/(?<!(?<a>\D){3})f|f/u),
'["f", undefined] must return the same value returned by "abcdef".match(/(?<!(?<a>D){3})f|f/u)'
);
assert.compareArray(
["f", undefined],
"abcdef".match(/(?<a>(?<!\D{3}))f|f/u),
'["f", undefined] must return the same value returned by "abcdef".match(/(?<a>(?<!D{3}))f|f/u)'
);
// Non-Unicode mode // Non-Unicode mode
assert(compareArray(["f", "c"], "abcdef".match(/(?<=(?<a>\w){3})f/))); assert.compareArray(
assert.sameValue("c", "abcdef".match(/(?<=(?<a>\w){3})f/).groups.a); ["f", "c"],
assert.sameValue("b", "abcdef".match(/(?<=(?<a>\w){4})f/).groups.a); "abcdef".match(/(?<=(?<a>\w){3})f/),
assert.sameValue("a", "abcdef".match(/(?<=(?<a>\w)+)f/).groups.a); '["f", "c"] must return the same value returned by "abcdef".match(/(?<=(?<a>w){3})f/)'
assert.sameValue(null, "abcdef".match(/(?<=(?<a>\w){6})f/)); );
assert.sameValue(
"abcdef".match(/(?<=(?<a>\w){3})f/).groups.a,
"c",
'The value of "abcdef".match(/(?<=(?<a>w){3})f/).groups.a is expected to be "c"'
);
assert.sameValue(
"abcdef".match(/(?<=(?<a>\w){4})f/).groups.a,
"b",
'The value of "abcdef".match(/(?<=(?<a>w){4})f/).groups.a is expected to be "b"'
);
assert.sameValue(
"abcdef".match(/(?<=(?<a>\w)+)f/).groups.a,
"a",
'The value of "abcdef".match(/(?<=(?<a>w)+)f/).groups.a is expected to be "a"'
);
assert.sameValue(
"abcdef".match(/(?<=(?<a>\w){6})f/),
null,
'"abcdef".match(/(?<=(?<a>w){6})f/) must return null'
);
assert(compareArray(["f", ""], "abcdef".match(/((?<=\w{3}))f/))); assert.compareArray(
assert(compareArray(["f", ""], "abcdef".match(/(?<a>(?<=\w{3}))f/))); ["f", ""],
"abcdef".match(/((?<=\w{3}))f/),
'["f", ""] must return the same value returned by "abcdef".match(/((?<=w{3}))f/)'
);
assert.compareArray(
["f", ""],
"abcdef".match(/(?<a>(?<=\w{3}))f/),
'["f", ""] must return the same value returned by "abcdef".match(/(?<a>(?<=w{3}))f/)'
);
assert(compareArray(["f", undefined], "abcdef".match(/(?<!(?<a>\d){3})f/))); assert.compareArray(
assert.sameValue(null, "abcdef".match(/(?<!(?<a>\D){3})f/)); ["f", undefined],
"abcdef".match(/(?<!(?<a>\d){3})f/),
'["f", undefined] must return the same value returned by "abcdef".match(/(?<!(?<a>d){3})f/)'
);
assert.sameValue(
"abcdef".match(/(?<!(?<a>\D){3})f/),
null,
'"abcdef".match(/(?<!(?<a>D){3})f/) must return null'
);
assert(compareArray(["f", undefined], "abcdef".match(/(?<!(?<a>\D){3})f|f/))); assert.compareArray(
assert(compareArray(["f", undefined], "abcdef".match(/(?<a>(?<!\D{3}))f|f/))); ["f", undefined],
"abcdef".match(/(?<!(?<a>\D){3})f|f/),
'["f", undefined] must return the same value returned by "abcdef".match(/(?<!(?<a>D){3})f|f/)'
);
assert.compareArray(
["f", undefined],
"abcdef".match(/(?<a>(?<!\D{3}))f|f/),
'["f", undefined] must return the same value returned by "abcdef".match(/(?<a>(?<!D{3}))f|f/)'
);
// Even within a lookbehind, properties are created in left to right order // Even within a lookbehind, properties are created in left to right order
assert(compareArray(["fst", "snd"], assert.compareArray(["fst", "snd"], Object.getOwnPropertyNames(
Object.getOwnPropertyNames( /(?<=(?<fst>.)|(?<snd>.))/u.exec("abcd").groups), '["fst", "snd"] must return the same value returned by Object.getOwnPropertyNames(\n /(?<=(?<fst>.)|(?<snd>.))/u.exec("abcd").groups)');
/(?<=(?<fst>.)|(?<snd>.))/u.exec("abcd").groups)));

View File

@ -8,36 +8,135 @@ features: [regexp-named-groups]
includes: [compareArray.js] includes: [compareArray.js]
---*/ ---*/
assert(compareArray(["a", "a"], "bab".match(/(?<a>a)/))); assert.compareArray(
assert(compareArray(["a", "a"], "bab".match(/(?<a42>a)/))); "bab".match(/(?<a>a)/),
assert(compareArray(["a", "a"], "bab".match(/(?<_>a)/))); ["a", "a"],
assert(compareArray(["a", "a"], "bab".match(/(?<$>a)/))); '"bab".match("/(?<a>.)(?<b>.)(?<c>.)k<c>k<b>k<a>/.exec("abccba").groups") must return ["a", "a"]'
assert(compareArray(["bab", "a"], "bab".match(/.(?<$>a)./))); );
assert(compareArray(["bab", "a", "b"], "bab".match(/.(?<a>a)(.)/))); assert.compareArray(
assert(compareArray(["bab", "a", "b"], "bab".match(/.(?<a>a)(?<b>.)/))); "bab".match(/(?<a42>a)/),
assert(compareArray(["bab", "ab"], "bab".match(/.(?<a>\w\w)/))); ["a", "a"],
assert(compareArray(["bab", "bab"], "bab".match(/(?<a>\w\w\w)/))); '"bab".match("/(?<a>.)(?<b>.)(?<c>.)k<c>k<b>k<a>/.exec("abccba").groups") must return ["a", "a"]'
assert(compareArray(["bab", "ba", "b"], "bab".match(/(?<a>\w\w)(?<b>\w)/))); );
assert.compareArray(
"bab".match(/(?<_>a)/),
["a", "a"],
'"bab".match("/(?<a>.)(?<b>.)(?<c>.)k<c>k<b>k<a>/.exec("abccba").groups") must return ["a", "a"]'
);
assert.compareArray(
"bab".match(/(?<$>a)/),
["a", "a"],
'"bab".match("/(?<a>.)(?<b>.)(?<c>.)k<c>k<b>k<a>/.exec("abccba").groups") must return ["a", "a"]'
);
assert.compareArray(
"bab".match(/.(?<$>a)./),
["bab", "a"],
'"bab".match("/(?<a>.)(?<b>.)(?<c>.)k<c>k<b>k<a>/.exec("abccba").groups") must return ["bab", "a"]'
);
assert.compareArray(
"bab".match(/.(?<a>a)(.)/),
["bab", "a", "b"],
'"bab".match("/(?<a>.)(?<b>.)(?<c>.)k<c>k<b>k<a>/.exec("abccba").groups") must return ["bab", "a", "b"]'
);
assert.compareArray(
"bab".match(/.(?<a>a)(?<b>.)/),
["bab", "a", "b"],
'"bab".match("/(?<a>.)(?<b>.)(?<c>.)k<c>k<b>k<a>/.exec("abccba").groups") must return ["bab", "a", "b"]'
);
assert.compareArray(
"bab".match(/.(?<a>\w\w)/),
["bab", "ab"],
'"bab".match("/(?<a>.)(?<b>.)(?<c>.)k<c>k<b>k<a>/.exec("abccba").groups") must return ["bab", "ab"]'
);
assert.compareArray(
"bab".match(/(?<a>\w\w\w)/),
["bab", "bab"],
'"bab".match("/(?<a>.)(?<b>.)(?<c>.)k<c>k<b>k<a>/.exec("abccba").groups") must return ["bab", "bab"]'
);
assert.compareArray(
"bab".match(/(?<a>\w\w)(?<b>\w)/),
["bab", "ba", "b"],
'"bab".match("/(?<a>.)(?<b>.)(?<c>.)k<c>k<b>k<a>/.exec("abccba").groups") must return ["bab", "ba", "b"]'
);
let {a, b, c} = /(?<a>.)(?<b>.)(?<c>.)\k<c>\k<b>\k<a>/.exec("abccba").groups; let {a, b, c} = /(?<a>.)(?<b>.)(?<c>.)\k<c>\k<b>\k<a>/.exec("abccba").groups;
assert.sameValue(a, "a"); assert.sameValue(a, "a", 'The value of a is expected to be "a"');
assert.sameValue(b, "b"); assert.sameValue(b, "b", 'The value of b is expected to be "b"');
assert.sameValue(c, "c"); assert.sameValue(c, "c", 'The value of c is expected to be "c"');
assert(compareArray("bab".match(/(a)/), "bab".match(/(?<a>a)/))); assert.compareArray(
assert(compareArray("bab".match(/(a)/), "bab".match(/(?<a42>a)/))); "bab".match(/(?<a>a)/),
assert(compareArray("bab".match(/(a)/), "bab".match(/(?<_>a)/))); "bab".match(/(a)/),
assert(compareArray("bab".match(/(a)/), "bab".match(/(?<$>a)/))); '"bab".match("/(?<a>.)(?<b>.)(?<c>.)k<c>k<b>k<a>/.exec("abccba").groups") must return the same value returned by "bab".match(/(a)/)'
assert(compareArray("bab".match(/.(a)./), "bab".match(/.(?<$>a)./))); );
assert(compareArray("bab".match(/.(a)(.)/), "bab".match(/.(?<a>a)(.)/))); assert.compareArray(
assert(compareArray("bab".match(/.(a)(.)/), "bab".match(/.(?<a>a)(?<b>.)/))); "bab".match(/(?<a42>a)/),
assert(compareArray("bab".match(/.(\w\w)/), "bab".match(/.(?<a>\w\w)/))); "bab".match(/(a)/),
assert(compareArray("bab".match(/(\w\w\w)/), "bab".match(/(?<a>\w\w\w)/))); '"bab".match("/(?<a>.)(?<b>.)(?<c>.)k<c>k<b>k<a>/.exec("abccba").groups") must return the same value returned by "bab".match(/(a)/)'
assert(compareArray("bab".match(/(\w\w)(\w)/), "bab".match(/(?<a>\w\w)(?<b>\w)/))); );
assert.compareArray(
"bab".match(/(?<_>a)/),
"bab".match(/(a)/),
'"bab".match("/(?<a>.)(?<b>.)(?<c>.)k<c>k<b>k<a>/.exec("abccba").groups") must return the same value returned by "bab".match(/(a)/)'
);
assert.compareArray(
"bab".match(/(?<$>a)/),
"bab".match(/(a)/),
'"bab".match("/(?<a>.)(?<b>.)(?<c>.)k<c>k<b>k<a>/.exec("abccba").groups") must return the same value returned by "bab".match(/(a)/)'
);
assert.compareArray(
"bab".match(/.(?<$>a)./),
"bab".match(/.(a)./),
'"bab".match("/(?<a>.)(?<b>.)(?<c>.)k<c>k<b>k<a>/.exec("abccba").groups") must return the same value returned by "bab".match(/.(a)./)'
);
assert.compareArray(
"bab".match(/.(?<a>a)(.)/),
"bab".match(/.(a)(.)/),
'"bab".match("/(?<a>.)(?<b>.)(?<c>.)k<c>k<b>k<a>/.exec("abccba").groups") must return the same value returned by "bab".match(/.(a)(.)/)'
);
assert.compareArray(
"bab".match(/.(?<a>a)(?<b>.)/),
"bab".match(/.(a)(.)/),
'"bab".match("/(?<a>.)(?<b>.)(?<c>.)k<c>k<b>k<a>/.exec("abccba").groups") must return the same value returned by "bab".match(/.(a)(.)/)'
);
assert.compareArray(
"bab".match(/.(?<a>\w\w)/),
"bab".match(/.(\w\w)/),
'"bab".match("/(?<a>.)(?<b>.)(?<c>.)k<c>k<b>k<a>/.exec("abccba").groups") must return the same value returned by "bab".match(/.(ww)/)'
);
assert.compareArray(
"bab".match(/(?<a>\w\w\w)/),
"bab".match(/(\w\w\w)/),
'"bab".match("/(?<a>.)(?<b>.)(?<c>.)k<c>k<b>k<a>/.exec("abccba").groups") must return the same value returned by "bab".match(/(www)/)'
);
assert.compareArray(
"bab".match(/(?<a>\w\w)(?<b>\w)/),
"bab".match(/(\w\w)(\w)/),
'"bab".match("/(?<a>.)(?<b>.)(?<c>.)k<c>k<b>k<a>/.exec("abccba").groups") must return the same value returned by "bab".match(/(ww)(w)/)'
);
assert(compareArray(["bab", "b"], "bab".match(/(?<b>b).\1/))); assert.compareArray(
assert(compareArray(["baba", "b", "a"], "baba".match(/(.)(?<a>a)\1\2/))); "bab".match(/(?<b>b).\1/),
assert(compareArray(["baba", "b", "a", "b", "a"], ["bab", "b"],
"baba".match(/(.)(?<a>a)(?<b>\1)(\2)/))); '"bab".match("/(?<a>.)(?<b>.)(?<c>.)k<c>k<b>k<a>/.exec("abccba").groups") must return ["bab", "b"]'
assert(compareArray(["<a", "<"], "<a".match(/(?<lt><)a/))); );
assert(compareArray([">a", ">"], ">a".match(/(?<gt>>)a/))); assert.compareArray(
"baba".match(/(.)(?<a>a)\1\2/),
["baba", "b", "a"],
'"baba".match("/(?<a>.)(?<b>.)(?<c>.)k<c>k<b>k<a>/.exec("abccba").groups") must return ["baba", "b", "a"]'
);
assert.compareArray(
"baba".match(/(.)(?<a>a)(?<b>\1)(\2)/),
["baba", "b", "a", "b", "a"],
'"baba".match("/(?<a>.)(?<b>.)(?<c>.)k<c>k<b>k<a>/.exec("abccba").groups") must return ["baba", "b", "a", "b", "a"]'
);
assert.compareArray(
"<a".match(/(?<lt><)a/),
["<a", "<"],
'"<a".match("/(?<a>.)(?<b>.)(?<c>.)k<c>k<b>k<a>/.exec("abccba").groups") must return ["<a", "<"]'
);
assert.compareArray(
">a".match(/(?<gt>>)a/),
[">a", ">"],
'">a".match("/(?<a>.)(?<b>.)(?<c>.)k<c>k<b>k<a>/.exec("abccba").groups") must return [">a", ">"]'
);

View File

@ -9,26 +9,78 @@ includes: [compareArray.js]
---*/ ---*/
// Named references. // Named references.
assert(compareArray(["bab", "b"], "bab".match(/(?<b>.).\k<b>/))); assert.compareArray(
assert.sameValue(null, "baa".match(/(?<b>.).\k<b>/)); "bab".match(/(?<b>.).\k<b>/),
["bab", "b"],
'"bab".match(""bab".match(/(?<b>b)k<a>(?<a>a)k<b>/).groups") must return ["bab", "b"]'
);
assert.sameValue(
"baa".match(/(?<b>.).\k<b>/),
null,
'"baa".match(""bab".match(/(?<b>b)k<a>(?<a>a)k<b>/).groups") must return null'
);
// Reference inside group. // Reference inside group.
assert(compareArray(["bab", "b"], "bab".match(/(?<a>\k<a>\w)../))); assert.compareArray(
assert.sameValue("b", "bab".match(/(?<a>\k<a>\w)../).groups.a); "bab".match(/(?<a>\k<a>\w)../),
["bab", "b"],
'"bab".match(""bab".match(/(?<b>b)k<a>(?<a>a)k<b>/).groups") must return ["bab", "b"]'
);
assert.sameValue(
"bab".match(/(?<a>\k<a>\w)../).groups.a,
"b",
'The value of "bab".match(/(?<a>k<a>w)../).groups.a is expected to be "b"'
);
// Reference before group. // Reference before group.
assert(compareArray(["bab", "b"], "bab".match(/\k<a>(?<a>b)\w\k<a>/))); assert.compareArray(
assert.sameValue("b", "bab".match(/\k<a>(?<a>b)\w\k<a>/).groups.a); "bab".match(/\k<a>(?<a>b)\w\k<a>/),
assert(compareArray(["bab", "b", "a"], "bab".match(/(?<b>b)\k<a>(?<a>a)\k<b>/))); ["bab", "b"],
'"bab".match(""bab".match(/(?<b>b)k<a>(?<a>a)k<b>/).groups") must return ["bab", "b"]'
);
assert.sameValue(
"bab".match(/\k<a>(?<a>b)\w\k<a>/).groups.a,
"b",
'The value of "bab".match(/k<a>(?<a>b)wk<a>/).groups.a is expected to be "b"'
);
assert.compareArray(
"bab".match(/(?<b>b)\k<a>(?<a>a)\k<b>/),
["bab", "b", "a"],
'"bab".match(""bab".match(/(?<b>b)k<a>(?<a>a)k<b>/).groups") must return ["bab", "b", "a"]'
);
let {a, b} = "bab".match(/(?<b>b)\k<a>(?<a>a)\k<b>/).groups; let {a, b} = "bab".match(/(?<b>b)\k<a>(?<a>a)\k<b>/).groups;
assert.sameValue(a, "a"); assert.sameValue(a, "a", 'The value of a is expected to be "a"');
assert.sameValue(b, "b"); assert.sameValue(b, "b", 'The value of b is expected to be "b"');
assert(compareArray(["bab", "b"], "bab".match(/\k<a>(?<a>b)\w\k<a>/))); assert.compareArray(
assert(compareArray(["bab", "b", "a"], "bab".match(/(?<b>b)\k<a>(?<a>a)\k<b>/))); "bab".match(/\k<a>(?<a>b)\w\k<a>/),
["bab", "b"],
'"bab".match(""bab".match(/(?<b>b)k<a>(?<a>a)k<b>/).groups") must return ["bab", "b"]'
);
assert.compareArray(
"bab".match(/(?<b>b)\k<a>(?<a>a)\k<b>/),
["bab", "b", "a"],
'"bab".match(""bab".match(/(?<b>b)k<a>(?<a>a)k<b>/).groups") must return ["bab", "b", "a"]'
);
// Reference properties. // Reference properties.
assert.sameValue("a", /(?<a>a)(?<b>b)\k<a>/.exec("aba").groups.a); assert.sameValue(
assert.sameValue("b", /(?<a>a)(?<b>b)\k<a>/.exec("aba").groups.b); /(?<a>a)(?<b>b)\k<a>/.exec("aba").groups.a,
assert.sameValue(undefined, /(?<a>a)(?<b>b)\k<a>/.exec("aba").groups.c); "a",
assert.sameValue(undefined, /(?<a>a)(?<b>b)\k<a>|(?<c>c)/.exec("aba").groups.c); 'The value of /(?<a>a)(?<b>b)k<a>/.exec("aba").groups.a is expected to be "a"'
);
assert.sameValue(
/(?<a>a)(?<b>b)\k<a>/.exec("aba").groups.b,
"b",
'The value of /(?<a>a)(?<b>b)k<a>/.exec("aba").groups.b is expected to be "b"'
);
assert.sameValue(
/(?<a>a)(?<b>b)\k<a>/.exec("aba").groups.c,
undefined,
'The value of /(?<a>a)(?<b>b)k<a>/.exec("aba").groups.c is expected to equal undefined'
);
assert.sameValue(
/(?<a>a)(?<b>b)\k<a>|(?<c>c)/.exec("aba").groups.c,
undefined,
'The value of /(?<a>a)(?<b>b)k<a>|(?<c>c)/.exec("aba").groups.c is expected to equal undefined'
);

View File

@ -8,41 +8,149 @@ features: [regexp-named-groups]
includes: [compareArray.js] includes: [compareArray.js]
---*/ ---*/
assert(compareArray(["a", "a"], "bab".match(/(?<a>a)/u))); assert.compareArray(
assert(compareArray(["a", "a"], "bab".match(/(?<a42>a)/u))); "bab".match(/(?<a>a)/u),
assert(compareArray(["a", "a"], "bab".match(/(?<_>a)/u))); ["a", "a"],
assert(compareArray(["a", "a"], "bab".match(/(?<$>a)/u))); '"bab".match(""bab".match(/(?<a>.(?<b>.(?<c>.)))/u).groups") must return ["a", "a"]'
assert(compareArray(["bab", "a"], "bab".match(/.(?<$>a)./u))); );
assert(compareArray(["bab", "a", "b"], "bab".match(/.(?<a>a)(.)/u))); assert.compareArray(
assert(compareArray(["bab", "a", "b"], "bab".match(/.(?<a>a)(?<b>.)/u))); "bab".match(/(?<a42>a)/u),
assert(compareArray(["bab", "ab"], "bab".match(/.(?<a>\w\w)/u))); ["a", "a"],
assert(compareArray(["bab", "bab"], "bab".match(/(?<a>\w\w\w)/u))); '"bab".match(""bab".match(/(?<a>.(?<b>.(?<c>.)))/u).groups") must return ["a", "a"]'
assert(compareArray(["bab", "ba", "b"], "bab".match(/(?<a>\w\w)(?<b>\w)/u))); );
assert.compareArray(
"bab".match(/(?<_>a)/u),
["a", "a"],
'"bab".match(""bab".match(/(?<a>.(?<b>.(?<c>.)))/u).groups") must return ["a", "a"]'
);
assert.compareArray(
"bab".match(/(?<$>a)/u),
["a", "a"],
'"bab".match(""bab".match(/(?<a>.(?<b>.(?<c>.)))/u).groups") must return ["a", "a"]'
);
assert.compareArray(
"bab".match(/.(?<$>a)./u),
["bab", "a"],
'"bab".match(""bab".match(/(?<a>.(?<b>.(?<c>.)))/u).groups") must return ["bab", "a"]'
);
assert.compareArray(
"bab".match(/.(?<a>a)(.)/u),
["bab", "a", "b"],
'"bab".match(""bab".match(/(?<a>.(?<b>.(?<c>.)))/u).groups") must return ["bab", "a", "b"]'
);
assert.compareArray(
"bab".match(/.(?<a>a)(?<b>.)/u),
["bab", "a", "b"],
'"bab".match(""bab".match(/(?<a>.(?<b>.(?<c>.)))/u).groups") must return ["bab", "a", "b"]'
);
assert.compareArray(
"bab".match(/.(?<a>\w\w)/u),
["bab", "ab"],
'"bab".match(""bab".match(/(?<a>.(?<b>.(?<c>.)))/u).groups") must return ["bab", "ab"]'
);
assert.compareArray(
"bab".match(/(?<a>\w\w\w)/u),
["bab", "bab"],
'"bab".match(""bab".match(/(?<a>.(?<b>.(?<c>.)))/u).groups") must return ["bab", "bab"]'
);
assert.compareArray(
"bab".match(/(?<a>\w\w)(?<b>\w)/u),
["bab", "ba", "b"],
'"bab".match(""bab".match(/(?<a>.(?<b>.(?<c>.)))/u).groups") must return ["bab", "ba", "b"]'
);
let {a, b, c} = /(?<a>.)(?<b>.)(?<c>.)\k<c>\k<b>\k<a>/u.exec("abccba").groups; let {a, b, c} = /(?<a>.)(?<b>.)(?<c>.)\k<c>\k<b>\k<a>/u.exec("abccba").groups;
assert.sameValue(a, "a"); assert.sameValue(a, "a", 'The value of a is expected to be "a"');
assert.sameValue(b, "b"); assert.sameValue(b, "b", 'The value of b is expected to be "b"');
assert.sameValue(c, "c"); assert.sameValue(c, "c", 'The value of c is expected to be "c"');
assert(compareArray("bab".match(/(a)/u), "bab".match(/(?<a>a)/u))); assert.compareArray(
assert(compareArray("bab".match(/(a)/u), "bab".match(/(?<a42>a)/u))); "bab".match(/(?<a>a)/u),
assert(compareArray("bab".match(/(a)/u), "bab".match(/(?<_>a)/u))); "bab".match(/(a)/u),
assert(compareArray("bab".match(/(a)/u), "bab".match(/(?<$>a)/u))); '"bab".match("/(?<a>.)(?<b>.)(?<c>.)k<c>k<b>k<a>/u.exec("abccba").groups") must return the same value returned by "bab".match(/(a)/u)'
assert(compareArray("bab".match(/.(a)./u), "bab".match(/.(?<$>a)./u))); );
assert(compareArray("bab".match(/.(a)(.)/u), "bab".match(/.(?<a>a)(.)/u))); assert.compareArray(
assert(compareArray("bab".match(/.(a)(.)/u), "bab".match(/.(?<a>a)(?<b>.)/u))); "bab".match(/(?<a42>a)/u),
assert(compareArray("bab".match(/.(\w\w)/u), "bab".match(/.(?<a>\w\w)/u))); "bab".match(/(a)/u),
assert(compareArray("bab".match(/(\w\w\w)/u), "bab".match(/(?<a>\w\w\w)/u))); '"bab".match("/(?<a>.)(?<b>.)(?<c>.)k<c>k<b>k<a>/u.exec("abccba").groups") must return the same value returned by "bab".match(/(a)/u)'
assert(compareArray("bab".match(/(\w\w)(\w)/u), "bab".match(/(?<a>\w\w)(?<b>\w)/u))); );
assert.compareArray(
"bab".match(/(?<_>a)/u),
"bab".match(/(a)/u),
'"bab".match("/(?<a>.)(?<b>.)(?<c>.)k<c>k<b>k<a>/u.exec("abccba").groups") must return the same value returned by "bab".match(/(a)/u)'
);
assert.compareArray(
"bab".match(/(?<$>a)/u),
"bab".match(/(a)/u),
'"bab".match("/(?<a>.)(?<b>.)(?<c>.)k<c>k<b>k<a>/u.exec("abccba").groups") must return the same value returned by "bab".match(/(a)/u)'
);
assert.compareArray(
"bab".match(/.(?<$>a)./u),
"bab".match(/.(a)./u),
'"bab".match("/(?<a>.)(?<b>.)(?<c>.)k<c>k<b>k<a>/u.exec("abccba").groups") must return the same value returned by "bab".match(/.(a)./u)'
);
assert.compareArray(
"bab".match(/.(?<a>a)(.)/u),
"bab".match(/.(a)(.)/u),
'"bab".match("/(?<a>.)(?<b>.)(?<c>.)k<c>k<b>k<a>/u.exec("abccba").groups") must return the same value returned by "bab".match(/.(a)(.)/u)'
);
assert.compareArray(
"bab".match(/.(?<a>a)(?<b>.)/u),
"bab".match(/.(a)(.)/u),
'"bab".match("/(?<a>.)(?<b>.)(?<c>.)k<c>k<b>k<a>/u.exec("abccba").groups") must return the same value returned by "bab".match(/.(a)(.)/u)'
);
assert.compareArray(
"bab".match(/.(?<a>\w\w)/u),
"bab".match(/.(\w\w)/u),
'"bab".match("/(?<a>.)(?<b>.)(?<c>.)k<c>k<b>k<a>/u.exec("abccba").groups") must return the same value returned by "bab".match(/.(ww)/u)'
);
assert.compareArray(
"bab".match(/(?<a>\w\w\w)/u),
"bab".match(/(\w\w\w)/u),
'"bab".match("/(?<a>.)(?<b>.)(?<c>.)k<c>k<b>k<a>/u.exec("abccba").groups") must return the same value returned by "bab".match(/(www)/u)'
);
assert.compareArray(
"bab".match(/(?<a>\w\w)(?<b>\w)/u),
"bab".match(/(\w\w)(\w)/u),
'"bab".match("/(?<a>.)(?<b>.)(?<c>.)k<c>k<b>k<a>/u.exec("abccba").groups") must return the same value returned by "bab".match(/(ww)(w)/u)'
);
assert(compareArray(["bab", "b"], "bab".match(/(?<b>b).\1/u))); assert.compareArray(
assert(compareArray(["baba", "b", "a"], "baba".match(/(.)(?<a>a)\1\2/u))); "bab".match(/(?<b>b).\1/u),
assert(compareArray(["baba", "b", "a", "b", "a"], ["bab", "b"],
"baba".match(/(.)(?<a>a)(?<b>\1)(\2)/u))); '"bab".match("/(?<a>.)(?<b>.)(?<c>.)k<c>k<b>k<a>/u.exec("abccba").groups") must return ["bab", "b"]'
assert(compareArray(["<a", "<"], "<a".match(/(?<lt><)a/u))); );
assert(compareArray([">a", ">"], ">a".match(/(?<gt>>)a/u))); assert.compareArray(
"baba".match(/(.)(?<a>a)\1\2/u),
["baba", "b", "a"],
'"baba".match("/(?<a>.)(?<b>.)(?<c>.)k<c>k<b>k<a>/u.exec("abccba").groups") must return ["baba", "b", "a"]'
);
assert.compareArray(
"baba".match(/(.)(?<a>a)(?<b>\1)(\2)/u),
["baba", "b", "a", "b", "a"],
'"baba".match("/(?<a>.)(?<b>.)(?<c>.)k<c>k<b>k<a>/u.exec("abccba").groups") must return ["baba", "b", "a", "b", "a"]'
);
assert.compareArray(
"<a".match(/(?<lt><)a/u),
["<a", "<"],
'"<a".match("/(?<a>.)(?<b>.)(?<c>.)k<c>k<b>k<a>/u.exec("abccba").groups") must return ["<a", "<"]'
);
assert.compareArray(
">a".match(/(?<gt>>)a/u),
[">a", ">"],
'">a".match("/(?<a>.)(?<b>.)(?<c>.)k<c>k<b>k<a>/u.exec("abccba").groups") must return [">a", ">"]'
);
// Nested groups. // Nested groups.
assert(compareArray(["bab", "bab", "ab", "b"], "bab".match(/(?<a>.(?<b>.(?<c>.)))/u))); assert.compareArray(
assert(compareArray({a: "bab", b: "ab", c: "b"}, "bab".match(/(?<a>.(?<b>.(?<c>.)))/u),
"bab".match(/(?<a>.(?<b>.(?<c>.)))/u).groups)); ["bab", "bab", "ab", "b"],
'"bab".match("/(?<a>.)(?<b>.)(?<c>.)k<c>k<b>k<a>/u.exec("abccba").groups") must return ["bab", "bab", "ab", "b"]'
);
{
let {a, b, c} = "bab".match(/(?<a>.(?<b>.(?<c>.)))/u).groups
assert.sameValue(a, "bab", 'The value of a is expected to be "bab"');
assert.sameValue(b, "ab", 'The value of b is expected to be "ab"');
assert.sameValue(c, "b", 'The value of c is expected to be "b"');
}

View File

@ -22,26 +22,79 @@ includes: [compareArray.js]
---*/ ---*/
// Named references. // Named references.
assert(compareArray(["bab", "b"], "bab".match(/(?<b>.).\k<b>/u))); assert.compareArray(
assert.sameValue(null, "baa".match(/(?<b>.).\k<b>/u)); "bab".match(/(?<b>.).\k<b>/u),
["bab", "b"],
'"bab".match(""bab".match(/(?<b>b)k<a>(?<a>a)k<b>/u).groups") must return ["bab", "b"]'
);
assert.sameValue(
"baa".match(/(?<b>.).\k<b>/u),
null,
'"baa".match(""bab".match(/(?<b>b)k<a>(?<a>a)k<b>/u).groups") must return null'
);
// Reference inside group. // Reference inside group.
assert(compareArray(["bab", "b"], "bab".match(/(?<a>\k<a>\w)../u))); assert.compareArray(
assert.sameValue("b", "bab".match(/(?<a>\k<a>\w)../u).groups.a); "bab".match(/(?<a>\k<a>\w)../u),
["bab", "b"],
'"bab".match(""bab".match(/(?<b>b)k<a>(?<a>a)k<b>/u).groups") must return ["bab", "b"]'
);
assert.sameValue(
"bab".match(/(?<a>\k<a>\w)../u).groups.a,
"b",
'The value of "bab".match(/(?<a>k<a>w)../u).groups.a is expected to be "b"'
);
// Reference before group. // Reference before group.
assert(compareArray(["bab", "b"], "bab".match(/\k<a>(?<a>b)\w\k<a>/u))); assert.compareArray(
assert.sameValue("b", "bab".match(/\k<a>(?<a>b)\w\k<a>/u).groups.a); "bab".match(/\k<a>(?<a>b)\w\k<a>/u),
assert(compareArray(["bab", "b", "a"], "bab".match(/(?<b>b)\k<a>(?<a>a)\k<b>/u))); ["bab", "b"],
let {a, b} = "bab".match(/(?<b>b)\k<a>(?<a>a)\k<b>/u).groups; '"bab".match(""bab".match(/(?<b>b)k<a>(?<a>a)k<b>/u).groups") must return ["bab", "b"]'
assert.sameValue(a, "a"); );
assert.sameValue(b, "b"); assert.sameValue(
"bab".match(/\k<a>(?<a>b)\w\k<a>/u).groups.a,
"b",
'The value of "bab".match(/k<a>(?<a>b)wk<a>/u).groups.a is expected to be "b"'
);
assert.compareArray(
"bab".match(/(?<b>b)\k<a>(?<a>a)\k<b>/u),
["bab", "b", "a"],
'"bab".match(""bab".match(/(?<b>b)k<a>(?<a>a)k<b>/u).groups") must return ["bab", "b", "a"]'
);
assert(compareArray(["bab", "b"], "bab".match(/\k<a>(?<a>b)\w\k<a>/))); let {a, b} = "bab".match(/(?<b>b)\k<a>(?<a>a)\k<b>/u).groups;
assert(compareArray(["bab", "b", "a"], "bab".match(/(?<b>b)\k<a>(?<a>a)\k<b>/))); assert.sameValue(a, "a", 'The value of a is expected to be "a"');
assert.sameValue(b, "b", 'The value of b is expected to be "b"');
assert.compareArray(
"bab".match(/\k<a>(?<a>b)\w\k<a>/),
["bab", "b"],
'"bab".match(""bab".match(/(?<b>b)k<a>(?<a>a)k<b>/u).groups") must return ["bab", "b"]'
);
assert.compareArray(
"bab".match(/(?<b>b)\k<a>(?<a>a)\k<b>/),
["bab", "b", "a"],
'"bab".match(""bab".match(/(?<b>b)k<a>(?<a>a)k<b>/u).groups") must return ["bab", "b", "a"]'
);
// Reference properties. // Reference properties.
assert.sameValue("a", /(?<a>a)(?<b>b)\k<a>/u.exec("aba").groups.a); assert.sameValue(
assert.sameValue("b", /(?<a>a)(?<b>b)\k<a>/u.exec("aba").groups.b); /(?<a>a)(?<b>b)\k<a>/u.exec("aba").groups.a,
assert.sameValue(undefined, /(?<a>a)(?<b>b)\k<a>/u.exec("aba").groups.c); "a",
assert.sameValue(undefined, /(?<a>a)(?<b>b)\k<a>|(?<c>c)/u.exec("aba").groups.c); 'The value of /(?<a>a)(?<b>b)k<a>/u.exec("aba").groups.a is expected to be "a"'
);
assert.sameValue(
/(?<a>a)(?<b>b)\k<a>/u.exec("aba").groups.b,
"b",
'The value of /(?<a>a)(?<b>b)k<a>/u.exec("aba").groups.b is expected to be "b"'
);
assert.sameValue(
/(?<a>a)(?<b>b)\k<a>/u.exec("aba").groups.c,
undefined,
'The value of /(?<a>a)(?<b>b)k<a>/u.exec("aba").groups.c is expected to equal undefined'
);
assert.sameValue(
/(?<a>a)(?<b>b)\k<a>|(?<c>c)/u.exec("aba").groups.c,
undefined,
'The value of /(?<a>a)(?<b>b)k<a>|(?<c>c)/u.exec("aba").groups.c is expected to equal undefined'
);

View File

@ -25,7 +25,7 @@ const fields = {
} }
} }
} }
assert( assert.compareArray(
compareArray(cal.fields(fields), Array.from(fields)), cal.fields(fields), Array.from(fields),
'compareArray(cal.fields(fields), Array.from(fields)) must return true' 'cal.fields("{*[Symbol.iterator]() {let i = 0; while (i++ < 1000001) {yield "garbage " + i;}}}) must return the same value returned by Array.from(fields)'
); );

View File

@ -25,53 +25,40 @@ info: |
includes: [compareArray.js, testBigIntTypedArray.js] includes: [compareArray.js, testBigIntTypedArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, null), new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, null),
[0n, 1n, 2n, 3n] [0n, 1n, 2n, 3n],
), 'new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, null) must return [0n, 1n, 2n, 3n]'
'null value coerced to 0'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, NaN), new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, NaN),
[0n, 1n, 2n, 3n] [0n, 1n, 2n, 3n],
), 'new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, NaN) must return [0n, 1n, 2n, 3n]'
'NaN value coerced to 0'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, false), new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, false),
[0n, 1n, 2n, 3n] [0n, 1n, 2n, 3n],
), 'new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, false) must return [0n, 1n, 2n, 3n]'
'false value coerced to 0'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, true), new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, true),
[0n, 0n, 2n, 3n] [0n, 0n, 2n, 3n],
), 'new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, true) must return [0n, 0n, 2n, 3n]'
'true value coerced to 1'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, '-2'), new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, '-2'),
[0n, 0n, 1n, 3n] [0n, 0n, 1n, 3n],
), 'new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, "-2") must return [0n, 0n, 1n, 3n]'
'string "-2" value coerced to integer -2'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, -2.5), new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, -2.5),
[0n, 0n, 1n, 3n] [0n, 0n, 1n, 3n],
), 'new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, -2.5) must return [0n, 0n, 1n, 3n]'
'float -2.5 value coerced to integer -2'
); );
}); });

View File

@ -24,69 +24,52 @@ info: |
includes: [compareArray.js, testBigIntTypedArray.js] includes: [compareArray.js, testBigIntTypedArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n]).copyWithin(1, undefined), new TA([0n, 1n, 2n, 3n]).copyWithin(1, undefined),
[0n, 0n, 1n, 2n] [0n, 0n, 1n, 2n],
), 'new TA([0n, 1n, 2n, 3n]).copyWithin(1, undefined) must return [0n, 0n, 1n, 2n]'
'undefined value coerced to 0'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n]).copyWithin(1, false), new TA([0n, 1n, 2n, 3n]).copyWithin(1, false),
[0n, 0n, 1n, 2n] [0n, 0n, 1n, 2n],
), 'new TA([0n, 1n, 2n, 3n]).copyWithin(1, false) must return [0n, 0n, 1n, 2n]'
'false value coerced to 0'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n]).copyWithin(1, NaN), new TA([0n, 1n, 2n, 3n]).copyWithin(1, NaN),
[0n, 0n, 1n, 2n] [0n, 0n, 1n, 2n],
), 'new TA([0n, 1n, 2n, 3n]).copyWithin(1, NaN) must return [0n, 0n, 1n, 2n]'
'NaN value coerced to 0'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n]).copyWithin(1, null), new TA([0n, 1n, 2n, 3n]).copyWithin(1, null),
[0n, 0n, 1n, 2n] [0n, 0n, 1n, 2n],
), 'new TA([0n, 1n, 2n, 3n]).copyWithin(1, null) must return [0n, 0n, 1n, 2n]'
'null value coerced to 0'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n]).copyWithin(0, true), new TA([0n, 1n, 2n, 3n]).copyWithin(0, true),
[1n, 2n, 3n, 3n] [1n, 2n, 3n, 3n],
), 'new TA([0n, 1n, 2n, 3n]).copyWithin(0, true) must return [1n, 2n, 3n, 3n]'
'true value coerced to 1'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n]).copyWithin(0, '1'), new TA([0n, 1n, 2n, 3n]).copyWithin(0, '1'),
[1n, 2n, 3n, 3n] [1n, 2n, 3n, 3n],
), 'new TA([0n, 1n, 2n, 3n]).copyWithin(0, "1") must return [1n, 2n, 3n, 3n]'
'string "1" value coerced to 1'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0.5), new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0.5),
[0n, 0n, 1n, 2n] [0n, 0n, 1n, 2n],
), 'new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0.5) must return [0n, 0n, 1n, 2n]'
'0.5 float value coerced to integer 0'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1.5), new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1.5),
[1n, 2n, 3n, 3n] [1n, 2n, 3n, 3n],
), 'new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1.5) must return [1n, 2n, 3n, 3n]'
'1.5 float value coerced to integer 1'
); );
}); });

View File

@ -24,69 +24,52 @@ info: |
includes: [compareArray.js, testBigIntTypedArray.js] includes: [compareArray.js, testBigIntTypedArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n]).copyWithin(undefined, 1), new TA([0n, 1n, 2n, 3n]).copyWithin(undefined, 1),
[1n, 2n, 3n, 3n] [1n, 2n, 3n, 3n],
), 'new TA([0n, 1n, 2n, 3n]).copyWithin(undefined, 1) must return [1n, 2n, 3n, 3n]'
'undefined value coerced to 0'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n]).copyWithin(false, 1), new TA([0n, 1n, 2n, 3n]).copyWithin(false, 1),
[1n, 2n, 3n, 3n] [1n, 2n, 3n, 3n],
), 'new TA([0n, 1n, 2n, 3n]).copyWithin(false, 1) must return [1n, 2n, 3n, 3n]'
'false value coerced to 0'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n]).copyWithin(NaN, 1), new TA([0n, 1n, 2n, 3n]).copyWithin(NaN, 1),
[1n, 2n, 3n, 3n] [1n, 2n, 3n, 3n],
), 'new TA([0n, 1n, 2n, 3n]).copyWithin(NaN, 1) must return [1n, 2n, 3n, 3n]'
'NaN value coerced to 0'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n]).copyWithin(null, 1), new TA([0n, 1n, 2n, 3n]).copyWithin(null, 1),
[1n, 2n, 3n, 3n] [1n, 2n, 3n, 3n],
), 'new TA([0n, 1n, 2n, 3n]).copyWithin(null, 1) must return [1n, 2n, 3n, 3n]'
'null value coerced to 0'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n]).copyWithin(true, 0), new TA([0n, 1n, 2n, 3n]).copyWithin(true, 0),
[0n, 0n, 1n, 2n] [0n, 0n, 1n, 2n],
), 'new TA([0n, 1n, 2n, 3n]).copyWithin(true, 0) must return [0n, 0n, 1n, 2n]'
'true value coerced to 1'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n]).copyWithin('1', 0), new TA([0n, 1n, 2n, 3n]).copyWithin('1', 0),
[0n, 0n, 1n, 2n] [0n, 0n, 1n, 2n],
), 'new TA([0n, 1n, 2n, 3n]).copyWithin("1", 0) must return [0n, 0n, 1n, 2n]'
'string "1" value coerced to 1'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n]).copyWithin(0.5, 1), new TA([0n, 1n, 2n, 3n]).copyWithin(0.5, 1),
[1n, 2n, 3n, 3n] [1n, 2n, 3n, 3n],
), 'new TA([0n, 1n, 2n, 3n]).copyWithin(0.5, 1) must return [1n, 2n, 3n, 3n]'
'0.5 float value coerced to integer 0'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n]).copyWithin(1.5, 0), new TA([0n, 1n, 2n, 3n]).copyWithin(1.5, 0),
[0n, 0n, 1n, 2n] [0n, 0n, 1n, 2n],
), 'new TA([0n, 1n, 2n, 3n]).copyWithin(1.5, 0) must return [0n, 0n, 1n, 2n]'
'1.5 float value coerced to integer 1'
); );
}); });

View File

@ -27,69 +27,52 @@ info: |
includes: [compareArray.js, testBigIntTypedArray.js] includes: [compareArray.js, testBigIntTypedArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1, -1), new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1, -1),
[1n, 2n, 2n, 3n] [1n, 2n, 2n, 3n],
), 'new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1, -1) must return [1n, 2n, 2n, 3n]'
'[0, 1, 2, 3].copyWithin(0, 1, -1) -> [1, 2, 2, 3]'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(2, 0, -1), new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(2, 0, -1),
[0n, 1n, 0n, 1n, 2n] [0n, 1n, 0n, 1n, 2n],
), 'new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(2, 0, -1) must return [0n, 1n, 0n, 1n, 2n]'
'[0, 1, 2, 3, 4].copyWithin(2, 0, -1) -> [0, 1, 0, 1, 2]'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(1, 2, -2), new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(1, 2, -2),
[0n, 2n, 2n, 3n, 4n] [0n, 2n, 2n, 3n, 4n],
), 'new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(1, 2, -2) must return [0n, 2n, 2n, 3n, 4n]'
'[0, 1, 2, 3, 4].copyWithin(1, 2, -2) -> [0, 2, 2, 3, 4]'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n]).copyWithin(0, -2, -1), new TA([0n, 1n, 2n, 3n]).copyWithin(0, -2, -1),
[2n, 1n, 2n, 3n] [2n, 1n, 2n, 3n],
), 'new TA([0n, 1n, 2n, 3n]).copyWithin(0, -2, -1) must return [2n, 1n, 2n, 3n]'
'[0, 1, 2, 3].copyWithin(0, -2, -1) -> [2, 1, 2, 3]'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(2, -2, -1), new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(2, -2, -1),
[0n, 1n, 3n, 3n, 4n] [0n, 1n, 3n, 3n, 4n],
), 'new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(2, -2, -1) must return [0n, 1n, 3n, 3n, 4n]'
'[0, 1, 2, 3, 4].copyWithin(2, -2, 1) -> [0, 1, 3, 3, 4]'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n]).copyWithin(-3, -2, -1), new TA([0n, 1n, 2n, 3n]).copyWithin(-3, -2, -1),
[0n, 2n, 2n, 3n] [0n, 2n, 2n, 3n],
), 'new TA([0n, 1n, 2n, 3n]).copyWithin(-3, -2, -1) must return [0n, 2n, 2n, 3n]'
'[0, 1, 2, 3].copyWithin(-3, -2, -1) -> [0, 2, 2, 3]'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-2, -3, -1), new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-2, -3, -1),
[0n, 1n, 2n, 2n, 3n] [0n, 1n, 2n, 2n, 3n],
), 'new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-2, -3, -1) must return [0n, 1n, 2n, 2n, 3n]'
'[0, 1, 2, 3, 4].copyWithin(-2, -3, -1) -> [0, 1, 2, 2, 3]'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-5, -2, -1), new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-5, -2, -1),
[3n, 1n, 2n, 3n, 4n] [3n, 1n, 2n, 3n, 4n],
), 'new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-5, -2, -1) must return [3n, 1n, 2n, 3n, 4n]'
'[0, 1, 2, 3, 4].copyWithin(-5, -2, -1) -> [3, 1, 2, 3, 4]'
); );
}); });

View File

@ -27,85 +27,64 @@ info: |
includes: [compareArray.js, testBigIntTypedArray.js] includes: [compareArray.js, testBigIntTypedArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1, -10), new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1, -10),
[0n, 1n, 2n, 3n] [0n, 1n, 2n, 3n],
), 'new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1, -10) must return [0n, 1n, 2n, 3n]'
'[0, 1, 2, 3].copyWithin(0, 1, -10) -> [0, 1, 2, 3]'
); );
assert( assert.compareArray(
compareArray(
new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, 1, -Infinity), new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, 1, -Infinity),
[1n, 2n, 3n, 4n, 5n] [1n, 2n, 3n, 4n, 5n],
), 'new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, 1, -Infinity) must return [1n, 2n, 3n, 4n, 5n]'
'[1, 2, 3, 4, 5].copyWithin(0, 1, -Infinity) -> [1, 2, 3, 4, 5]'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n]).copyWithin(0, -2, -10), new TA([0n, 1n, 2n, 3n]).copyWithin(0, -2, -10),
[0n, 1n, 2n, 3n] [0n, 1n, 2n, 3n],
), 'new TA([0n, 1n, 2n, 3n]).copyWithin(0, -2, -10) must return [0n, 1n, 2n, 3n]'
'[0, 1, 2, 3].copyWithin(0, -2, -10) -> [0, 1, 2, 3]'
); );
assert( assert.compareArray(
compareArray(
new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, -2, -Infinity), new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, -2, -Infinity),
[1n, 2n, 3n, 4n, 5n] [1n, 2n, 3n, 4n, 5n],
), 'new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, -2, -Infinity) must return [1n, 2n, 3n, 4n, 5n]'
'[1, 2, 3, 4, 5].copyWithin(0, -2, -Infinity) -> [1, 2, 3, 4, 5]'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n]).copyWithin(0, -9, -10), new TA([0n, 1n, 2n, 3n]).copyWithin(0, -9, -10),
[0n, 1n, 2n, 3n] [0n, 1n, 2n, 3n],
), 'new TA([0n, 1n, 2n, 3n]).copyWithin(0, -9, -10) must return [0n, 1n, 2n, 3n]'
'[0, 1, 2, 3].copyWithin(0, -9, -10) -> [0, 1, 2, 3]'
); );
assert( assert.compareArray(
compareArray(
new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, -9, -Infinity), new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, -9, -Infinity),
[1n, 2n, 3n, 4n, 5n] [1n, 2n, 3n, 4n, 5n],
), 'new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, -9, -Infinity) must return [1n, 2n, 3n, 4n, 5n]'
'[1, 2, 3, 4, 5].copyWithin(0, -9, -Infinity) -> [1, 2, 3, 4, 5]'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n]).copyWithin(-3, -2, -10), new TA([0n, 1n, 2n, 3n]).copyWithin(-3, -2, -10),
[0n, 1n, 2n, 3n] [0n, 1n, 2n, 3n],
), 'new TA([0n, 1n, 2n, 3n]).copyWithin(-3, -2, -10) must return [0n, 1n, 2n, 3n]'
'[0, 1, 2, 3].copyWithin(-3, -2, -10) -> [0, 1, 2, 3]'
); );
assert( assert.compareArray(
compareArray(
new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(-3, -2, -Infinity), new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(-3, -2, -Infinity),
[1n, 2n, 3n, 4n, 5n] [1n, 2n, 3n, 4n, 5n],
), 'new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(-3, -2, -Infinity) must return [1n, 2n, 3n, 4n, 5n]'
'[1, 2, 3, 4, 5].copyWithin(-3, -2, -Infinity) -> [1, 2, 3, 4, 5]'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n]).copyWithin(-7, -8, -9), new TA([0n, 1n, 2n, 3n]).copyWithin(-7, -8, -9),
[0n, 1n, 2n, 3n] [0n, 1n, 2n, 3n],
), 'new TA([0n, 1n, 2n, 3n]).copyWithin(-7, -8, -9) must return [0n, 1n, 2n, 3n]'
'[0, 1, 2, 3].copyWithin(-7, -8, -9) -> [0, 1, 2, 3]'
); );
assert( assert.compareArray(
compareArray(
new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(-7, -8, -Infinity), new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(-7, -8, -Infinity),
[1n, 2n, 3n, 4n, 5n] [1n, 2n, 3n, 4n, 5n],
), 'new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(-7, -8, -Infinity) must return [1n, 2n, 3n, 4n, 5n]'
'[1, 2, 3, 4, 5].copyWithin(-7, -8, -Infinity) -> [1, 2, 3, 4, 5]'
); );
}); });

View File

@ -25,69 +25,52 @@ info: |
includes: [compareArray.js, testBigIntTypedArray.js] includes: [compareArray.js, testBigIntTypedArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n]).copyWithin(0, -10), new TA([0n, 1n, 2n, 3n]).copyWithin(0, -10),
[0n, 1n, 2n, 3n] [0n, 1n, 2n, 3n],
), 'new TA([0n, 1n, 2n, 3n]).copyWithin(0, -10) must return [0n, 1n, 2n, 3n]'
'[0, 1, 2, 3]).copyWithin(0, -10) -> [0, 1, 2, 3]'
); );
assert( assert.compareArray(
compareArray(
new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, -Infinity), new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, -Infinity),
[1n, 2n, 3n, 4n, 5n] [1n, 2n, 3n, 4n, 5n],
), 'new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, -Infinity) must return [1n, 2n, 3n, 4n, 5n]'
'[1, 2, 3, 4, 5]).copyWithin(0, -Infinity) -> [1, 2, 3, 4, 5]'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(2, -10), new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(2, -10),
[0n, 1n, 0n, 1n, 2n] [0n, 1n, 0n, 1n, 2n],
), 'new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(2, -10) must return [0n, 1n, 0n, 1n, 2n]'
'[0, 1, 2, 3, 4]).copyWithin(2, -2) -> [0, 1, 0, 1, 2]'
); );
assert( assert.compareArray(
compareArray(
new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(2, -Infinity), new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(2, -Infinity),
[1n, 2n, 1n, 2n, 3n] [1n, 2n, 1n, 2n, 3n],
), 'new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(2, -Infinity) must return [1n, 2n, 1n, 2n, 3n]'
'[1, 2, 3, 4, 5]).copyWithin(2, -Infinity) -> [1, 2, 1, 2, 3]'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(10, -10), new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(10, -10),
[0n, 1n, 2n, 3n, 4n] [0n, 1n, 2n, 3n, 4n],
), 'new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(10, -10) must return [0n, 1n, 2n, 3n, 4n]'
'[0, 1, 2, 3, 4]).copyWithin(10, -10) -> [0, 1, 2, 3, 4]'
); );
assert( assert.compareArray(
compareArray(
new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(10, -Infinity), new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(10, -Infinity),
[1n, 2n, 3n, 4n, 5n] [1n, 2n, 3n, 4n, 5n],
), 'new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(10, -Infinity) must return [1n, 2n, 3n, 4n, 5n]'
'[1, 2, 3, 4, 5]).copyWithin(10, -Infinity) -> [1, 2, 3, 4, 5]'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n]).copyWithin(-9, -10), new TA([0n, 1n, 2n, 3n]).copyWithin(-9, -10),
[0n, 1n, 2n, 3n] [0n, 1n, 2n, 3n],
), 'new TA([0n, 1n, 2n, 3n]).copyWithin(-9, -10) must return [0n, 1n, 2n, 3n]'
'[0, 1, 2, 3].copyWithin(-9, -10) -> [0, 1, 2, 3]'
); );
assert( assert.compareArray(
compareArray(
new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(-9, -Infinity), new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(-9, -Infinity),
[1n, 2n, 3n, 4n, 5n] [1n, 2n, 3n, 4n, 5n],
), 'new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(-9, -Infinity) must return [1n, 2n, 3n, 4n, 5n]'
'[1, 2, 3, 4, 5].copyWithin(-9, -Infinity) -> [1, 2, 3, 4, 5]'
); );
}); });

View File

@ -25,37 +25,28 @@ info: |
includes: [compareArray.js, testBigIntTypedArray.js] includes: [compareArray.js, testBigIntTypedArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n]).copyWithin(-10, 0), new TA([0n, 1n, 2n, 3n]).copyWithin(-10, 0),
[0n, 1n, 2n, 3n] [0n, 1n, 2n, 3n],
), 'new TA([0n, 1n, 2n, 3n]).copyWithin(-10, 0) must return [0n, 1n, 2n, 3n]'
'[0, 1, 2, 3].copyWithin(-10, 0) -> [0, 1, 2, 3]'
); );
assert( assert.compareArray(
compareArray(
new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(-Infinity, 0), new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(-Infinity, 0),
[1n, 2n, 3n, 4n, 5n] [1n, 2n, 3n, 4n, 5n],
), 'new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(-Infinity, 0) must return [1n, 2n, 3n, 4n, 5n]'
'[1, 2, 3, 4, 5].copyWithin(-Infinity, 0) -> [1, 2, 3, 4, 5]'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-10, 2), new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-10, 2),
[2n, 3n, 4n, 3n, 4n] [2n, 3n, 4n, 3n, 4n],
), 'new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-10, 2) must return [2n, 3n, 4n, 3n, 4n]'
'[0, 1, 2, 3, 4].copyWithin(-10, 2) -> [2, 3, 4, 3, 4]'
); );
assert( assert.compareArray(
compareArray(
new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(-Infinity, 2), new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(-Infinity, 2),
[3n, 4n, 5n, 4n, 5n] [3n, 4n, 5n, 4n, 5n],
), 'new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(-Infinity, 2) must return [3n, 4n, 5n, 4n, 5n]'
'[1, 2, 3, 4, 5].copyWithin(-Infinity, 2) -> [3, 4, 5, 4, 5]'
); );
}); });

View File

@ -25,53 +25,40 @@ info: |
includes: [compareArray.js, testBigIntTypedArray.js] includes: [compareArray.js, testBigIntTypedArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n]).copyWithin(0, -1), new TA([0n, 1n, 2n, 3n]).copyWithin(0, -1),
[3n, 1n, 2n, 3n] [3n, 1n, 2n, 3n],
), 'new TA([0n, 1n, 2n, 3n]).copyWithin(0, -1) must return [3n, 1n, 2n, 3n]'
'[0, 1, 2, 3].copyWithin(0, -1) -> [3, 1, 2, 3]'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(2, -2), new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(2, -2),
[0n, 1n, 3n, 4n, 4n] [0n, 1n, 3n, 4n, 4n],
), 'new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(2, -2) must return [0n, 1n, 3n, 4n, 4n]'
'[0, 1, 2, 3, 4].copyWithin(2, -2) -> [0, 1, 3, 4, 4]'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(1, -2), new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(1, -2),
[0n, 3n, 4n, 3n, 4n] [0n, 3n, 4n, 3n, 4n],
), 'new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(1, -2) must return [0n, 3n, 4n, 3n, 4n]'
'[0, 1, 2, 3, 4].copyWithin(1, -2) -> [0, 3, 4, 3, 4]'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n]).copyWithin(-1, -2), new TA([0n, 1n, 2n, 3n]).copyWithin(-1, -2),
[0n, 1n, 2n, 2n] [0n, 1n, 2n, 2n],
), 'new TA([0n, 1n, 2n, 3n]).copyWithin(-1, -2) must return [0n, 1n, 2n, 2n]'
'[0, 1, 2, 3].copyWithin(-1, -2) -> [ 0, 1, 2, 2 ]'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-2, -3), new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-2, -3),
[0n, 1n, 2n, 2n, 3n] [0n, 1n, 2n, 2n, 3n],
), 'new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-2, -3) must return [0n, 1n, 2n, 2n, 3n]'
'[0, 1, 2, 3, 4].copyWithin(-2, -3) -> [0, 1, 2, 2, 3]'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-5, -2), new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-5, -2),
[3n, 4n, 2n, 3n, 4n] [3n, 4n, 2n, 3n, 4n],
), 'new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-5, -2) must return [3n, 4n, 2n, 3n, 4n]'
'[0, 1, 2, 3, 4].copyWithin(-5, -2) -> [3, 4, 2, 3, 4]'
); );
}); });

View File

@ -25,29 +25,22 @@ info: |
includes: [compareArray.js, testBigIntTypedArray.js] includes: [compareArray.js, testBigIntTypedArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n]).copyWithin(-1, 0), new TA([0n, 1n, 2n, 3n]).copyWithin(-1, 0),
[0n, 1n, 2n, 0n] [0n, 1n, 2n, 0n],
), 'new TA([0n, 1n, 2n, 3n]).copyWithin(-1, 0) must return [0n, 1n, 2n, 0n]'
'[0, 1, 2, 3].copyWithin(-1, 0) -> [0, 1, 2, 0]'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-2, 2), new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-2, 2),
[0n, 1n, 2n, 2n, 3n] [0n, 1n, 2n, 2n, 3n],
), 'new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-2, 2) must return [0n, 1n, 2n, 2n, 3n]'
'[0, 1, 2, 3, 4].copyWithin(-2, 2) -> [0, 1, 2, 2, 3]'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n]).copyWithin(-1, 2), new TA([0n, 1n, 2n, 3n]).copyWithin(-1, 2),
[0n, 1n, 2n, 2n] [0n, 1n, 2n, 2n],
), 'new TA([0n, 1n, 2n, 3n]).copyWithin(-1, 2) must return [0n, 1n, 2n, 2n]'
'[0, 1, 2, 3].copyWithin(-1, 2) -> [0, 1, 2, 2]'
); );
}); });

View File

@ -18,37 +18,28 @@ info: |
includes: [compareArray.js, testBigIntTypedArray.js] includes: [compareArray.js, testBigIntTypedArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1, 6), new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1, 6),
[1n, 2n, 3n, 3n] [1n, 2n, 3n, 3n],
), 'new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1, 6) must return [1n, 2n, 3n, 3n]'
'[0, 1, 2, 3].copyWithin(0, 1, 6) -> [1, 2, 3, 3]'
); );
assert( assert.compareArray(
compareArray(
new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, 1, Infinity), new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, 1, Infinity),
[2n, 3n, 4n, 5n, 5n] [2n, 3n, 4n, 5n, 5n],
), 'new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, 1, Infinity) must return [2n, 3n, 4n, 5n, 5n]'
'[1, 2, 3, 4, 5].copyWithin(0, 1, Infinity) -> [2, 3, 4, 5, 5]'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(1, 3, 6), new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(1, 3, 6),
[0n, 3n, 4n, 5n, 4n, 5n] [0n, 3n, 4n, 5n, 4n, 5n],
), 'new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(1, 3, 6) must return [0n, 3n, 4n, 5n, 4n, 5n]'
'[0, 1, 2, 3, 4, 5].copyWithin(1, 3, 6) -> [0, 3, 4, 5, 4, 5]'
); );
assert( assert.compareArray(
compareArray(
new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(1, 3, Infinity), new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(1, 3, Infinity),
[1n, 4n, 5n, 4n, 5n] [1n, 4n, 5n, 4n, 5n],
), 'new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(1, 3, Infinity) must return [1n, 4n, 5n, 4n, 5n]'
'[1, 2, 3, 4, 5].copyWithin(1, 3, Infinity) -> [1, 4, 5, 4, 5]'
); );
}); });

View File

@ -18,57 +18,46 @@ info: |
includes: [compareArray.js, testBigIntTypedArray.js] includes: [compareArray.js, testBigIntTypedArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(6, 0), new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(6, 0),
[0n, 1n, 2n, 3n, 4n, 5n] [0n, 1n, 2n, 3n, 4n, 5n],
) 'new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(6, 0) must return [0n, 1n, 2n, 3n, 4n, 5n]'
); );
assert( assert.compareArray(
compareArray(
new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(Infinity, 0), new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(Infinity, 0),
[1n, 2n, 3n, 4n, 5n] [1n, 2n, 3n, 4n, 5n],
), 'new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(Infinity, 0) must return [1n, 2n, 3n, 4n, 5n]'
'[1, 2, 3, 4, 5].copyWithin(Infinity, 0) -> [1, 2, 3, 4, 5]'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(0, 6), new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(0, 6),
[0n, 1n, 2n, 3n, 4n, 5n] [0n, 1n, 2n, 3n, 4n, 5n],
) 'new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(0, 6) must return [0n, 1n, 2n, 3n, 4n, 5n]'
); );
assert( assert.compareArray(
compareArray(
new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, Infinity), new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, Infinity),
[1n, 2n, 3n, 4n, 5n] [1n, 2n, 3n, 4n, 5n],
), 'new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, Infinity) must return [1n, 2n, 3n, 4n, 5n]'
'[1, 2, 3, 4, 5].copyWithin(0, Infinity) -> [1, 2, 3, 4, 5]'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(6, 6), new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(6, 6),
[0n, 1n, 2n, 3n, 4n, 5n] [0n, 1n, 2n, 3n, 4n, 5n],
) 'new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(6, 6) must return [0n, 1n, 2n, 3n, 4n, 5n]'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(10, 10), new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(10, 10),
[0n, 1n, 2n, 3n, 4n, 5n] [0n, 1n, 2n, 3n, 4n, 5n],
) 'new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(10, 10) must return [0n, 1n, 2n, 3n, 4n, 5n]'
); );
assert( assert.compareArray(
compareArray(
new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(Infinity, Infinity), new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(Infinity, Infinity),
[1n, 2n, 3n, 4n, 5n] [1n, 2n, 3n, 4n, 5n],
), 'new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(Infinity, Infinity) must return [1n, 2n, 3n, 4n, 5n]'
'[1, 2, 3, 4, 5].copyWithin(Infinity, Infinity) -> [1, 2, 3, 4, 5]'
); );
}); });

View File

@ -18,33 +18,28 @@ info: |
includes: [compareArray.js, testBigIntTypedArray.js] includes: [compareArray.js, testBigIntTypedArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
assert( assert.compareArray(
compareArray(
new TA([1n, 2n, 3n, 4n, 5n, 6n]).copyWithin(0, 0), new TA([1n, 2n, 3n, 4n, 5n, 6n]).copyWithin(0, 0),
[1n, 2n, 3n, 4n, 5n, 6n] [1n, 2n, 3n, 4n, 5n, 6n],
) 'new TA([1n, 2n, 3n, 4n, 5n, 6n]).copyWithin(0, 0) must return [1n, 2n, 3n, 4n, 5n, 6n]'
); );
assert( assert.compareArray(
compareArray(
new TA([1n, 2n, 3n, 4n, 5n, 6n]).copyWithin(0, 2), new TA([1n, 2n, 3n, 4n, 5n, 6n]).copyWithin(0, 2),
[3n, 4n, 5n, 6n, 5n, 6n] [3n, 4n, 5n, 6n, 5n, 6n],
) 'new TA([1n, 2n, 3n, 4n, 5n, 6n]).copyWithin(0, 2) must return [3n, 4n, 5n, 6n, 5n, 6n]'
); );
assert( assert.compareArray(
compareArray(
new TA([1n, 2n, 3n, 4n, 5n, 6n]).copyWithin(3, 0), new TA([1n, 2n, 3n, 4n, 5n, 6n]).copyWithin(3, 0),
[1n, 2n, 3n, 1n, 2n, 3n] [1n, 2n, 3n, 1n, 2n, 3n],
) 'new TA([1n, 2n, 3n, 4n, 5n, 6n]).copyWithin(3, 0) must return [1n, 2n, 3n, 1n, 2n, 3n]'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(1, 4), new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(1, 4),
[0n, 4n, 5n, 3n, 4n, 5n] [0n, 4n, 5n, 3n, 4n, 5n],
) 'new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(1, 4) must return [0n, 4n, 5n, 3n, 4n, 5n]'
); );
}); });

View File

@ -20,28 +20,22 @@ features: [BigInt, TypedArray]
---*/ ---*/
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n]).copyWithin(0, 0, 0), new TA([0n, 1n, 2n, 3n]).copyWithin(0, 0, 0),
[0n, 1n, 2n, 3n] [0n, 1n, 2n, 3n],
), 'new TA([0n, 1n, 2n, 3n]).copyWithin(0, 0, 0) must return [0n, 1n, 2n, 3n]'
'[0, 1, 2, 3].copyWithin(0, 0, 0) -> [0, 1, 2, 3]'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n]).copyWithin(0, 0, 2), new TA([0n, 1n, 2n, 3n]).copyWithin(0, 0, 2),
[0n, 1n, 2n, 3n] [0n, 1n, 2n, 3n],
), 'new TA([0n, 1n, 2n, 3n]).copyWithin(0, 0, 2) must return [0n, 1n, 2n, 3n]'
'[0, 1, 2, 3].copyWithin(0, 0, 2) -> [0, 1, 2, 3]'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1, 2), new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1, 2),
[1n, 1n, 2n, 3n] [1n, 1n, 2n, 3n],
), 'new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1, 2) must return [1n, 1n, 2n, 3n]'
'[0, 1, 2, 3].copyWithin(0, 1, 2) -> [1, 1, 2, 3]'
); );
/* /*
@ -55,19 +49,15 @@ testWithBigIntTypedArrayConstructors(function(TA) {
* from = 0 + 2 - 1 * from = 0 + 2 - 1
* to = 1 + 2 - 1 * to = 1 + 2 - 1
*/ */
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, 2), new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, 2),
[0n, 0n, 1n, 3n] [0n, 0n, 1n, 3n],
), 'new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, 2) must return [0n, 0n, 1n, 3n]'
'[0, 1, 2, 3].copyWithin(1, 0, 2) -> [0, 0, 1, 3]'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(1, 3, 5), new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(1, 3, 5),
[0n, 3n, 4n, 3n, 4n, 5n] [0n, 3n, 4n, 3n, 4n, 5n],
), 'new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(1, 3, 5) must return [0n, 3n, 4n, 3n, 4n, 5n]'
'[0, 1, 2, 3, 4, 5].copyWithin(1, 3, 5) -> [0, 3, 4, 3, 4, 5]'
); );
}); });

View File

@ -25,21 +25,16 @@ info: |
includes: [compareArray.js, testBigIntTypedArray.js] includes: [compareArray.js, testBigIntTypedArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1, undefined), new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1, undefined),
[1n, 2n, 3n, 3n] [1n, 2n, 3n, 3n],
), 'new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1, undefined) must return [1n, 2n, 3n, 3n]'
'[0, 1, 2, 3].copyWithin(0, 1, undefined) -> [1, 2, 3]'
); );
assert( assert.compareArray(
compareArray(
new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1), new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1),
[1n, 2n, 3n, 3n] [1n, 2n, 3n, 3n],
), 'new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1) must return [1n, 2n, 3n, 3n]'
'[0, 1, 2, 3].copyWithin(0, 1) -> [1, 2, 3, 3]'
); );
}); });

View File

@ -38,7 +38,11 @@ function body(FloatArray) {
length length
); );
assert(compareArray(originalBytes, copiedBytes)); assert.compareArray(
originalBytes,
copiedBytes,
'The value of originalBytes is expected to equal the value of copiedBytes'
);
} }
testWithTypedArrayConstructors(body, [Float32Array, Float64Array]); testWithTypedArrayConstructors(body, [Float32Array, Float64Array]);

View File

@ -27,51 +27,45 @@ features: [TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3]).copyWithin(1, 0, null), new TA([0, 1, 2, 3]).copyWithin(1, 0, null),
[0, 1, 2, 3] [0, 1, 2, 3]
), ,
'null value coerced to 0' 'new TA([0, 1, 2, 3]).copyWithin(1, 0, null) must return [0, 1, 2, 3]'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3]).copyWithin(1, 0, NaN), new TA([0, 1, 2, 3]).copyWithin(1, 0, NaN),
[0, 1, 2, 3] [0, 1, 2, 3]
), ,
'NaN value coerced to 0' 'new TA([0, 1, 2, 3]).copyWithin(1, 0, NaN) must return [0, 1, 2, 3]'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3]).copyWithin(1, 0, false), new TA([0, 1, 2, 3]).copyWithin(1, 0, false),
[0, 1, 2, 3] [0, 1, 2, 3]
), ,
'false value coerced to 0' 'new TA([0, 1, 2, 3]).copyWithin(1, 0, false) must return [0, 1, 2, 3]'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3]).copyWithin(1, 0, true), new TA([0, 1, 2, 3]).copyWithin(1, 0, true),
[0, 0, 2, 3] [0, 0, 2, 3]
), ,
'true value coerced to 1' 'new TA([0, 1, 2, 3]).copyWithin(1, 0, true) must return [0, 0, 2, 3]'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3]).copyWithin(1, 0, '-2'), new TA([0, 1, 2, 3]).copyWithin(1, 0, '-2'),
[0, 0, 1, 3] [0, 0, 1, 3]
), ,
'string "-2" value coerced to integer -2' 'new TA([0, 1, 2, 3]).copyWithin(1, 0, "-2") must return [0, 0, 1, 3]'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3]).copyWithin(1, 0, -2.5), new TA([0, 1, 2, 3]).copyWithin(1, 0, -2.5),
[0, 0, 1, 3] [0, 0, 1, 3]
), ,
'float -2.5 value coerced to integer -2' 'new TA([0, 1, 2, 3]).copyWithin(1, 0, -2.5) must return [0, 0, 1, 3]'
); );
}); });

View File

@ -26,67 +26,51 @@ features: [TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3]).copyWithin(1, undefined), new TA([0, 1, 2, 3]).copyWithin(1, undefined),
[0, 0, 1, 2] [0, 0, 1, 2],
), 'new TA([0, 1, 2, 3]).copyWithin(1, undefined) must return [0, 0, 1, 2]'
'undefined value coerced to 0'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3]).copyWithin(1, false), new TA([0, 1, 2, 3]).copyWithin(1, false),
[0, 0, 1, 2] [0, 0, 1, 2],
), 'new TA([0, 1, 2, 3]).copyWithin(1, false) must return [0, 0, 1, 2]'
'false value coerced to 0'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3]).copyWithin(1, NaN), new TA([0, 1, 2, 3]).copyWithin(1, NaN),
[0, 0, 1, 2] [0, 0, 1, 2],
), 'new TA([0, 1, 2, 3]).copyWithin(1, NaN) must return [0, 0, 1, 2]'
'NaN value coerced to 0'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3]).copyWithin(1, null), new TA([0, 1, 2, 3]).copyWithin(1, null),
[0, 0, 1, 2] [0, 0, 1, 2],
), 'new TA([0, 1, 2, 3]).copyWithin(1, null) must return [0, 0, 1, 2]'
'null value coerced to 0'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3]).copyWithin(0, true), new TA([0, 1, 2, 3]).copyWithin(0, true),
[1, 2, 3, 3] [1, 2, 3, 3],
), 'new TA([0, 1, 2, 3]).copyWithin(0, true) must return [1, 2, 3, 3]'
'true value coerced to 1'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3]).copyWithin(0, '1'), new TA([0, 1, 2, 3]).copyWithin(0, '1'),
[1, 2, 3, 3] [1, 2, 3, 3],
), 'new TA([0, 1, 2, 3]).copyWithin(0, "1") must return [1, 2, 3, 3]'
'string "1" value coerced to 1'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3]).copyWithin(1, 0.5), new TA([0, 1, 2, 3]).copyWithin(1, 0.5),
[0, 0, 1, 2] [0, 0, 1, 2],
), 'new TA([0, 1, 2, 3]).copyWithin(1, 0.5) must return [0, 0, 1, 2]'
'0.5 float value coerced to integer 0'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3]).copyWithin(0, 1.5), new TA([0, 1, 2, 3]).copyWithin(0, 1.5),
[1, 2, 3, 3] [1, 2, 3, 3],
), 'new TA([0, 1, 2, 3]).copyWithin(0, 1.5) must return [1, 2, 3, 3]'
'1.5 float value coerced to integer 1'
); );
}); });

View File

@ -26,75 +26,57 @@ features: [TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3]).copyWithin(undefined, 1), new TA([0, 1, 2, 3]).copyWithin(undefined, 1),
[1, 2, 3, 3] [1, 2, 3, 3],
), 'new TA([0, 1, 2, 3]).copyWithin(undefined, 1) must return [1, 2, 3, 3]'
'undefined value coerced to 0'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3]).copyWithin(false, 1), new TA([0, 1, 2, 3]).copyWithin(false, 1),
[1, 2, 3, 3] [1, 2, 3, 3],
), 'new TA([0, 1, 2, 3]).copyWithin(false, 1) must return [1, 2, 3, 3]'
'false value coerced to 0'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3]).copyWithin(NaN, 1), new TA([0, 1, 2, 3]).copyWithin(NaN, 1),
[1, 2, 3, 3] [1, 2, 3, 3],
), 'new TA([0, 1, 2, 3]).copyWithin(NaN, 1) must return [1, 2, 3, 3]'
'NaN value coerced to 0'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3]).copyWithin(null, 1), new TA([0, 1, 2, 3]).copyWithin(null, 1),
[1, 2, 3, 3] [1, 2, 3, 3],
), 'new TA([0, 1, 2, 3]).copyWithin(null, 1) must return [1, 2, 3, 3]'
'null value coerced to 0'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3]).copyWithin(true, 0), new TA([0, 1, 2, 3]).copyWithin(true, 0),
[0, 0, 1, 2] [0, 0, 1, 2],
), 'new TA([0, 1, 2, 3]).copyWithin(true, 0) must return [0, 0, 1, 2]'
'true value coerced to 1'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3]).copyWithin('1', 0), new TA([0, 1, 2, 3]).copyWithin('1', 0),
[0, 0, 1, 2] [0, 0, 1, 2],
), 'new TA([0, 1, 2, 3]).copyWithin("1", 0) must return [0, 0, 1, 2]'
'string "1" value coerced to 1'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3]).copyWithin(0.5, 1), new TA([0, 1, 2, 3]).copyWithin(0.5, 1),
[1, 2, 3, 3] [1, 2, 3, 3],
), 'new TA([0, 1, 2, 3]).copyWithin(0.5, 1) must return [1, 2, 3, 3]'
'0.5 float value coerced to integer 0'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3]).copyWithin(1.5, 0), new TA([0, 1, 2, 3]).copyWithin(1.5, 0),
[0, 0, 1, 2] [0, 0, 1, 2],
), 'new TA([0, 1, 2, 3]).copyWithin(1.5, 0) must return [0, 0, 1, 2]'
'1.5 float value coerced to integer 1'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3]).copyWithin({}, 1), new TA([0, 1, 2, 3]).copyWithin({}, 1),
[1, 2, 3, 3] [1, 2, 3, 3],
), 'new TA([0, 1, 2, 3]).copyWithin({}, 1) must return [1, 2, 3, 3]'
'object value coerced to integer 0'
); );
}); });

View File

@ -29,67 +29,51 @@ features: [TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3]).copyWithin(0, 1, -1), new TA([0, 1, 2, 3]).copyWithin(0, 1, -1),
[1, 2, 2, 3] [1, 2, 2, 3],
), 'new TA([0, 1, 2, 3]).copyWithin(0, 1, -1) must return [1, 2, 2, 3]'
'[0, 1, 2, 3].copyWithin(0, 1, -1) -> [1, 2, 2, 3]'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3, 4]).copyWithin(2, 0, -1), new TA([0, 1, 2, 3, 4]).copyWithin(2, 0, -1),
[0, 1, 0, 1, 2] [0, 1, 0, 1, 2],
), 'new TA([0, 1, 2, 3, 4]).copyWithin(2, 0, -1) must return [0, 1, 0, 1, 2]'
'[0, 1, 2, 3, 4].copyWithin(2, 0, -1) -> [0, 1, 0, 1, 2]'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3, 4]).copyWithin(1, 2, -2), new TA([0, 1, 2, 3, 4]).copyWithin(1, 2, -2),
[0, 2, 2, 3, 4] [0, 2, 2, 3, 4],
), 'new TA([0, 1, 2, 3, 4]).copyWithin(1, 2, -2) must return [0, 2, 2, 3, 4]'
'[0, 1, 2, 3, 4].copyWithin(1, 2, -2) -> [0, 2, 2, 3, 4]'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3]).copyWithin(0, -2, -1), new TA([0, 1, 2, 3]).copyWithin(0, -2, -1),
[2, 1, 2, 3] [2, 1, 2, 3],
), 'new TA([0, 1, 2, 3]).copyWithin(0, -2, -1) must return [2, 1, 2, 3]'
'[0, 1, 2, 3].copyWithin(0, -2, -1) -> [2, 1, 2, 3]'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3, 4]).copyWithin(2, -2, -1), new TA([0, 1, 2, 3, 4]).copyWithin(2, -2, -1),
[0, 1, 3, 3, 4] [0, 1, 3, 3, 4],
), 'new TA([0, 1, 2, 3, 4]).copyWithin(2, -2, -1) must return [0, 1, 3, 3, 4]'
'[0, 1, 2, 3, 4].copyWithin(2, -2, 1) -> [0, 1, 3, 3, 4]'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3]).copyWithin(-3, -2, -1), new TA([0, 1, 2, 3]).copyWithin(-3, -2, -1),
[0, 2, 2, 3] [0, 2, 2, 3],
), 'new TA([0, 1, 2, 3]).copyWithin(-3, -2, -1) must return [0, 2, 2, 3]'
'[0, 1, 2, 3].copyWithin(-3, -2, -1) -> [0, 2, 2, 3]'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3, 4]).copyWithin(-2, -3, -1), new TA([0, 1, 2, 3, 4]).copyWithin(-2, -3, -1),
[0, 1, 2, 2, 3] [0, 1, 2, 2, 3],
), 'new TA([0, 1, 2, 3, 4]).copyWithin(-2, -3, -1) must return [0, 1, 2, 2, 3]'
'[0, 1, 2, 3, 4].copyWithin(-2, -3, -1) -> [0, 1, 2, 2, 3]'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3, 4]).copyWithin(-5, -2, -1), new TA([0, 1, 2, 3, 4]).copyWithin(-5, -2, -1),
[3, 1, 2, 3, 4] [3, 1, 2, 3, 4],
), 'new TA([0, 1, 2, 3, 4]).copyWithin(-5, -2, -1) must return [3, 1, 2, 3, 4]'
'[0, 1, 2, 3, 4].copyWithin(-5, -2, -1) -> [3, 1, 2, 3, 4]'
); );
}); });

View File

@ -29,83 +29,63 @@ features: [TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3]).copyWithin(0, 1, -10), new TA([0, 1, 2, 3]).copyWithin(0, 1, -10),
[0, 1, 2, 3] [0, 1, 2, 3],
), 'new TA([0, 1, 2, 3]).copyWithin(0, 1, -10) must return [0, 1, 2, 3]'
'[0, 1, 2, 3].copyWithin(0, 1, -10) -> [0, 1, 2, 3]'
); );
assert( assert.compareArray(
compareArray(
new TA([1, 2, 3, 4, 5]).copyWithin(0, 1, -Infinity), new TA([1, 2, 3, 4, 5]).copyWithin(0, 1, -Infinity),
[1, 2, 3, 4, 5] [1, 2, 3, 4, 5],
), 'new TA([1, 2, 3, 4, 5]).copyWithin(0, 1, -Infinity) must return [1, 2, 3, 4, 5]'
'[1, 2, 3, 4, 5].copyWithin(0, 1, -Infinity) -> [1, 2, 3, 4, 5]'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3]).copyWithin(0, -2, -10), new TA([0, 1, 2, 3]).copyWithin(0, -2, -10),
[0, 1, 2, 3] [0, 1, 2, 3],
), 'new TA([0, 1, 2, 3]).copyWithin(0, -2, -10) must return [0, 1, 2, 3]'
'[0, 1, 2, 3].copyWithin(0, -2, -10) -> [0, 1, 2, 3]'
); );
assert( assert.compareArray(
compareArray(
new TA([1, 2, 3, 4, 5]).copyWithin(0, -2, -Infinity), new TA([1, 2, 3, 4, 5]).copyWithin(0, -2, -Infinity),
[1, 2, 3, 4, 5] [1, 2, 3, 4, 5],
), 'new TA([1, 2, 3, 4, 5]).copyWithin(0, -2, -Infinity) must return [1, 2, 3, 4, 5]'
'[1, 2, 3, 4, 5].copyWithin(0, -2, -Infinity) -> [1, 2, 3, 4, 5]'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3]).copyWithin(0, -9, -10), new TA([0, 1, 2, 3]).copyWithin(0, -9, -10),
[0, 1, 2, 3] [0, 1, 2, 3],
), 'new TA([0, 1, 2, 3]).copyWithin(0, -9, -10) must return [0, 1, 2, 3]'
'[0, 1, 2, 3].copyWithin(0, -9, -10) -> [0, 1, 2, 3]'
); );
assert( assert.compareArray(
compareArray(
new TA([1, 2, 3, 4, 5]).copyWithin(0, -9, -Infinity), new TA([1, 2, 3, 4, 5]).copyWithin(0, -9, -Infinity),
[1, 2, 3, 4, 5] [1, 2, 3, 4, 5],
), 'new TA([1, 2, 3, 4, 5]).copyWithin(0, -9, -Infinity) must return [1, 2, 3, 4, 5]'
'[1, 2, 3, 4, 5].copyWithin(0, -9, -Infinity) -> [1, 2, 3, 4, 5]'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3]).copyWithin(-3, -2, -10), new TA([0, 1, 2, 3]).copyWithin(-3, -2, -10),
[0, 1, 2, 3] [0, 1, 2, 3],
), 'new TA([0, 1, 2, 3]).copyWithin(-3, -2, -10) must return [0, 1, 2, 3]'
'[0, 1, 2, 3].copyWithin(-3, -2, -10) -> [0, 1, 2, 3]'
); );
assert( assert.compareArray(
compareArray(
new TA([1, 2, 3, 4, 5]).copyWithin(-3, -2, -Infinity), new TA([1, 2, 3, 4, 5]).copyWithin(-3, -2, -Infinity),
[1, 2, 3, 4, 5] [1, 2, 3, 4, 5],
), 'new TA([1, 2, 3, 4, 5]).copyWithin(-3, -2, -Infinity) must return [1, 2, 3, 4, 5]'
'[1, 2, 3, 4, 5].copyWithin(-3, -2, -Infinity) -> [1, 2, 3, 4, 5]'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3]).copyWithin(-7, -8, -9), new TA([0, 1, 2, 3]).copyWithin(-7, -8, -9),
[0, 1, 2, 3] [0, 1, 2, 3],
), 'new TA([0, 1, 2, 3]).copyWithin(-7, -8, -9) must return [0, 1, 2, 3]'
'[0, 1, 2, 3].copyWithin(-7, -8, -9) -> [0, 1, 2, 3]'
); );
assert( assert.compareArray(
compareArray(
new TA([1, 2, 3, 4, 5]).copyWithin(-7, -8, -Infinity), new TA([1, 2, 3, 4, 5]).copyWithin(-7, -8, -Infinity),
[1, 2, 3, 4, 5] [1, 2, 3, 4, 5],
), 'new TA([1, 2, 3, 4, 5]).copyWithin(-7, -8, -Infinity) must return [1, 2, 3, 4, 5]'
'[1, 2, 3, 4, 5].copyWithin(-7, -8, -Infinity) -> [1, 2, 3, 4, 5]'
); );
}); });

View File

@ -27,67 +27,51 @@ features: [TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3]).copyWithin(0, -10), new TA([0, 1, 2, 3]).copyWithin(0, -10),
[0, 1, 2, 3] [0, 1, 2, 3],
), 'new TA([0, 1, 2, 3]).copyWithin(0, -10) must return [0, 1, 2, 3]'
'[0, 1, 2, 3]).copyWithin(0, -10) -> [0, 1, 2, 3]'
); );
assert( assert.compareArray(
compareArray(
new TA([1, 2, 3, 4, 5]).copyWithin(0, -Infinity), new TA([1, 2, 3, 4, 5]).copyWithin(0, -Infinity),
[1, 2, 3, 4, 5] [1, 2, 3, 4, 5],
), 'new TA([1, 2, 3, 4, 5]).copyWithin(0, -Infinity) must return [1, 2, 3, 4, 5]'
'[1, 2, 3, 4, 5]).copyWithin(0, -Infinity) -> [1, 2, 3, 4, 5]'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3, 4]).copyWithin(2, -10), new TA([0, 1, 2, 3, 4]).copyWithin(2, -10),
[0, 1, 0, 1, 2] [0, 1, 0, 1, 2],
), 'new TA([0, 1, 2, 3, 4]).copyWithin(2, -10) must return [0, 1, 0, 1, 2]'
'[0, 1, 2, 3, 4]).copyWithin(2, -2) -> [0, 1, 0, 1, 2]'
); );
assert( assert.compareArray(
compareArray(
new TA([1, 2, 3, 4, 5]).copyWithin(2, -Infinity), new TA([1, 2, 3, 4, 5]).copyWithin(2, -Infinity),
[1, 2, 1, 2, 3] [1, 2, 1, 2, 3],
), 'new TA([1, 2, 3, 4, 5]).copyWithin(2, -Infinity) must return [1, 2, 1, 2, 3]'
'[1, 2, 3, 4, 5]).copyWithin(2, -Infinity) -> [1, 2, 1, 2, 3]'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3, 4]).copyWithin(10, -10), new TA([0, 1, 2, 3, 4]).copyWithin(10, -10),
[0, 1, 2, 3, 4] [0, 1, 2, 3, 4],
), 'new TA([0, 1, 2, 3, 4]).copyWithin(10, -10) must return [0, 1, 2, 3, 4]'
'[0, 1, 2, 3, 4]).copyWithin(10, -10) -> [0, 1, 2, 3, 4]'
); );
assert( assert.compareArray(
compareArray(
new TA([1, 2, 3, 4, 5]).copyWithin(10, -Infinity), new TA([1, 2, 3, 4, 5]).copyWithin(10, -Infinity),
[1, 2, 3, 4, 5] [1, 2, 3, 4, 5],
), 'new TA([1, 2, 3, 4, 5]).copyWithin(10, -Infinity) must return [1, 2, 3, 4, 5]'
'[1, 2, 3, 4, 5]).copyWithin(10, -Infinity) -> [1, 2, 3, 4, 5]'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3]).copyWithin(-9, -10), new TA([0, 1, 2, 3]).copyWithin(-9, -10),
[0, 1, 2, 3] [0, 1, 2, 3],
), 'new TA([0, 1, 2, 3]).copyWithin(-9, -10) must return [0, 1, 2, 3]'
'[0, 1, 2, 3].copyWithin(-9, -10) -> [0, 1, 2, 3]'
); );
assert( assert.compareArray(
compareArray(
new TA([1, 2, 3, 4, 5]).copyWithin(-9, -Infinity), new TA([1, 2, 3, 4, 5]).copyWithin(-9, -Infinity),
[1, 2, 3, 4, 5] [1, 2, 3, 4, 5],
), 'new TA([1, 2, 3, 4, 5]).copyWithin(-9, -Infinity) must return [1, 2, 3, 4, 5]'
'[1, 2, 3, 4, 5].copyWithin(-9, -Infinity) -> [1, 2, 3, 4, 5]'
); );
}); });

View File

@ -27,35 +27,27 @@ features: [TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3]).copyWithin(-10, 0), new TA([0, 1, 2, 3]).copyWithin(-10, 0),
[0, 1, 2, 3] [0, 1, 2, 3],
), 'new TA([0, 1, 2, 3]).copyWithin(-10, 0) must return [0, 1, 2, 3]'
'[0, 1, 2, 3].copyWithin(-10, 0) -> [0, 1, 2, 3]'
); );
assert( assert.compareArray(
compareArray(
new TA([1, 2, 3, 4, 5]).copyWithin(-Infinity, 0), new TA([1, 2, 3, 4, 5]).copyWithin(-Infinity, 0),
[1, 2, 3, 4, 5] [1, 2, 3, 4, 5],
), 'new TA([1, 2, 3, 4, 5]).copyWithin(-Infinity, 0) must return [1, 2, 3, 4, 5]'
'[1, 2, 3, 4, 5].copyWithin(-Infinity, 0) -> [1, 2, 3, 4, 5]'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3, 4]).copyWithin(-10, 2), new TA([0, 1, 2, 3, 4]).copyWithin(-10, 2),
[2, 3, 4, 3, 4] [2, 3, 4, 3, 4],
), 'new TA([0, 1, 2, 3, 4]).copyWithin(-10, 2) must return [2, 3, 4, 3, 4]'
'[0, 1, 2, 3, 4].copyWithin(-10, 2) -> [2, 3, 4, 3, 4]'
); );
assert( assert.compareArray(
compareArray(
new TA([1, 2, 3, 4, 5]).copyWithin(-Infinity, 2), new TA([1, 2, 3, 4, 5]).copyWithin(-Infinity, 2),
[3, 4, 5, 4, 5] [3, 4, 5, 4, 5],
), 'new TA([1, 2, 3, 4, 5]).copyWithin(-Infinity, 2) must return [3, 4, 5, 4, 5]'
'[1, 2, 3, 4, 5].copyWithin(-Infinity, 2) -> [3, 4, 5, 4, 5]'
); );
}); });

View File

@ -27,51 +27,39 @@ features: [TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3]).copyWithin(0, -1), new TA([0, 1, 2, 3]).copyWithin(0, -1),
[3, 1, 2, 3] [3, 1, 2, 3],
), 'new TA([0, 1, 2, 3]).copyWithin(0, -1) must return [3, 1, 2, 3]'
'[0, 1, 2, 3].copyWithin(0, -1) -> [3, 1, 2, 3]'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3, 4]).copyWithin(2, -2), new TA([0, 1, 2, 3, 4]).copyWithin(2, -2),
[0, 1, 3, 4, 4] [0, 1, 3, 4, 4],
), 'new TA([0, 1, 2, 3, 4]).copyWithin(2, -2) must return [0, 1, 3, 4, 4]'
'[0, 1, 2, 3, 4].copyWithin(2, -2) -> [0, 1, 3, 4, 4]'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3, 4]).copyWithin(1, -2), new TA([0, 1, 2, 3, 4]).copyWithin(1, -2),
[0, 3, 4, 3, 4] [0, 3, 4, 3, 4],
), 'new TA([0, 1, 2, 3, 4]).copyWithin(1, -2) must return [0, 3, 4, 3, 4]'
'[0, 1, 2, 3, 4].copyWithin(1, -2) -> [0, 3, 4, 3, 4]'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3]).copyWithin(-1, -2), new TA([0, 1, 2, 3]).copyWithin(-1, -2),
[0, 1, 2, 2] [0, 1, 2, 2],
), 'new TA([0, 1, 2, 3]).copyWithin(-1, -2) must return [0, 1, 2, 2]'
'[0, 1, 2, 3].copyWithin(-1, -2) -> [ 0, 1, 2, 2 ]'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3, 4]).copyWithin(-2, -3), new TA([0, 1, 2, 3, 4]).copyWithin(-2, -3),
[0, 1, 2, 2, 3] [0, 1, 2, 2, 3],
), 'new TA([0, 1, 2, 3, 4]).copyWithin(-2, -3) must return [0, 1, 2, 2, 3]'
'[0, 1, 2, 3, 4].copyWithin(-2, -3) -> [0, 1, 2, 2, 3]'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3, 4]).copyWithin(-5, -2), new TA([0, 1, 2, 3, 4]).copyWithin(-5, -2),
[3, 4, 2, 3, 4] [3, 4, 2, 3, 4],
), 'new TA([0, 1, 2, 3, 4]).copyWithin(-5, -2) must return [3, 4, 2, 3, 4]'
'[0, 1, 2, 3, 4].copyWithin(-5, -2) -> [3, 4, 2, 3, 4]'
); );
}); });

View File

@ -27,27 +27,21 @@ features: [TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3]).copyWithin(-1, 0), new TA([0, 1, 2, 3]).copyWithin(-1, 0),
[0, 1, 2, 0] [0, 1, 2, 0],
), 'new TA([0, 1, 2, 3]).copyWithin(-1, 0) must return [0, 1, 2, 0]'
'[0, 1, 2, 3].copyWithin(-1, 0) -> [0, 1, 2, 0]'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3, 4]).copyWithin(-2, 2), new TA([0, 1, 2, 3, 4]).copyWithin(-2, 2),
[0, 1, 2, 2, 3] [0, 1, 2, 2, 3],
), 'new TA([0, 1, 2, 3, 4]).copyWithin(-2, 2) must return [0, 1, 2, 2, 3]'
'[0, 1, 2, 3, 4].copyWithin(-2, 2) -> [0, 1, 2, 2, 3]'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3]).copyWithin(-1, 2), new TA([0, 1, 2, 3]).copyWithin(-1, 2),
[0, 1, 2, 2] [0, 1, 2, 2],
), 'new TA([0, 1, 2, 3]).copyWithin(-1, 2) must return [0, 1, 2, 2]'
'[0, 1, 2, 3].copyWithin(-1, 2) -> [0, 1, 2, 2]'
); );
}); });

View File

@ -20,35 +20,27 @@ features: [TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3]).copyWithin(0, 1, 6), new TA([0, 1, 2, 3]).copyWithin(0, 1, 6),
[1, 2, 3, 3] [1, 2, 3, 3],
), 'new TA([0, 1, 2, 3]).copyWithin(0, 1, 6) must return [1, 2, 3, 3]'
'[0, 1, 2, 3].copyWithin(0, 1, 6) -> [1, 2, 3, 3]'
); );
assert( assert.compareArray(
compareArray(
new TA([1, 2, 3, 4, 5]).copyWithin(0, 1, Infinity), new TA([1, 2, 3, 4, 5]).copyWithin(0, 1, Infinity),
[2, 3, 4, 5, 5] [2, 3, 4, 5, 5],
), 'new TA([1, 2, 3, 4, 5]).copyWithin(0, 1, Infinity) must return [2, 3, 4, 5, 5]'
'[1, 2, 3, 4, 5].copyWithin(0, 1, Infinity) -> [2, 3, 4, 5, 5]'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3, 4, 5]).copyWithin(1, 3, 6), new TA([0, 1, 2, 3, 4, 5]).copyWithin(1, 3, 6),
[0, 3, 4, 5, 4, 5] [0, 3, 4, 5, 4, 5],
), 'new TA([0, 1, 2, 3, 4, 5]).copyWithin(1, 3, 6) must return [0, 3, 4, 5, 4, 5]'
'[0, 1, 2, 3, 4, 5].copyWithin(1, 3, 6) -> [0, 3, 4, 5, 4, 5]'
); );
assert( assert.compareArray(
compareArray(
new TA([1, 2, 3, 4, 5]).copyWithin(1, 3, Infinity), new TA([1, 2, 3, 4, 5]).copyWithin(1, 3, Infinity),
[1, 4, 5, 4, 5] [1, 4, 5, 4, 5],
), 'new TA([1, 2, 3, 4, 5]).copyWithin(1, 3, Infinity) must return [1, 4, 5, 4, 5]'
'[1, 2, 3, 4, 5].copyWithin(1, 3, Infinity) -> [1, 4, 5, 4, 5]'
); );
}); });

View File

@ -20,55 +20,45 @@ features: [TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3, 4, 5]).copyWithin(6, 0), new TA([0, 1, 2, 3, 4, 5]).copyWithin(6, 0),
[0, 1, 2, 3, 4, 5] [0, 1, 2, 3, 4, 5],
) 'new TA([0, 1, 2, 3, 4, 5]).copyWithin(6, 0) must return [0, 1, 2, 3, 4, 5]'
); );
assert( assert.compareArray(
compareArray(
new TA([1, 2, 3, 4, 5]).copyWithin(Infinity, 0), new TA([1, 2, 3, 4, 5]).copyWithin(Infinity, 0),
[1, 2, 3, 4, 5] [1, 2, 3, 4, 5],
), 'new TA([1, 2, 3, 4, 5]).copyWithin(Infinity, 0) must return [1, 2, 3, 4, 5]'
'[1, 2, 3, 4, 5].copyWithin(Infinity, 0) -> [1, 2, 3, 4, 5]'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3, 4, 5]).copyWithin(0, 6), new TA([0, 1, 2, 3, 4, 5]).copyWithin(0, 6),
[0, 1, 2, 3, 4, 5] [0, 1, 2, 3, 4, 5],
) 'new TA([0, 1, 2, 3, 4, 5]).copyWithin(0, 6) must return [0, 1, 2, 3, 4, 5]'
); );
assert( assert.compareArray(
compareArray(
new TA([1, 2, 3, 4, 5]).copyWithin(0, Infinity), new TA([1, 2, 3, 4, 5]).copyWithin(0, Infinity),
[1, 2, 3, 4, 5] [1, 2, 3, 4, 5],
), 'new TA([1, 2, 3, 4, 5]).copyWithin(0, Infinity) must return [1, 2, 3, 4, 5]'
'[1, 2, 3, 4, 5].copyWithin(0, Infinity) -> [1, 2, 3, 4, 5]'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3, 4, 5]).copyWithin(6, 6), new TA([0, 1, 2, 3, 4, 5]).copyWithin(6, 6),
[0, 1, 2, 3, 4, 5] [0, 1, 2, 3, 4, 5],
) 'new TA([0, 1, 2, 3, 4, 5]).copyWithin(6, 6) must return [0, 1, 2, 3, 4, 5]'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3, 4, 5]).copyWithin(10, 10), new TA([0, 1, 2, 3, 4, 5]).copyWithin(10, 10),
[0, 1, 2, 3, 4, 5] [0, 1, 2, 3, 4, 5],
) 'new TA([0, 1, 2, 3, 4, 5]).copyWithin(10, 10) must return [0, 1, 2, 3, 4, 5]'
); );
assert( assert.compareArray(
compareArray(
new TA([1, 2, 3, 4, 5]).copyWithin(Infinity, Infinity), new TA([1, 2, 3, 4, 5]).copyWithin(Infinity, Infinity),
[1, 2, 3, 4, 5] [1, 2, 3, 4, 5],
), 'new TA([1, 2, 3, 4, 5]).copyWithin(Infinity, Infinity) must return [1, 2, 3, 4, 5]'
'[1, 2, 3, 4, 5].copyWithin(Infinity, Infinity) -> [1, 2, 3, 4, 5]'
); );
}); });

View File

@ -20,31 +20,27 @@ features: [TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
assert( assert.compareArray(
compareArray(
new TA([1, 2, 3, 4, 5, 6]).copyWithin(0, 0), new TA([1, 2, 3, 4, 5, 6]).copyWithin(0, 0),
[1, 2, 3, 4, 5, 6] [1, 2, 3, 4, 5, 6],
) 'new TA([1, 2, 3, 4, 5, 6]).copyWithin(0, 0) must return [1, 2, 3, 4, 5, 6]'
); );
assert( assert.compareArray(
compareArray(
new TA([1, 2, 3, 4, 5, 6]).copyWithin(0, 2), new TA([1, 2, 3, 4, 5, 6]).copyWithin(0, 2),
[3, 4, 5, 6, 5, 6] [3, 4, 5, 6, 5, 6],
) 'new TA([1, 2, 3, 4, 5, 6]).copyWithin(0, 2) must return [3, 4, 5, 6, 5, 6]'
); );
assert( assert.compareArray(
compareArray(
new TA([1, 2, 3, 4, 5, 6]).copyWithin(3, 0), new TA([1, 2, 3, 4, 5, 6]).copyWithin(3, 0),
[1, 2, 3, 1, 2, 3] [1, 2, 3, 1, 2, 3],
) 'new TA([1, 2, 3, 4, 5, 6]).copyWithin(3, 0) must return [1, 2, 3, 1, 2, 3]'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3, 4, 5]).copyWithin(1, 4), new TA([0, 1, 2, 3, 4, 5]).copyWithin(1, 4),
[0, 4, 5, 3, 4, 5] [0, 4, 5, 3, 4, 5],
) 'new TA([0, 1, 2, 3, 4, 5]).copyWithin(1, 4) must return [0, 4, 5, 3, 4, 5]'
); );
}); });

View File

@ -20,28 +20,22 @@ features: [TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3]).copyWithin(0, 0, 0), new TA([0, 1, 2, 3]).copyWithin(0, 0, 0),
[0, 1, 2, 3] [0, 1, 2, 3],
), 'new TA([0, 1, 2, 3]).copyWithin(0, 0, 0) must return [0, 1, 2, 3]'
'[0, 1, 2, 3].copyWithin(0, 0, 0) -> [0, 1, 2, 3]'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3]).copyWithin(0, 0, 2), new TA([0, 1, 2, 3]).copyWithin(0, 0, 2),
[0, 1, 2, 3] [0, 1, 2, 3],
), 'new TA([0, 1, 2, 3]).copyWithin(0, 0, 2) must return [0, 1, 2, 3]'
'[0, 1, 2, 3].copyWithin(0, 0, 2) -> [0, 1, 2, 3]'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3]).copyWithin(0, 1, 2), new TA([0, 1, 2, 3]).copyWithin(0, 1, 2),
[1, 1, 2, 3] [1, 1, 2, 3],
), 'new TA([0, 1, 2, 3]).copyWithin(0, 1, 2) must return [1, 1, 2, 3]'
'[0, 1, 2, 3].copyWithin(0, 1, 2) -> [1, 1, 2, 3]'
); );
/* /*
@ -55,19 +49,15 @@ testWithTypedArrayConstructors(function(TA) {
* from = 0 + 2 - 1 * from = 0 + 2 - 1
* to = 1 + 2 - 1 * to = 1 + 2 - 1
*/ */
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3]).copyWithin(1, 0, 2), new TA([0, 1, 2, 3]).copyWithin(1, 0, 2),
[0, 0, 1, 3] [0, 0, 1, 3],
), 'new TA([0, 1, 2, 3]).copyWithin(1, 0, 2) must return [0, 0, 1, 3]'
'[0, 1, 2, 3].copyWithin(1, 0, 2) -> [0, 0, 1, 3]'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3, 4, 5]).copyWithin(1, 3, 5), new TA([0, 1, 2, 3, 4, 5]).copyWithin(1, 3, 5),
[0, 3, 4, 3, 4, 5] [0, 3, 4, 3, 4, 5],
), 'new TA([0, 1, 2, 3, 4, 5]).copyWithin(1, 3, 5) must return [0, 3, 4, 3, 4, 5]'
'[0, 1, 2, 3, 4, 5].copyWithin(1, 3, 5) -> [0, 3, 4, 3, 4, 5]'
); );
}); });

View File

@ -27,19 +27,15 @@ features: [TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3]).copyWithin(0, 1, undefined), new TA([0, 1, 2, 3]).copyWithin(0, 1, undefined),
[1, 2, 3, 3] [1, 2, 3, 3],
), 'new TA([0, 1, 2, 3]).copyWithin(0, 1, undefined) must return [1, 2, 3, 3]'
'[0, 1, 2, 3].copyWithin(0, 1, undefined) -> [1, 2, 3]'
); );
assert( assert.compareArray(
compareArray(
new TA([0, 1, 2, 3]).copyWithin(0, 1), new TA([0, 1, 2, 3]).copyWithin(0, 1),
[1, 2, 3, 3] [1, 2, 3, 3],
), 'new TA([0, 1, 2, 3]).copyWithin(0, 1) must return [1, 2, 3, 3]'
'[0, 1, 2, 3].copyWithin(0, 1) -> [1, 2, 3, 3]'
); );
}); });

View File

@ -11,24 +11,19 @@ info: |
includes: [testBigIntTypedArray.js, compareArray.js] includes: [testBigIntTypedArray.js, compareArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var typedArray = new TA([0n, 42n, 64n]); var typedArray = new TA([0n, 42n, 64n]);
var itor = typedArray.entries(); var itor = typedArray.entries();
var next = itor.next(); var next = itor.next();
assert(compareArray(next.value, [0, 0n])); assert.compareArray(next.value, [0, 0n], 'The value of next.value is expected to be [0, 0n]');
assert.sameValue(next.done, false); assert.sameValue(next.done, false, 'The value of next.done is expected to be false');
next = itor.next(); next = itor.next();
assert(compareArray(next.value, [1, 42n])); assert.compareArray(next.value, [1, 42n], 'The value of next.value is expected to be [1, 42n]');
assert.sameValue(next.done, false); assert.sameValue(next.done, false, 'The value of next.done is expected to be false');
next = itor.next(); next = itor.next();
assert(compareArray(next.value, [2, 64n])); assert.compareArray(next.value, [2, 64n], 'The value of next.value is expected to be [2, 64n]');
assert.sameValue(next.done, false); assert.sameValue(next.done, false, 'The value of next.done is expected to be false');
next = itor.next(); next = itor.next();
assert.sameValue(next.value, undefined); assert.sameValue(next.value, undefined, 'The value of next.value is expected to equal undefined');
assert.sameValue(next.done, true); assert.sameValue(next.done, true, 'The value of next.done is expected to be true');
}); });

View File

@ -19,18 +19,18 @@ testWithTypedArrayConstructors(function(TA) {
var itor = typedArray.entries(); var itor = typedArray.entries();
var next = itor.next(); var next = itor.next();
assert(compareArray(next.value, [0, 0])); assert.compareArray(next.value, [0, 0], 'The value of next.value is expected to be [0, 0]');
assert.sameValue(next.done, false); assert.sameValue(next.done, false, 'The value of next.done is expected to be false');
next = itor.next(); next = itor.next();
assert(compareArray(next.value, [1, 42])); assert.compareArray(next.value, [1, 42], 'The value of next.value is expected to be [1, 42]');
assert.sameValue(next.done, false); assert.sameValue(next.done, false, 'The value of next.done is expected to be false');
next = itor.next(); next = itor.next();
assert(compareArray(next.value, [2, 64])); assert.compareArray(next.value, [2, 64], 'The value of next.value is expected to be [2, 64]');
assert.sameValue(next.done, false); assert.sameValue(next.done, false, 'The value of next.done is expected to be false');
next = itor.next(); next = itor.next();
assert.sameValue(next.value, undefined); assert.sameValue(next.value, undefined, 'The value of next.value is expected to equal undefined');
assert.sameValue(next.done, true); assert.sameValue(next.done, true, 'The value of next.done is expected to be true');
}); });

View File

@ -30,75 +30,64 @@ info: |
includes: [compareArray.js, testBigIntTypedArray.js] includes: [compareArray.js, testBigIntTypedArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
assert( assert.compareArray(
compareArray(new TA([0n, 0n]).fill(1n, undefined), [1n, 1n]), new TA([0n, 0n]).fill(1n, undefined),
'`undefined` start coerced to 0' [1n, 1n],
'new TA([0n, 0n]).fill(1n, undefined) must return [1n, 1n]'
); );
assert( assert.compareArray(
compareArray(new TA([0n, 0n]).fill(1n, 0, undefined), [1n, 1n]), new TA([0n, 0n]).fill(1n, 0, undefined),
'If end is undefined, let relativeEnd be len' [1n, 1n],
'new TA([0n, 0n]).fill(1n, 0, undefined) must return [1n, 1n]'
); );
assert( assert.compareArray(new TA([0n, 0n]).fill(1n, null), [1n, 1n], 'new TA([0n, 0n]).fill(1n, null) must return [1n, 1n]');
compareArray(new TA([0n, 0n]).fill(1n, null), [1n, 1n]),
'`null` start coerced to 0' assert.compareArray(
new TA([0n, 0n]).fill(1n, 0, null),
[0n, 0n],
'new TA([0n, 0n]).fill(1n, 0, null) must return [0n, 0n]'
); );
assert( assert.compareArray(new TA([0n, 0n]).fill(1n, true), [0n, 1n], 'new TA([0n, 0n]).fill(1n, true) must return [0n, 1n]');
compareArray(new TA([0n, 0n]).fill(1n, 0, null), [0n, 0n]),
'`null` end coerced to 0' assert.compareArray(
new TA([0n, 0n]).fill(1n, 0, true),
[1n, 0n],
'new TA([0n, 0n]).fill(1n, 0, true) must return [1n, 0n]'
); );
assert( assert.compareArray(new TA([0n, 0n]).fill(1n, false), [1n, 1n], 'new TA([0n, 0n]).fill(1n, false) must return [1n, 1n]');
compareArray(new TA([0n, 0n]).fill(1n, true), [0n, 1n]),
'`true` start coerced to 1' assert.compareArray(
new TA([0n, 0n]).fill(1n, 0, false),
[0n, 0n],
'new TA([0n, 0n]).fill(1n, 0, false) must return [0n, 0n]'
); );
assert( assert.compareArray(new TA([0n, 0n]).fill(1n, NaN), [1n, 1n], 'new TA([0n, 0n]).fill(1n, NaN) must return [1n, 1n]');
compareArray(new TA([0n, 0n]).fill(1n, 0, true), [1n, 0n]),
'`true` end coerced to 1' assert.compareArray(
new TA([0n, 0n]).fill(1n, 0, NaN),
[0n, 0n],
'new TA([0n, 0n]).fill(1n, 0, NaN) must return [0n, 0n]'
); );
assert( assert.compareArray(new TA([0n, 0n]).fill(1n, '1'), [0n, 1n], 'new TA([0n, 0n]).fill(1n, "1") must return [0n, 1n]');
compareArray(new TA([0n, 0n]).fill(1n, false), [1n, 1n]),
'`false` start coerced to 0' assert.compareArray(
new TA([0n, 0n]).fill(1n, 0, '1'),
[1n, 0n],
'new TA([0n, 0n]).fill(1n, 0, "1") must return [1n, 0n]'
); );
assert( assert.compareArray(new TA([0n, 0n]).fill(1n, 1.5), [0n, 1n], 'new TA([0n, 0n]).fill(1n, 1.5) must return [0n, 1n]');
compareArray(new TA([0n, 0n]).fill(1n, 0, false), [0n, 0n]),
'`false` end coerced to 0'
);
assert( assert.compareArray(
compareArray(new TA([0n, 0n]).fill(1n, NaN), [1n, 1n]), new TA([0n, 0n]).fill(1n, 0, 1.5),
'`NaN` start coerced to 0' [1n, 0n],
); 'new TA([0n, 0n]).fill(1n, 0, 1.5) must return [1n, 0n]'
assert(
compareArray(new TA([0n, 0n]).fill(1n, 0, NaN), [0n, 0n]),
'`NaN` end coerced to 0'
);
assert(
compareArray(new TA([0n, 0n]).fill(1n, '1'), [0n, 1n]),
'string start coerced'
);
assert(
compareArray(new TA([0n, 0n]).fill(1n, 0, '1'), [1n, 0n]),
'string end coerced'
);
assert(
compareArray(new TA([0n, 0n]).fill(1n, 1.5), [0n, 1n]),
'start as a float number coerced'
);
assert(
compareArray(new TA([0n, 0n]).fill(1n, 0, 1.5), [1n, 0n]),
'end as a float number coerced'
); );
}); });

View File

@ -32,11 +32,34 @@ info: |
includes: [compareArray.js, testBigIntTypedArray.js] includes: [compareArray.js, testBigIntTypedArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
assert(compareArray(new TA([0n, 0n, 0n]).fill(8n, 1, 2), [0n, 8n, 0n])); assert.compareArray(
assert(compareArray(new TA([0n, 0n, 0n, 0n, 0n]).fill(8n, -3, 4), [0n, 0n, 8n, 8n, 0n])); new TA([0n, 0n, 0n]).fill(8n, 1, 2),
assert(compareArray(new TA([0n, 0n, 0n, 0n, 0n]).fill(8n, -2, -1), [0n, 0n, 0n, 8n, 0n])); [0n, 8n, 0n],
assert(compareArray(new TA([0n, 0n, 0n, 0n, 0n]).fill(8n, -1, -3), [0n, 0n, 0n, 0n, 0n])); 'new TA([0n, 0n, 0n]).fill(8n, 1, 2) must return [0n, 8n, 0n]'
assert(compareArray(new TA([0n, 0n, 0n, 0n, 0n]).fill(8n, 1, 3), [0n, 8n, 8n, 0n, 0n])); );
assert.compareArray(
new TA([0n, 0n, 0n, 0n, 0n]).fill(8n, -3, 4),
[0n, 0n, 8n, 8n, 0n],
'new TA([0n, 0n, 0n, 0n, 0n]).fill(8n, -3, 4) must return [0n, 0n, 8n, 8n, 0n]'
);
assert.compareArray(
new TA([0n, 0n, 0n, 0n, 0n]).fill(8n, -2, -1),
[0n, 0n, 0n, 8n, 0n],
'new TA([0n, 0n, 0n, 0n, 0n]).fill(8n, -2, -1) must return [0n, 0n, 0n, 8n, 0n]'
);
assert.compareArray(
new TA([0n, 0n, 0n, 0n, 0n]).fill(8n, -1, -3),
[0n, 0n, 0n, 0n, 0n],
'new TA([0n, 0n, 0n, 0n, 0n]).fill(8n, -1, -3) must return [0n, 0n, 0n, 0n, 0n]'
);
assert.compareArray(
new TA([0n, 0n, 0n, 0n, 0n]).fill(8n, 1, 3),
[0n, 8n, 8n, 0n, 0n],
'new TA([0n, 0n, 0n, 0n, 0n]).fill(8n, 1, 3) must return [0n, 8n, 8n, 0n, 0n]'
);
}); });

View File

@ -29,25 +29,28 @@ info: |
includes: [compareArray.js, testBigIntTypedArray.js] includes: [compareArray.js, testBigIntTypedArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
assert( assert.compareArray(
compareArray(new TA([0n, 0n, 0n]).fill(8n, 0, 1), [8n, 0n, 0n]), new TA([0n, 0n, 0n]).fill(8n, 0, 1),
"Fill elements from custom end position" [8n, 0n, 0n],
'new TA([0n, 0n, 0n]).fill(8n, 0, 1) must return [8n, 0n, 0n]'
); );
assert( assert.compareArray(
compareArray(new TA([0n, 0n, 0n]).fill(8n, 0, -1), [8n, 8n, 0n]), new TA([0n, 0n, 0n]).fill(8n, 0, -1),
"negative end sets final position to max((length + relativeEnd), 0)" [8n, 8n, 0n],
'new TA([0n, 0n, 0n]).fill(8n, 0, -1) must return [8n, 8n, 0n]'
); );
assert( assert.compareArray(
compareArray(new TA([0n, 0n, 0n]).fill(8n, 0, 5), [8n, 8n, 8n]), new TA([0n, 0n, 0n]).fill(8n, 0, 5),
"end position is never higher than of length" [8n, 8n, 8n],
'new TA([0n, 0n, 0n]).fill(8n, 0, 5) must return [8n, 8n, 8n]'
); );
assert( assert.compareArray(
compareArray(new TA([0n, 0n, 0n]).fill(8n, 0, -4), [0n, 0n, 0n]), new TA([0n, 0n, 0n]).fill(8n, 0, -4),
"end position is 0 when (len + relativeEnd) < 0" [0n, 0n, 0n],
'new TA([0n, 0n, 0n]).fill(8n, 0, -4) must return [0n, 0n, 0n]'
); );
}); });

View File

@ -27,25 +27,28 @@ info: |
includes: [compareArray.js, testBigIntTypedArray.js] includes: [compareArray.js, testBigIntTypedArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
assert( assert.compareArray(
compareArray(new TA([0n, 0n, 0n]).fill(8n, 1), [0n, 8n, 8n]), new TA([0n, 0n, 0n]).fill(8n, 1),
"Fill elements from custom start position" [0n, 8n, 8n],
'new TA([0n, 0n, 0n]).fill(8n, 1) must return [0n, 8n, 8n]'
); );
assert( assert.compareArray(
compareArray(new TA([0n, 0n, 0n]).fill(8n, 4), [0n, 0n, 0n]), new TA([0n, 0n, 0n]).fill(8n, 4),
"start position is never higher than length" [0n, 0n, 0n],
'new TA([0n, 0n, 0n]).fill(8n, 4) must return [0n, 0n, 0n]'
); );
assert( assert.compareArray(
compareArray(new TA([0n, 0n, 0n]).fill(8n, -1), [0n, 0n, 8n]), new TA([0n, 0n, 0n]).fill(8n, -1),
"start < 0 sets initial position to max((len + relativeStart), 0)" [0n, 0n, 8n],
'new TA([0n, 0n, 0n]).fill(8n, -1) must return [0n, 0n, 8n]'
); );
assert( assert.compareArray(
compareArray(new TA([0n, 0n, 0n]).fill(8n, -5), [8n, 8n, 8n]), new TA([0n, 0n, 0n]).fill(8n, -5),
"start position is 0 when (len + relativeStart) < 0" [8n, 8n, 8n],
'new TA([0n, 0n, 0n]).fill(8n, -5) must return [8n, 8n, 8n]'
); );
}); });

View File

@ -27,18 +27,12 @@ info: |
includes: [compareArray.js, testBigIntTypedArray.js] includes: [compareArray.js, testBigIntTypedArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
assert( assert.compareArray(new TA().fill(8n), [], 'new TA().fill(8n) must return []');
compareArray(
new TA().fill(8n),
[]
),
"does not fill an empty instance"
);
assert( assert.compareArray(
compareArray(new TA([0n, 0n, 0n]).fill(8n), [8n, 8n, 8n]), new TA([0n, 0n, 0n]).fill(8n),
"Default start and end indexes are 0 and this.length" [8n, 8n, 8n],
'new TA([0n, 0n, 0n]).fill(8n) must return [8n, 8n, 8n]'
); );
}); });

View File

@ -32,73 +32,73 @@ features: [TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
assert( assert.compareArray(
compareArray(new TA([0, 0]).fill(1, undefined), [1, 1]), new TA([0, 0]).fill(1, undefined), [1, 1],
'`undefined` start coerced to 0' 'new TA([0, 0]).fill(1, undefined) must return [1, 1]'
); );
assert( assert.compareArray(
compareArray(new TA([0, 0]).fill(1, 0, undefined), [1, 1]), new TA([0, 0]).fill(1, 0, undefined), [1, 1],
'If end is undefined, let relativeEnd be len' 'new TA([0, 0]).fill(1, 0, undefined) must return [1, 1]'
); );
assert( assert.compareArray(
compareArray(new TA([0, 0]).fill(1, null), [1, 1]), new TA([0, 0]).fill(1, null), [1, 1],
'`null` start coerced to 0' 'new TA([0, 0]).fill(1, null) must return [1, 1]'
); );
assert( assert.compareArray(
compareArray(new TA([0, 0]).fill(1, 0, null), [0, 0]), new TA([0, 0]).fill(1, 0, null), [0, 0],
'`null` end coerced to 0' 'new TA([0, 0]).fill(1, 0, null) must return [0, 0]'
); );
assert( assert.compareArray(
compareArray(new TA([0, 0]).fill(1, true), [0, 1]), new TA([0, 0]).fill(1, true), [0, 1],
'`true` start coerced to 1' 'new TA([0, 0]).fill(1, true) must return [0, 1]'
); );
assert( assert.compareArray(
compareArray(new TA([0, 0]).fill(1, 0, true), [1, 0]), new TA([0, 0]).fill(1, 0, true), [1, 0],
'`true` end coerced to 1' 'new TA([0, 0]).fill(1, 0, true) must return [1, 0]'
); );
assert( assert.compareArray(
compareArray(new TA([0, 0]).fill(1, false), [1, 1]), new TA([0, 0]).fill(1, false), [1, 1],
'`false` start coerced to 0' 'new TA([0, 0]).fill(1, false) must return [1, 1]'
); );
assert( assert.compareArray(
compareArray(new TA([0, 0]).fill(1, 0, false), [0, 0]), new TA([0, 0]).fill(1, 0, false), [0, 0],
'`false` end coerced to 0' 'new TA([0, 0]).fill(1, 0, false) must return [0, 0]'
); );
assert( assert.compareArray(
compareArray(new TA([0, 0]).fill(1, NaN), [1, 1]), new TA([0, 0]).fill(1, NaN), [1, 1],
'`NaN` start coerced to 0' 'new TA([0, 0]).fill(1, NaN) must return [1, 1]'
); );
assert( assert.compareArray(
compareArray(new TA([0, 0]).fill(1, 0, NaN), [0, 0]), new TA([0, 0]).fill(1, 0, NaN), [0, 0],
'`NaN` end coerced to 0' 'new TA([0, 0]).fill(1, 0, NaN) must return [0, 0]'
); );
assert( assert.compareArray(
compareArray(new TA([0, 0]).fill(1, '1'), [0, 1]), new TA([0, 0]).fill(1, '1'), [0, 1],
'string start coerced' 'new TA([0, 0]).fill(1, "1") must return [0, 1]'
); );
assert( assert.compareArray(
compareArray(new TA([0, 0]).fill(1, 0, '1'), [1, 0]), new TA([0, 0]).fill(1, 0, '1'), [1, 0],
'string end coerced' 'new TA([0, 0]).fill(1, 0, "1") must return [1, 0]'
); );
assert( assert.compareArray(
compareArray(new TA([0, 0]).fill(1, 1.5), [0, 1]), new TA([0, 0]).fill(1, 1.5), [0, 1],
'start as a float number coerced' 'new TA([0, 0]).fill(1, 1.5) must return [0, 1]'
); );
assert( assert.compareArray(
compareArray(new TA([0, 0]).fill(1, 0, 1.5), [1, 0]), new TA([0, 0]).fill(1, 0, 1.5), [1, 0],
'end as a float number coerced' 'new TA([0, 0]).fill(1, 0, 1.5) must return [1, 0]'
); );
}); });

View File

@ -34,9 +34,25 @@ features: [TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
assert(compareArray(new TA([0, 0, 0]).fill(8, 1, 2), [0, 8, 0])); assert.compareArray(new TA([0, 0, 0]).fill(8, 1, 2), [0, 8, 0], 'new TA([0, 0, 0]).fill(8, 1, 2) must return [0, 8, 0]');
assert(compareArray(new TA([0, 0, 0, 0, 0]).fill(8, -3, 4), [0, 0, 8, 8, 0])); assert.compareArray(
assert(compareArray(new TA([0, 0, 0, 0, 0]).fill(8, -2, -1), [0, 0, 0, 8, 0])); new TA([0, 0, 0, 0, 0]).fill(8, -3, 4),
assert(compareArray(new TA([0, 0, 0, 0, 0]).fill(8, -1, -3), [0, 0, 0, 0, 0])); [0, 0, 8, 8, 0],
assert(compareArray(new TA([0, 0, 0, 0, 0]).fill(8, 1, 3), [0, 8, 8, 0, 0])); 'new TA([0, 0, 0, 0, 0]).fill(8, -3, 4) must return [0, 0, 8, 8, 0]'
);
assert.compareArray(
new TA([0, 0, 0, 0, 0]).fill(8, -2, -1),
[0, 0, 0, 8, 0],
'new TA([0, 0, 0, 0, 0]).fill(8, -2, -1) must return [0, 0, 0, 8, 0]'
);
assert.compareArray(
new TA([0, 0, 0, 0, 0]).fill(8, -1, -3),
[0, 0, 0, 0, 0],
'new TA([0, 0, 0, 0, 0]).fill(8, -1, -3) must return [0, 0, 0, 0, 0]'
);
assert.compareArray(
new TA([0, 0, 0, 0, 0]).fill(8, 1, 3),
[0, 8, 8, 0, 0],
'new TA([0, 0, 0, 0, 0]).fill(8, 1, 3) must return [0, 8, 8, 0, 0]'
);
}); });

View File

@ -31,23 +31,23 @@ features: [TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
assert( assert.compareArray(
compareArray(new TA([0, 0, 0]).fill(8, 0, 1), [8, 0, 0]), new TA([0, 0, 0]).fill(8, 0, 1), [8, 0, 0],
"Fill elements from custom end position" 'new TA([0, 0, 0]).fill(8, 0, 1) must return [8, 0, 0]'
); );
assert( assert.compareArray(
compareArray(new TA([0, 0, 0]).fill(8, 0, -1), [8, 8, 0]), new TA([0, 0, 0]).fill(8, 0, -1), [8, 8, 0],
"negative end sets final position to max((length + relativeEnd), 0)" 'new TA([0, 0, 0]).fill(8, 0, -1) must return [8, 8, 0]'
); );
assert( assert.compareArray(
compareArray(new TA([0, 0, 0]).fill(8, 0, 5), [8, 8, 8]), new TA([0, 0, 0]).fill(8, 0, 5), [8, 8, 8],
"end position is never higher than of length" 'new TA([0, 0, 0]).fill(8, 0, 5) must return [8, 8, 8]'
); );
assert( assert.compareArray(
compareArray(new TA([0, 0, 0]).fill(8, 0, -4), [0, 0, 0]), new TA([0, 0, 0]).fill(8, 0, -4), [0, 0, 0],
"end position is 0 when (len + relativeEnd) < 0" 'new TA([0, 0, 0]).fill(8, 0, -4) must return [0, 0, 0]'
); );
}); });

View File

@ -29,23 +29,23 @@ features: [TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
assert( assert.compareArray(
compareArray(new TA([0, 0, 0]).fill(8, 1), [0, 8, 8]), new TA([0, 0, 0]).fill(8, 1), [0, 8, 8],
"Fill elements from custom start position" 'new TA([0, 0, 0]).fill(8, 1) must return [0, 8, 8]'
); );
assert( assert.compareArray(
compareArray(new TA([0, 0, 0]).fill(8, 4), [0, 0, 0]), new TA([0, 0, 0]).fill(8, 4), [0, 0, 0],
"start position is never higher than length" 'new TA([0, 0, 0]).fill(8, 4) must return [0, 0, 0]'
); );
assert( assert.compareArray(
compareArray(new TA([0, 0, 0]).fill(8, -1), [0, 0, 8]), new TA([0, 0, 0]).fill(8, -1), [0, 0, 8],
"start < 0 sets initial position to max((len + relativeStart), 0)" 'new TA([0, 0, 0]).fill(8, -1) must return [0, 0, 8]'
); );
assert( assert.compareArray(
compareArray(new TA([0, 0, 0]).fill(8, -5), [8, 8, 8]), new TA([0, 0, 0]).fill(8, -5), [8, 8, 8],
"start position is 0 when (len + relativeStart) < 0" 'new TA([0, 0, 0]).fill(8, -5) must return [8, 8, 8]'
); );
}); });

View File

@ -29,16 +29,13 @@ features: [TypedArray]
---*/ ---*/
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
assert( assert.compareArray(
compareArray( new TA().fill(8), [],
new TA().fill(8), 'new TA().fill(8) must return []'
[]
),
"does not fill an empty instance"
); );
assert( assert.compareArray(
compareArray(new TA([0, 0, 0]).fill(8), [8, 8, 8]), new TA([0, 0, 0]).fill(8), [8, 8, 8],
"Default start and end indexes are 0 and this.length" 'new TA([0, 0, 0]).fill(8) must return [8, 8, 8]'
); );
}); });

View File

@ -15,10 +15,7 @@ info: |
includes: [testBigIntTypedArray.js, compareArray.js] includes: [testBigIntTypedArray.js, compareArray.js]
features: [BigInt, Symbol, TypedArray] features: [BigInt, Symbol, TypedArray]
---*/ ---*/
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA([40n, 41n, 42n]);
[ [
true, true,
1, 1,
@ -32,7 +29,9 @@ testWithBigIntTypedArrayConstructors(function(TA) {
0.1, 0.1,
-0.1 -0.1
].forEach(function(val) { ].forEach(function(val) {
var result = sample.filter(function() { return val; }); const sample = new TA([40n, 41n, 42n]);
assert(compareArray(result, sample), val); const result = sample.filter(() => val);
assert.compareArray(result, sample, 'The value of result is expected to equal the value of sample');
}); });
}); });

View File

@ -48,7 +48,6 @@ testWithBigIntTypedArrayConstructors(function(TA) {
}; };
result = sample.filter(function() {}); result = sample.filter(function() {});
assert.sameValue(result, other, 'The value of result is expected to equal the value of other');
assert.sameValue(result, other, "returned another typedarray"); assert.compareArray(result, [1n, 0n, 1n], 'The value of result is expected to be [1n, 0n, 1n]');
assert(compareArray(result, [1n, 0n, 1n]), "the returned object is preserved");
}); });

View File

@ -35,22 +35,23 @@ info: |
includes: [testBigIntTypedArray.js, compareArray.js] includes: [testBigIntTypedArray.js, compareArray.js]
features: [BigInt, Symbol.species, TypedArray] features: [BigInt, Symbol.species, TypedArray]
---*/ ---*/
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA([40n, 41n, 42n]); var sample = new TA([40n, 41n, 42n]);
var calls = 0; var calls = 0;
var other, result; var other, result;
sample.constructor = {}; sample.constructor = {};
sample.constructor[Symbol.species] = function(captured) { sample.constructor[Symbol.species] = function(captured) {
calls++; calls++;
other = new TA(captured); other = new TA(captured);
return other; return other;
}; };
result = sample.filter(function() { return true; }); result = sample.filter(function() {
return true;
});
assert.sameValue(calls, 1, "ctor called once"); assert.sameValue(calls, 1, 'The value of calls is expected to be 1');
assert.sameValue(result, other, "return is instance of custom constructor"); assert.sameValue(result, other, 'The value of result is expected to equal the value of other');
assert(compareArray(result, [40n, 41n, 42n]), "values are set on the new obj"); assert.compareArray(result, [40n, 41n, 42n], 'The value of result is expected to be [40n, 41n, 42n]');
}); });

View File

@ -15,16 +15,17 @@ info: |
includes: [testBigIntTypedArray.js, compareArray.js] includes: [testBigIntTypedArray.js, compareArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA([41n, 1n, 42n, 7n]); var sample = new TA([41n, 1n, 42n, 7n]);
var result; var result = sample.filter(function() {
return true;
});
result = sample.filter(function() { return true; }); assert.compareArray(result, [41n, 1n, 42n, 7n], 'The value of result is expected to be [41n, 1n, 42n, 7n]');
assert(compareArray(result, [41n, 1n, 42n, 7n]), "values are set #1");
result = sample.filter(function(v) { result = sample.filter(function(v) {
return v > 40n; return v > 40n;
}); });
assert(compareArray(result, [41n, 42n]), "values are set #2");
assert.compareArray(result, [41n, 42n], 'The value of result is expected to be [41n, 42n]');
}); });

View File

@ -33,6 +33,6 @@ testWithTypedArrayConstructors(function(TA) {
-0.1 -0.1
].forEach(function(val) { ].forEach(function(val) {
var result = sample.filter(function() { return val; }); var result = sample.filter(function() { return val; });
assert(compareArray(result, sample), val); assert.compareArray(result, sample, 'The value of result is expected to equal the value of sample');
}); });
}); });

View File

@ -49,6 +49,6 @@ testWithTypedArrayConstructors(function(TA) {
result = sample.filter(function() {}); result = sample.filter(function() {});
assert.sameValue(result, other, "returned another typedarray"); assert.sameValue(result, other, 'The value of result is expected to equal the value of other');
assert(compareArray(result, [1, 0, 1]), "the returned object is preserved"); assert.compareArray(result, [1, 0, 1], 'The value of result is expected to be [1, 0, 1]');
}); });

View File

@ -50,7 +50,7 @@ testWithTypedArrayConstructors(function(TA) {
result = sample.filter(function() { return true; }); result = sample.filter(function() { return true; });
assert.sameValue(calls, 1, "ctor called once"); assert.sameValue(calls, 1, 'The value of calls is expected to be 1');
assert.sameValue(result, other, "return is instance of custom constructor"); assert.sameValue(result, other, 'The value of result is expected to equal the value of other');
assert(compareArray(result, [40, 41, 42]), "values are set on the new obj"); assert.compareArray(result, [40, 41, 42], 'The value of result is expected to be [40, 41, 42]');
}); });

View File

@ -21,10 +21,10 @@ testWithTypedArrayConstructors(function(TA) {
var result; var result;
result = sample.filter(function() { return true; }); result = sample.filter(function() { return true; });
assert(compareArray(result, [41, 1, 42, 7]), "values are set #1"); assert.compareArray(result, [41, 1, 42, 7], 'The value of result is expected to be [41, 1, 42, 7]');
result = sample.filter(function(v) { result = sample.filter(function(v) {
return v > 40; return v > 40;
}); });
assert(compareArray(result, [41, 42]), "values are set #2"); assert.compareArray(result, [41, 42], 'The value of result is expected to be [41, 42]');
}); });

View File

@ -28,51 +28,57 @@ info: |
includes: [compareArray.js, testBigIntTypedArray.js] includes: [compareArray.js, testBigIntTypedArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var arr = [1n, 2n, 3n]; var arr = [1n, 2n, 3n];
var sample; var sample;
var result; var result;
sample = new TA(3); sample = new TA(3);
sample.find(function(val, i) { sample.find(function(val, i) {
sample[i] = arr[i]; sample[i] = arr[i];
assert.sameValue(val, 0n, 'The value of val is expected to be 0n');
assert.sameValue(val, 0n, "value is not mapped to instance");
}); });
assert(compareArray(sample, arr), "values set during each predicate call");
assert.compareArray(sample, arr, 'The value of sample is expected to equal the value of arr');
sample = new TA(arr); sample = new TA(arr);
result = sample.find(function(val, i) { result = sample.find(function(val, i) {
if ( i === 0 ) { if (i === 0) {
sample[2] = 7n; sample[2] = 7n;
} }
return val === 7n; return val === 7n;
}); });
assert.sameValue(result, 7n, "value found");
assert.sameValue(result, 7n, 'The value of result is expected to be 7n');
sample = new TA(arr); sample = new TA(arr);
result = sample.find(function(val, i) { result = sample.find(function(val, i) {
if ( i === 0 ) { if (i === 0) {
sample[2] = 7n; sample[2] = 7n;
} }
return val === 3n; return val === 3n;
}); });
assert.sameValue(result, undefined, "value not found");
assert.sameValue(result, undefined, 'The value of result is expected to equal undefined');
sample = new TA(arr); sample = new TA(arr);
result = sample.find(function(val, i) { result = sample.find(function(val, i) {
if ( i > 0 ) { if (i > 0) {
sample[0] = 7n; sample[0] = 7n;
} }
return val === 7n; return val === 7n;
}); });
assert.sameValue(result, undefined, "value not found - changed after call");
assert.sameValue(result, undefined, 'The value of result is expected to equal undefined');
sample = new TA(arr); sample = new TA(arr);
result = sample.find(function() { result = sample.find(function() {
sample[0] = 7n; sample[0] = 7n;
return true; return true;
}); });
assert.sameValue(result, 1n, "find() returns previous found value");
assert.sameValue(result, 1n, 'The value of result is expected to be 1n');
}); });

View File

@ -38,9 +38,9 @@ testWithTypedArrayConstructors(function(TA) {
sample.find(function(val, i) { sample.find(function(val, i) {
sample[i] = arr[i]; sample[i] = arr[i];
assert.sameValue(val, 0, "value is not mapped to instance"); assert.sameValue(val, 0, 'The value of val is expected to be 0');
}); });
assert(compareArray(sample, arr), "values set during each predicate call"); assert.compareArray(sample, arr, 'The value of sample is expected to equal the value of arr');
sample = new TA(arr); sample = new TA(arr);
result = sample.find(function(val, i) { result = sample.find(function(val, i) {
@ -49,7 +49,7 @@ testWithTypedArrayConstructors(function(TA) {
} }
return val === 7; return val === 7;
}); });
assert.sameValue(result, 7, "value found"); assert.sameValue(result, 7, 'The value of result is expected to be 7');
sample = new TA(arr); sample = new TA(arr);
result = sample.find(function(val, i) { result = sample.find(function(val, i) {
@ -58,7 +58,7 @@ testWithTypedArrayConstructors(function(TA) {
} }
return val === 3; return val === 3;
}); });
assert.sameValue(result, undefined, "value not found"); assert.sameValue(result, undefined, 'The value of result is expected to equal undefined');
sample = new TA(arr); sample = new TA(arr);
result = sample.find(function(val, i) { result = sample.find(function(val, i) {
@ -67,12 +67,12 @@ testWithTypedArrayConstructors(function(TA) {
} }
return val === 7; return val === 7;
}); });
assert.sameValue(result, undefined, "value not found - changed after call"); assert.sameValue(result, undefined, 'The value of result is expected to equal undefined');
sample = new TA(arr); sample = new TA(arr);
result = sample.find(function() { result = sample.find(function() {
sample[0] = 7; sample[0] = 7;
return true; return true;
}); });
assert.sameValue(result, 1, "find() returns previous found value"); assert.sameValue(result, 1, 'The value of result is expected to be 1');
}); });

View File

@ -24,44 +24,49 @@ info: |
includes: [compareArray.js, testBigIntTypedArray.js] includes: [compareArray.js, testBigIntTypedArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var arr = [10n, 20n, 30n]; var arr = [10n, 20n, 30n];
var sample; var sample;
var result; var result;
sample = new TA(3); sample = new TA(3);
sample.findIndex(function(val, i) { sample.findIndex(function(val, i) {
sample[i] = arr[i]; sample[i] = arr[i];
assert.sameValue(val, 0n, 'The value of val is expected to be 0n');
assert.sameValue(val, 0n, "value is not mapped to instance");
}); });
assert(compareArray(sample, arr), "values set during each predicate call");
assert.compareArray(sample, arr, 'The value of sample is expected to equal the value of arr');
sample = new TA(arr); sample = new TA(arr);
result = sample.findIndex(function(val, i) { result = sample.findIndex(function(val, i) {
if ( i === 0 ) { if (i === 0) {
sample[2] = 7n; sample[2] = 7n;
} }
return val === 7n; return val === 7n;
}); });
assert.sameValue(result, 2, "value found");
assert.sameValue(result, 2, 'The value of result is expected to be 2');
sample = new TA(arr); sample = new TA(arr);
result = sample.findIndex(function(val, i) { result = sample.findIndex(function(val, i) {
if ( i === 0 ) { if (i === 0) {
sample[2] = 7n; sample[2] = 7n;
} }
return val === 30n; return val === 30n;
}); });
assert.sameValue(result, -1, "value not found");
assert.sameValue(result, -1, 'The value of result is expected to be -1');
sample = new TA(arr); sample = new TA(arr);
result = sample.findIndex(function(val, i) { result = sample.findIndex(function(val, i) {
if ( i > 0 ) { if (i > 0) {
sample[0] = 7n; sample[0] = 7n;
} }
return val === 7n; return val === 7n;
}); });
assert.sameValue(result, -1, "value not found - changed after call");
assert.sameValue(result, -1, 'The value of result is expected to be -1');
}); });

View File

@ -34,9 +34,9 @@ testWithTypedArrayConstructors(function(TA) {
sample.findIndex(function(val, i) { sample.findIndex(function(val, i) {
sample[i] = arr[i]; sample[i] = arr[i];
assert.sameValue(val, 0, "value is not mapped to instance"); assert.sameValue(val, 0, 'The value of val is expected to be 0');
}); });
assert(compareArray(sample, arr), "values set during each predicate call"); assert.compareArray(sample, arr, 'The value of sample is expected to equal the value of arr');
sample = new TA(arr); sample = new TA(arr);
result = sample.findIndex(function(val, i) { result = sample.findIndex(function(val, i) {
@ -45,7 +45,7 @@ testWithTypedArrayConstructors(function(TA) {
} }
return val === 7; return val === 7;
}); });
assert.sameValue(result, 2, "value found"); assert.sameValue(result, 2, 'The value of result is expected to be 2');
sample = new TA(arr); sample = new TA(arr);
result = sample.findIndex(function(val, i) { result = sample.findIndex(function(val, i) {
@ -54,7 +54,7 @@ testWithTypedArrayConstructors(function(TA) {
} }
return val === 30; return val === 30;
}); });
assert.sameValue(result, -1, "value not found"); assert.sameValue(result, -1, 'The value of result is expected to be -1');
sample = new TA(arr); sample = new TA(arr);
result = sample.findIndex(function(val, i) { result = sample.findIndex(function(val, i) {
@ -63,5 +63,5 @@ testWithTypedArrayConstructors(function(TA) {
} }
return val === 7; return val === 7;
}); });
assert.sameValue(result, -1, "value not found - changed after call"); assert.sameValue(result, -1, 'The value of result is expected to be -1');
}); });

View File

@ -17,50 +17,69 @@ includes: [compareArray.js, testBigIntTypedArray.js]
features: [BigInt, TypedArray, array-find-from-last] features: [BigInt, TypedArray, array-find-from-last]
---*/ ---*/
assert.sameValue(
typeof BigInt64Array.prototype.findLast,
'function',
'The value of `typeof BigInt64Array.prototype.findLast` is expected to be "function"'
);
assert.sameValue(
typeof BigUint64Array.prototype.findLast,
'function',
'The value of `typeof BigUint64Array.prototype.findLast` is expected to be "function"'
);
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var arr = [1n, 2n, 3n]; var arr = [1n, 2n, 3n];
var sample; var sample;
var result; var result;
sample = new TA(3); sample = new TA(3);
sample.findLast(function(val, i) { sample.findLast(function(val, i) {
sample[i] = arr[i]; sample[i] = arr[i];
assert.sameValue(val, 0n, 'The value of val is expected to be 0n');
assert.sameValue(val, 0n, "value is not mapped to instance");
}); });
assert(compareArray(sample, arr), "values set during each predicate call");
assert.compareArray(sample, arr, 'The value of sample is expected to equal the value of arr');
sample = new TA(arr); sample = new TA(arr);
result = sample.findLast(function(val, i) { result = sample.findLast(function(val, i) {
if ( i === 2 ) { if (i === 2) {
sample[0] = 7n; sample[0] = 7n;
} }
return val === 7n; return val === 7n;
}); });
assert.sameValue(result, 7n, "value found");
assert.sameValue(result, 7n, 'The value of result is expected to be 7n');
sample = new TA(arr); sample = new TA(arr);
result = sample.findLast(function(val, i) { result = sample.findLast(function(val, i) {
if ( i === 2 ) { if (i === 2) {
sample[0] = 7n; sample[0] = 7n;
} }
return val === 1n; return val === 1n;
}); });
assert.sameValue(result, undefined, "value not found");
assert.sameValue(result, undefined, 'The value of result is expected to equal undefined');
sample = new TA(arr); sample = new TA(arr);
result = sample.findLast(function(val, i) { result = sample.findLast(function(val, i) {
if ( i < 2 ) { if (i < 2) {
sample[2] = 7n; sample[2] = 7n;
} }
return val === 7n; return val === 7n;
}); });
assert.sameValue(result, undefined, "value not found - changed after call");
assert.sameValue(result, undefined, 'The value of result is expected to equal undefined');
sample = new TA(arr); sample = new TA(arr);
result = sample.findLast(function() { result = sample.findLast(function() {
sample[2] = 7n; sample[2] = 7n;
return true; return true;
}); });
assert.sameValue(result, 3n, "findLast() returns previous found value");
assert.sameValue(result, 3n, 'The value of result is expected to be 3n');
}); });

View File

@ -17,6 +17,18 @@ includes: [compareArray.js, testTypedArray.js]
features: [TypedArray, array-find-from-last] features: [TypedArray, array-find-from-last]
---*/ ---*/
assert.sameValue(
typeof BigInt64Array.prototype.findLast,
'function',
'The value of `typeof BigInt64Array.prototype.findLast` is expected to be "function"'
);
assert.sameValue(
typeof BigUint64Array.prototype.findLast,
'function',
'The value of `typeof BigUint64Array.prototype.findLast` is expected to be "function"'
);
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
var arr = [1, 2, 3]; var arr = [1, 2, 3];
var sample; var sample;
@ -26,9 +38,9 @@ testWithTypedArrayConstructors(function(TA) {
sample.findLast(function(val, i) { sample.findLast(function(val, i) {
sample[i] = arr[i]; sample[i] = arr[i];
assert.sameValue(val, 0, "value is not mapped to instance"); assert.sameValue(val, 0, 'The value of val is expected to be 0');
}); });
assert(compareArray(sample, arr), "values set during each predicate call"); assert.compareArray(sample, arr, 'The value of sample is expected to equal the value of arr');
sample = new TA(arr); sample = new TA(arr);
result = sample.findLast(function(val, i) { result = sample.findLast(function(val, i) {
@ -37,7 +49,7 @@ testWithTypedArrayConstructors(function(TA) {
} }
return val === 7; return val === 7;
}); });
assert.sameValue(result, 7, "value found"); assert.sameValue(result, 7, 'The value of result is expected to be 7');
sample = new TA(arr); sample = new TA(arr);
result = sample.findLast(function(val, i) { result = sample.findLast(function(val, i) {
@ -46,7 +58,7 @@ testWithTypedArrayConstructors(function(TA) {
} }
return val === 1; return val === 1;
}); });
assert.sameValue(result, undefined, "value not found"); assert.sameValue(result, undefined, 'The value of result is expected to equal undefined');
sample = new TA(arr); sample = new TA(arr);
result = sample.findLast(function(val, i) { result = sample.findLast(function(val, i) {
@ -55,12 +67,12 @@ testWithTypedArrayConstructors(function(TA) {
} }
return val === 7; return val === 7;
}); });
assert.sameValue(result, undefined, "value not found - changed after call"); assert.sameValue(result, undefined, 'The value of result is expected to equal undefined');
sample = new TA(arr); sample = new TA(arr);
result = sample.findLast(function() { result = sample.findLast(function() {
sample[2] = 7; sample[2] = 7;
return true; return true;
}); });
assert.sameValue(result, 3, "findLast() returns previous found value"); assert.sameValue(result, 3, 'The value of result is expected to be 3');
}); });

View File

@ -16,43 +16,61 @@ includes: [compareArray.js, testBigIntTypedArray.js]
features: [BigInt, TypedArray, array-find-from-last] features: [BigInt, TypedArray, array-find-from-last]
---*/ ---*/
assert.sameValue(
typeof BigInt64Array.prototype.findLastIndex,
'function',
'The value of `typeof BigInt64Array.prototype.findLastIndex` is expected to be "function"'
);
assert.sameValue(
typeof BigUint64Array.prototype.findLastIndex,
'function',
'The value of `typeof BigUint64Array.prototype.findLastIndex` is expected to be "function"'
);
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var arr = [10n, 20n, 30n]; var arr = [10n, 20n, 30n];
var sample; var sample;
var result; var result;
sample = new TA(3); sample = new TA(3);
sample.findLastIndex(function(val, i) { sample.findLastIndex(function(val, i) {
sample[i] = arr[i]; sample[i] = arr[i];
assert.sameValue(val, 0n, 'The value of val is expected to be 0n');
assert.sameValue(val, 0n, "value is not mapped to instance");
}); });
assert(compareArray(sample, arr), "values set during each predicate call");
assert.compareArray(sample, arr, 'The value of sample is expected to equal the value of arr');
sample = new TA(arr); sample = new TA(arr);
result = sample.findLastIndex(function(val, i) { result = sample.findLastIndex(function(val, i) {
if ( i === 2 ) { if (i === 2) {
sample[0] = 7n; sample[0] = 7n;
} }
return val === 7n; return val === 7n;
}); });
assert.sameValue(result, 0, "value found");
assert.sameValue(result, 0, 'The value of result is expected to be 0');
sample = new TA(arr); sample = new TA(arr);
result = sample.findLastIndex(function(val, i) { result = sample.findLastIndex(function(val, i) {
if ( i === 2 ) { if (i === 2) {
sample[0] = 7n; sample[0] = 7n;
} }
return val === 10n; return val === 10n;
}); });
assert.sameValue(result, -1, "value not found");
assert.sameValue(result, -1, 'The value of result is expected to be -1');
sample = new TA(arr); sample = new TA(arr);
result = sample.findLastIndex(function(val, i) { result = sample.findLastIndex(function(val, i) {
if ( i < 2 ) { if (i < 2) {
sample[2] = 7n; sample[2] = 7n;
} }
return val === 7n; return val === 7n;
}); });
assert.sameValue(result, -1, "value not found - changed after call");
assert.sameValue(result, -1, 'The value of result is expected to be -1');
}); });

View File

@ -16,6 +16,18 @@ includes: [compareArray.js, testTypedArray.js]
features: [TypedArray, array-find-from-last] features: [TypedArray, array-find-from-last]
---*/ ---*/
assert.sameValue(
typeof BigInt64Array.prototype.findLastIndex,
'function',
'The value of `typeof BigInt64Array.prototype.findLastIndex` is expected to be "function"'
);
assert.sameValue(
typeof BigUint64Array.prototype.findLastIndex,
'function',
'The value of `typeof BigUint64Array.prototype.findLastIndex` is expected to be "function"'
);
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
var arr = [10, 20, 30]; var arr = [10, 20, 30];
var sample; var sample;
@ -25,9 +37,9 @@ testWithTypedArrayConstructors(function(TA) {
sample.findLastIndex(function(val, i) { sample.findLastIndex(function(val, i) {
sample[i] = arr[i]; sample[i] = arr[i];
assert.sameValue(val, 0, "value is not mapped to instance"); assert.sameValue(val, 0, 'The value of val is expected to be 0');
}); });
assert(compareArray(sample, arr), "values set during each predicate call"); assert.compareArray(sample, arr, 'The value of sample is expected to equal the value of arr');
sample = new TA(arr); sample = new TA(arr);
result = sample.findLastIndex(function(val, i) { result = sample.findLastIndex(function(val, i) {
@ -36,7 +48,7 @@ testWithTypedArrayConstructors(function(TA) {
} }
return val === 7; return val === 7;
}); });
assert.sameValue(result, 0, "value found"); assert.sameValue(result, 0, 'The value of result is expected to be 0');
sample = new TA(arr); sample = new TA(arr);
result = sample.findLastIndex(function(val, i) { result = sample.findLastIndex(function(val, i) {
@ -45,7 +57,7 @@ testWithTypedArrayConstructors(function(TA) {
} }
return val === 10; return val === 10;
}); });
assert.sameValue(result, -1, "value not found"); assert.sameValue(result, -1, 'The value of result is expected to be -1');
sample = new TA(arr); sample = new TA(arr);
result = sample.findLastIndex(function(val, i) { result = sample.findLastIndex(function(val, i) {
@ -54,5 +66,5 @@ testWithTypedArrayConstructors(function(TA) {
} }
return val === 7; return val === 7;
}); });
assert.sameValue(result, -1, "value not found - changed after call"); assert.sameValue(result, -1, 'The value of result is expected to be -1');
}); });

View File

@ -35,20 +35,21 @@ info: |
includes: [testBigIntTypedArray.js, compareArray.js] includes: [testBigIntTypedArray.js, compareArray.js]
features: [BigInt, Symbol.species, TypedArray] features: [BigInt, Symbol.species, TypedArray]
---*/ ---*/
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA([40n]); var sample = new TA([40n]);
var otherTA = TA === BigInt64Array ? BigUint64Array : BigInt64Array; var otherTA = TA === BigInt64Array ? BigUint64Array : BigInt64Array;
var other = new otherTA([1n, 0n, 1n]); var other = new otherTA([1n, 0n, 1n]);
var result; var result;
sample.constructor = {}; sample.constructor = {};
sample.constructor[Symbol.species] = function() { sample.constructor[Symbol.species] = function() {
return other; return other;
}; };
result = sample.map(function(a) { return a + 7n; }); result = sample.map(function(a) {
return a + 7n;
});
assert.sameValue(result, other, "returned another typedarray"); assert.sameValue(result, other, 'The value of result is expected to equal the value of other');
assert(compareArray(result, [47n, 0n, 1n]), "values are set on returned typedarray"); assert.compareArray(result, [47n, 0n, 1n], 'The value of result is expected to be [47n, 0n, 1n]');
}); });

View File

@ -35,22 +35,23 @@ info: |
includes: [testBigIntTypedArray.js, compareArray.js] includes: [testBigIntTypedArray.js, compareArray.js]
features: [BigInt, Symbol.species, TypedArray] features: [BigInt, Symbol.species, TypedArray]
---*/ ---*/
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA([40n, 41n, 42n]); var sample = new TA([40n, 41n, 42n]);
var calls = 0; var calls = 0;
var other, result; var other, result;
sample.constructor = {}; sample.constructor = {};
sample.constructor[Symbol.species] = function(len) { sample.constructor[Symbol.species] = function(len) {
calls++; calls++;
other = new TA(len); other = new TA(len);
return other; return other;
}; };
result = sample.map(function(a) { return a + 7n; }); result = sample.map(function(a) {
return a + 7n;
});
assert.sameValue(calls, 1, "ctor called once"); assert.sameValue(calls, 1, 'The value of calls is expected to be 1');
assert.sameValue(result, other, "return is instance of custom constructor"); assert.sameValue(result, other, 'The value of result is expected to equal the value of other');
assert(compareArray(result, [47n, 48n, 49n]), "values are set on the new obj"); assert.compareArray(result, [47n, 48n, 49n], 'The value of result is expected to be [47n, 48n, 49n]');
}); });

View File

@ -65,7 +65,7 @@ function body(FloatArray) {
sampleBytes = new Uint8Array(sample.buffer); sampleBytes = new Uint8Array(sample.buffer);
resultBytes = new Uint8Array(result.buffer); resultBytes = new Uint8Array(result.buffer);
assert(compareArray(sampleBytes, resultBytes)); assert.compareArray(sampleBytes, resultBytes, 'The value of sampleBytes is expected to equal the value of resultBytes');
} }
testWithTypedArrayConstructors(body, [Float32Array, Float64Array]); testWithTypedArrayConstructors(body, [Float32Array, Float64Array]);

View File

@ -49,6 +49,6 @@ testWithTypedArrayConstructors(function(TA) {
result = sample.map(function(a) { return a + 7; }); result = sample.map(function(a) { return a + 7; });
assert.sameValue(result, other, "returned another typedarray"); assert.sameValue(result, other, 'The value of result is expected to equal the value of other');
assert(compareArray(result, [47, 0, 1]), "values are set on returned typedarray"); assert.compareArray(result, [47, 0, 1], 'The value of result is expected to be [47, 0, 1]');
}); });

View File

@ -50,7 +50,7 @@ testWithTypedArrayConstructors(function(TA) {
result = sample.map(function(a) { return a + 7; }); result = sample.map(function(a) { return a + 7; });
assert.sameValue(calls, 1, "ctor called once"); assert.sameValue(calls, 1, 'The value of calls is expected to be 1');
assert.sameValue(result, other, "return is instance of custom constructor"); assert.sameValue(result, other, 'The value of result is expected to equal the value of other');
assert(compareArray(result, [47, 48, 49]), "values are set on the new obj"); assert.compareArray(result, [47, 48, 49], 'The value of result is expected to be [47, 48, 49]');
}); });

View File

@ -18,40 +18,25 @@ info: |
includes: [testBigIntTypedArray.js, compareArray.js] includes: [testBigIntTypedArray.js, compareArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
var buffer = new ArrayBuffer(64); var buffer = new ArrayBuffer(64);
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA(buffer, 0, 4); var sample = new TA(buffer, 0, 4);
var other = new TA(buffer, 0, 5); var other = new TA(buffer, 0, 5);
sample[0] = 42n; sample[0] = 42n;
sample[1] = 43n; sample[1] = 43n;
sample[2] = 2n; sample[2] = 2n;
sample[3] = 1n; sample[3] = 1n;
other[4] = 7n; other[4] = 7n;
sample.reverse(); sample.reverse();
assert( assert.compareArray(sample, [1n, 2n, 43n, 42n], 'The value of sample is expected to be [1n, 2n, 43n, 42n]');
compareArray(sample, [1n, 2n, 43n, 42n]) assert.compareArray(other, [1n, 2n, 43n, 42n, 7n], 'The value of other is expected to be [1n, 2n, 43n, 42n, 7n]');
);
assert(
compareArray(other, [1n, 2n, 43n, 42n, 7n])
);
sample[0] = 7n; sample[0] = 7n;
sample[1] = 17n; sample[1] = 17n;
sample[2] = 1n; sample[2] = 1n;
sample[3] = 0n; sample[3] = 0n;
other[4] = 42n; other[4] = 42n;
other.reverse(); other.reverse();
assert( assert.compareArray(other, [42n, 0n, 1n, 17n, 7n], 'The value of other is expected to be [42n, 0n, 1n, 17n, 7n]');
compareArray(other, [42n, 0n, 1n, 17n, 7n]) assert.compareArray(sample, [42n, 0n, 1n, 17n], 'The value of sample is expected to be [42n, 0n, 1n, 17n]');
);
assert(
compareArray(sample, [42n, 0n, 1n, 17n])
);
}); });

View File

@ -32,13 +32,8 @@ testWithTypedArrayConstructors(function(TA) {
other[4] = 7; other[4] = 7;
sample.reverse(); sample.reverse();
assert( assert.compareArray(sample, [1, 2, 43, 42], 'The value of sample is expected to be [1, 2, 43, 42]');
compareArray(sample, [1, 2, 43, 42]) assert.compareArray(other, [1, 2, 43, 42, 7], 'The value of other is expected to be [1, 2, 43, 42, 7]');
);
assert(
compareArray(other, [1, 2, 43, 42, 7])
);
sample[0] = 7; sample[0] = 7;
sample[1] = 17; sample[1] = 17;
@ -47,11 +42,6 @@ testWithTypedArrayConstructors(function(TA) {
other[4] = 42; other[4] = 42;
other.reverse(); other.reverse();
assert( assert.compareArray(other, [42, 0, 1, 17, 7], 'The value of other is expected to be [42, 0, 1, 17, 7]');
compareArray(other, [42, 0, 1, 17, 7]) assert.compareArray(sample, [42, 0, 1, 17], 'The value of sample is expected to be [42, 0, 1, 17]');
);
assert(
compareArray(sample, [42, 0, 1, 17])
);
}); });

View File

@ -17,79 +17,72 @@ info: |
includes: [testBigIntTypedArray.js, compareArray.js] includes: [testBigIntTypedArray.js, compareArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var sample; var sample;
sample = new TA([1n, 2n]); sample = new TA([1n, 2n]);
sample.set([42n], ""); sample.set([42n], '');
assert(compareArray(sample, [42n, 2n]), "the empty string"); assert.compareArray(sample, [42n, 2n], 'The value of sample is expected to be [42n, 2n]');
sample = new TA([1n, 2n]); sample = new TA([1n, 2n]);
sample.set([42n], "0"); sample.set([42n], '0');
assert(compareArray(sample, [42n, 2n]), "'0'"); assert.compareArray(sample, [42n, 2n], 'The value of sample is expected to be [42n, 2n]');
sample = new TA([1n, 2n]); sample = new TA([1n, 2n]);
sample.set([42n], false); sample.set([42n], false);
assert(compareArray(sample, [42n, 2n]), "false"); assert.compareArray(sample, [42n, 2n], 'The value of sample is expected to be [42n, 2n]');
sample = new TA([1n, 2n]); sample = new TA([1n, 2n]);
sample.set([42n], 0.1); sample.set([42n], 0.1);
assert(compareArray(sample, [42n, 2n]), "0.1"); assert.compareArray(sample, [42n, 2n], 'The value of sample is expected to be [42n, 2n]');
sample = new TA([1n, 2n]); sample = new TA([1n, 2n]);
sample.set([42n], 0.9); sample.set([42n], 0.9);
assert(compareArray(sample, [42n, 2n]), "0.9"); assert.compareArray(sample, [42n, 2n], 'The value of sample is expected to be [42n, 2n]');
sample = new TA([1n, 2n]); sample = new TA([1n, 2n]);
sample.set([42n], -0.5); sample.set([42n], -0.5);
assert(compareArray(sample, [42n, 2n]), "-0.5"); assert.compareArray(sample, [42n, 2n], 'The value of sample is expected to be [42n, 2n]');
sample = new TA([1n, 2n]); sample = new TA([1n, 2n]);
sample.set([42n], 1.1); sample.set([42n], 1.1);
assert(compareArray(sample, [1n, 42n]), "1.1"); assert.compareArray(sample, [1n, 42n], 'The value of sample is expected to be [1n, 42n]');
sample = new TA([1n, 2n]); sample = new TA([1n, 2n]);
sample.set([42n], NaN); sample.set([42n], NaN);
assert(compareArray(sample, [42n, 2n]), "NaN"); assert.compareArray(sample, [42n, 2n], 'The value of sample is expected to be [42n, 2n]');
sample = new TA([1n, 2n]); sample = new TA([1n, 2n]);
sample.set([42n], null); sample.set([42n], null);
assert(compareArray(sample, [42n, 2n]), "null"); assert.compareArray(sample, [42n, 2n], 'The value of sample is expected to be [42n, 2n]');
sample = new TA([1n, 2n]); sample = new TA([1n, 2n]);
sample.set([42n], undefined); sample.set([42n], undefined);
assert(compareArray(sample, [42n, 2n]), "undefined"); assert.compareArray(sample, [42n, 2n], 'The value of sample is expected to be [42n, 2n]');
sample = new TA([1n, 2n]); sample = new TA([1n, 2n]);
sample.set([42n], {}); sample.set([42n], {});
assert(compareArray(sample, [42n, 2n]), "{}"); assert.compareArray(sample, [42n, 2n], 'The value of sample is expected to be [42n, 2n]');
sample = new TA([1n, 2n]); sample = new TA([1n, 2n]);
sample.set([42n], []); sample.set([42n], []);
assert(compareArray(sample, [42n, 2n]), "[]"); assert.compareArray(sample, [42n, 2n], 'The value of sample is expected to be [42n, 2n]');
sample = new TA([1n, 2n]); sample = new TA([1n, 2n]);
sample.set([42n], [0]); sample.set([42n], [0]);
assert(compareArray(sample, [42n, 2n]), "[0]"); assert.compareArray(sample, [42n, 2n], 'The value of sample is expected to be [42n, 2n]');
sample = new TA([1n, 2n]); sample = new TA([1n, 2n]);
sample.set([42n], true); sample.set([42n], true);
assert(compareArray(sample, [1n, 42n]), "true"); assert.compareArray(sample, [1n, 42n], 'The value of sample is expected to be [1n, 42n]');
sample = new TA([1n, 2n]); sample = new TA([1n, 2n]);
sample.set([42n], "1"); sample.set([42n], '1');
assert(compareArray(sample, [1n, 42n]), "'1'"); assert.compareArray(sample, [1n, 42n], 'The value of sample is expected to be [1n, 42n]');
sample = new TA([1n, 2n]); sample = new TA([1n, 2n]);
sample.set([42n], [1]); sample.set([42n], [1]);
assert(compareArray(sample, [1n, 42n]), "[1]"); assert.compareArray(sample, [1n, 42n], 'The value of sample is expected to be [1n, 42n]');
sample = new TA([1n, 2n]); sample = new TA([1n, 2n]);
sample.set([42n], { valueOf: function() {return 1;} });
assert(compareArray(sample, [1n, 42n]), "valueOf");
sample.set([42n], {
valueOf: function() {
return 1;
}
});
assert.compareArray(sample, [1n, 42n], 'The value of sample is expected to be [1n, 42n]');
sample = new TA([1n, 2n]); sample = new TA([1n, 2n]);
sample.set([42n], { toString: function() {return 1;} });
assert(compareArray(sample, [1n, 42n]), "toString"); sample.set([42n], {
toString: function() {
return 1;
}
});
assert.compareArray(sample, [1n, 42n], 'The value of sample is expected to be [1n, 42n]');
}); });

View File

@ -21,15 +21,15 @@ info: |
includes: [testBigIntTypedArray.js, compareArray.js] includes: [testBigIntTypedArray.js, compareArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var obj = { var obj = {
length: 4, length: 4,
"0": 42n, '0': 42n,
"1": 43n, '1': 43n,
"3": 44n '3': 44n
}; };
Object.defineProperty(obj, "2", {
Object.defineProperty(obj, '2', {
get: function() { get: function() {
throw new Test262Error(); throw new Test262Error();
} }
@ -39,10 +39,7 @@ testWithBigIntTypedArrayConstructors(function(TA) {
assert.throws(Test262Error, function() { assert.throws(Test262Error, function() {
sample.set(obj); sample.set(obj);
}); }, 'sample.set(obj) throws a Test262Error exception');
assert( assert.compareArray(sample, [42n, 43n, 3n, 4n], 'The value of sample is expected to be [42n, 43n, 3n, 4n]');
compareArray(sample, [42n, 43n, 3n, 4n]),
"values are set until exception"
);
}); });

View File

@ -21,24 +21,20 @@ info: |
includes: [testBigIntTypedArray.js, compareArray.js] includes: [testBigIntTypedArray.js, compareArray.js]
features: [BigInt, Symbol, TypedArray] features: [BigInt, Symbol, TypedArray]
---*/ ---*/
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var obj = { var obj = {
length: 4, length: 4,
"0": 42n, '0': 42n,
"1": 43n, '1': 43n,
"2": Symbol("1"), '2': Symbol('1'),
"3": 44n '3': 44n
}; };
var sample = new TA([1n, 2n, 3n, 4n]); var sample = new TA([1n, 2n, 3n, 4n]);
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
sample.set(obj); sample.set(obj);
}); }, 'sample.set(obj) throws a TypeError exception');
assert( assert.compareArray(sample, [42n, 43n, 3n, 4n], 'The value of sample is expected to be [42n, 43n, 3n, 4n]');
compareArray(sample, [42n, 43n, 3n, 4n]),
"values are set until exception"
);
}); });

View File

@ -21,28 +21,26 @@ info: |
includes: [testBigIntTypedArray.js, compareArray.js] includes: [testBigIntTypedArray.js, compareArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var obj = { var obj = {
length: 4, length: 4,
"0": 42n, '0': 42n,
"1": 43n, '1': 43n,
"2": {
'2': {
valueOf: function() { valueOf: function() {
throw new Test262Error(); throw new Test262Error();
} }
}, },
"3": 44n
'3': 44n
}; };
var sample = new TA([1n, 2n, 3n, 4n]); var sample = new TA([1n, 2n, 3n, 4n]);
assert.throws(Test262Error, function() { assert.throws(Test262Error, function() {
sample.set(obj); sample.set(obj);
}); }, 'sample.set(obj) throws a Test262Error exception');
assert( assert.compareArray(sample, [42n, 43n, 3n, 4n], 'The value of sample is expected to be [42n, 43n, 3n, 4n]');
compareArray(sample, [42n, 43n, 3n, 4n]),
"values are set until exception"
);
}); });

View File

@ -21,13 +21,14 @@ info: |
includes: [testBigIntTypedArray.js, compareArray.js] includes: [testBigIntTypedArray.js, compareArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA(5); var sample = new TA(5);
var calls = []; var calls = [];
var obj = { var obj = {
length: 3 length: 3
}; };
Object.defineProperty(obj, 0, { Object.defineProperty(obj, 0, {
get: function() { get: function() {
calls.push(0); calls.push(0);
@ -54,19 +55,16 @@ testWithBigIntTypedArrayConstructors(function(TA) {
Object.defineProperty(obj, 3, { Object.defineProperty(obj, 3, {
get: function() { get: function() {
throw new Test262Error("Should not call obj[3]"); throw new Test262Error('Should not call obj[3]');
} }
}); });
sample.set(obj, 1); sample.set(obj, 1);
assert.compareArray(sample, [0n, 42n, 43n, 44n, 0n], 'The value of sample is expected to be [0n, 42n, 43n, 44n, 0n]');
assert( assert.compareArray(
compareArray(sample, [0n, 42n, 43n, 44n, 0n]), calls,
"values are set for src length" [0, '0,0,0,0,0', 1, '0,42,0,0,0', 2, '0,42,43,0,0'],
); 'The value of calls is expected to be [0, "0,0,0,0,0", 1, "0,42,0,0,0", 2, "0,42,43,0,0"]'
assert(
compareArray(calls, [0, "0,0,0,0,0", 1, "0,42,0,0,0", 2, "0,42,43,0,0"]),
"values are set in order"
); );
}); });

View File

@ -21,43 +21,38 @@ info: |
includes: [testBigIntTypedArray.js, compareArray.js] includes: [testBigIntTypedArray.js, compareArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var src = [42n, 43n]; var src = [42n, 43n];
var srcObj = { var srcObj = {
length: 2, length: 2,
'0': 7n, '0': 7n,
'1': 17n '1': 17n
}; };
var sample, result;
var sample, result;
sample = new TA([1n, 2n, 3n, 4n]); sample = new TA([1n, 2n, 3n, 4n]);
result = sample.set(src, 0); result = sample.set(src, 0);
assert(compareArray(sample, [42n, 43n, 3n, 4n]), "offset: 0, result: " + sample); assert.compareArray(sample, [42n, 43n, 3n, 4n], 'The value of sample is expected to be [42n, 43n, 3n, 4n]');
assert.sameValue(result, undefined, "returns undefined"); assert.sameValue(result, undefined, 'The value of result is expected to equal undefined');
sample = new TA([1n, 2n, 3n, 4n]); sample = new TA([1n, 2n, 3n, 4n]);
result = sample.set(src, 1); result = sample.set(src, 1);
assert(compareArray(sample, [1n, 42n, 43n, 4n]), "offset: 1, result: " + sample); assert.compareArray(sample, [1n, 42n, 43n, 4n], 'The value of sample is expected to be [1n, 42n, 43n, 4n]');
assert.sameValue(result, undefined, "returns undefined"); assert.sameValue(result, undefined, 'The value of result is expected to equal undefined');
sample = new TA([1n, 2n, 3n, 4n]); sample = new TA([1n, 2n, 3n, 4n]);
result = sample.set(src, 2); result = sample.set(src, 2);
assert(compareArray(sample, [1n, 2n, 42n, 43n]), "offset: 2, result: " + sample); assert.compareArray(sample, [1n, 2n, 42n, 43n], 'The value of sample is expected to be [1n, 2n, 42n, 43n]');
assert.sameValue(result, undefined, "returns undefined"); assert.sameValue(result, undefined, 'The value of result is expected to equal undefined');
sample = new TA([1n, 2n, 3n, 4n]); sample = new TA([1n, 2n, 3n, 4n]);
result = sample.set(srcObj, 0); result = sample.set(srcObj, 0);
assert(compareArray(sample, [7n, 17n, 3n, 4n]), "offset: 0, result: " + sample); assert.compareArray(sample, [7n, 17n, 3n, 4n], 'The value of sample is expected to be [7n, 17n, 3n, 4n]');
assert.sameValue(result, undefined, "returns undefined"); assert.sameValue(result, undefined, 'The value of result is expected to equal undefined');
sample = new TA([1n, 2n, 3n, 4n]); sample = new TA([1n, 2n, 3n, 4n]);
result = sample.set(srcObj, 1); result = sample.set(srcObj, 1);
assert(compareArray(sample, [1n, 7n, 17n, 4n]), "offset: 1, result: " + sample); assert.compareArray(sample, [1n, 7n, 17n, 4n], 'The value of sample is expected to be [1n, 7n, 17n, 4n]');
assert.sameValue(result, undefined, "returns undefined"); assert.sameValue(result, undefined, 'The value of result is expected to equal undefined');
sample = new TA([1n, 2n, 3n, 4n]); sample = new TA([1n, 2n, 3n, 4n]);
result = sample.set(srcObj, 2); result = sample.set(srcObj, 2);
assert(compareArray(sample, [1n, 2n, 7n, 17n]), "offset: 2, result: " + sample); assert.compareArray(sample, [1n, 2n, 7n, 17n], 'The value of sample is expected to be [1n, 2n, 7n, 17n]');
assert.sameValue(result, undefined, "returns undefined"); assert.sameValue(result, undefined, 'The value of result is expected to equal undefined');
}); });

Some files were not shown because too many files have changed in this diff Show More