mirror of
https://github.com/tc39/test262.git
synced 2025-04-08 19:35:28 +02:00
Merge pull request #3219 from tc39/rwaldron/migrate-comparearray
chore: convert compareArray() to assert.compareArray()
This commit is contained in:
commit
b690cb67be
@ -26,8 +26,8 @@ compareArray.isSameValue = function(a, b) {
|
||||
return a === b;
|
||||
};
|
||||
|
||||
compareArray.format = function(array) {
|
||||
return `[${array.map(String).join(', ')}]`;
|
||||
compareArray.format = function(thingWithALengthPropertyAndNumericIndices) {
|
||||
return `[${[].map.call(thingWithALengthPropertyAndNumericIndices, String).join(', ')}]`;
|
||||
};
|
||||
|
||||
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(expected != null, `Second argument shouldn't be nullish. ${message}`);
|
||||
var format = compareArray.format;
|
||||
assert(
|
||||
compareArray(actual, expected),
|
||||
`Expected ${format(actual)} and ${format(expected)} to have the same contents. ${message}`
|
||||
);
|
||||
var result = compareArray(actual, expected);
|
||||
|
||||
// The following prevents actual and expected from being iterated and evaluated
|
||||
// more than once unless absolutely necessary.
|
||||
if (!result) {
|
||||
assert(false, `Expected ${format(actual)} and ${format(expected)} to have the same contents. ${message}`);
|
||||
}
|
||||
};
|
||||
|
@ -27,7 +27,7 @@ item.then(({ done, value }) => {
|
||||
item = iter.next(value);
|
||||
|
||||
item.then(({ done, value }) => {
|
||||
assert(compareArray(value, arr));
|
||||
assert.compareArray(value, arr);
|
||||
assert.sameValue(done, false);
|
||||
}).then($DONE, $DONE);
|
||||
}).catch($DONE);
|
||||
|
@ -50,4 +50,4 @@ verifyProperty(c, y, {
|
||||
configurable: true
|
||||
});
|
||||
|
||||
assert(compareArray(x, ["a", "b", "c"]));
|
||||
assert.compareArray(x, ["a", "b", "c"]);
|
||||
|
@ -50,4 +50,4 @@ verifyProperty(c, "y", {
|
||||
configurable: true
|
||||
});
|
||||
|
||||
assert(compareArray(x, ["a", "b", "c", "d"]));
|
||||
assert.compareArray(x, ["a", "b", "c", "d"]);
|
||||
|
@ -19,5 +19,5 @@ Object.defineProperty(o, Symbol('foo'), { get: () => { calls.push("Symbol(foo)")
|
||||
//- vals
|
||||
o
|
||||
//- body
|
||||
assert(compareArray(calls, [1, 'z', 'a', "Symbol(foo)"]));
|
||||
assert.compareArray(calls, [1, 'z', 'a', "Symbol(foo)"]);
|
||||
assert.sameValue(Object.keys(rest).length, 3);
|
||||
|
@ -23,5 +23,5 @@ iter.next(false);
|
||||
item = iter.next(['a', 'b', 'c']);
|
||||
item = iter.next(item.value);
|
||||
|
||||
assert(compareArray(item.value, arr));
|
||||
assert.compareArray(item.value, arr);
|
||||
assert.sameValue(item.done, false);
|
||||
|
@ -29,5 +29,5 @@ Object.defineProperty(o, Symbol('foo'), { get: () => { calls.push("Symbol(foo)")
|
||||
//- params
|
||||
obj
|
||||
//- body
|
||||
assert(compareArray(calls, [1, 'z', 'a', "Symbol(foo)"]));
|
||||
assert.compareArray(calls, [1, 'z', 'a', "Symbol(foo)"]);
|
||||
assert.sameValue(Object.keys(obj).length, 3);
|
||||
|
@ -16,21 +16,18 @@ function concatTypedArray(type, elems, modulo) {
|
||||
ta_by_len[i] = items[i] = modulo === false ? i : elems % modulo;
|
||||
}
|
||||
var ta = new type(items);
|
||||
assert(
|
||||
compareArray([].concat(ta, ta), [ta, ta]),
|
||||
'compareArray([].concat(ta, ta), [ta, ta]) must return true'
|
||||
assert.compareArray([].concat(ta, ta), [ta, ta],
|
||||
'[].concat(new type(items), new type(items)) must return [ta, ta]'
|
||||
);
|
||||
ta[Symbol.isConcatSpreadable] = true;
|
||||
assert.compareArray([].concat(ta), items, '[].concat(new type(items)) returns items');
|
||||
|
||||
assert(
|
||||
compareArray([].concat(ta_by_len, ta_by_len), [ta_by_len, ta_by_len]),
|
||||
'compareArray([].concat(ta_by_len, ta_by_len), [ta_by_len, ta_by_len]) must return true'
|
||||
assert.compareArray([].concat(ta_by_len, ta_by_len), [ta_by_len, ta_by_len],
|
||||
'[].concat(new type(elems), new type(elems)) must return [ta_by_len, ta_by_len]'
|
||||
);
|
||||
ta_by_len[Symbol.isConcatSpreadable] = true;
|
||||
assert(
|
||||
compareArray([].concat(ta_by_len), items),
|
||||
'compareArray([].concat(ta_by_len), items) must return true'
|
||||
assert.compareArray([].concat(ta_by_len), items,
|
||||
'[].concat(new type(elems)) returns items'
|
||||
);
|
||||
|
||||
// TypedArray with fake `length`.
|
||||
|
@ -16,21 +16,21 @@ function concatTypedArray(type, elems, modulo) {
|
||||
ta_by_len[i] = items[i] = modulo === false ? i : elems % modulo;
|
||||
}
|
||||
var ta = new type(items);
|
||||
assert(
|
||||
compareArray([].concat(ta, ta), [ta, ta]),
|
||||
'compareArray([].concat(ta, ta), [ta, ta]) must return true'
|
||||
assert.compareArray(
|
||||
[].concat(ta, ta), [ta, ta],
|
||||
'[].concat(new type(items), new type(items)) must return [ta, ta]'
|
||||
);
|
||||
ta[Symbol.isConcatSpreadable] = true;
|
||||
assert.compareArray([].concat(ta), items, '[].concat(new type(items)) returns items');
|
||||
|
||||
assert(
|
||||
compareArray([].concat(ta_by_len, ta_by_len), [ta_by_len, ta_by_len]),
|
||||
'compareArray([].concat(ta_by_len, ta_by_len), [ta_by_len, ta_by_len]) must return true'
|
||||
assert.compareArray(
|
||||
[].concat(ta_by_len, ta_by_len), [ta_by_len, ta_by_len],
|
||||
'[].concat(new type(elems), new type(elems)) must return [ta_by_len, ta_by_len]'
|
||||
);
|
||||
ta_by_len[Symbol.isConcatSpreadable] = true;
|
||||
assert(
|
||||
compareArray([].concat(ta_by_len), items),
|
||||
'compareArray([].concat(ta_by_len), items) must return true'
|
||||
assert.compareArray(
|
||||
[].concat(ta_by_len), items,
|
||||
'[].concat(new type(elems)) returns items'
|
||||
);
|
||||
|
||||
// TypedArray with fake `length`.
|
||||
|
@ -31,18 +31,22 @@ info: |
|
||||
includes: [compareArray.js]
|
||||
---*/
|
||||
|
||||
assert(compareArray(
|
||||
['a', 'b', 'c', 'd', 'e', 'f'].copyWithin(0, 0), ['a', 'b', 'c', 'd', 'e', 'f']
|
||||
), 'compareArray( ["a", "b", "c", "d", "e", "f"].copyWithin(0, 0), ["a", "b", "c", "d", "e", "f"] ) must return true');
|
||||
assert.compareArray(
|
||||
['a', 'b', 'c', 'd', 'e', 'f'].copyWithin(0, 0), ['a', 'b', 'c', 'd', 'e', 'f'],
|
||||
'["a", "b", "c", "d", "e", "f"].copyWithin(0, 0) must return ["a", "b", "c", "d", "e", "f"]'
|
||||
);
|
||||
|
||||
assert(compareArray(
|
||||
['a', 'b', 'c', 'd', 'e', 'f'].copyWithin(0, 2), ['c', 'd', 'e', 'f', 'e', 'f']
|
||||
), 'compareArray( ["a", "b", "c", "d", "e", "f"].copyWithin(0, 2), ["c", "d", "e", "f", "e", "f"] ) must return true');
|
||||
assert.compareArray(
|
||||
['a', 'b', 'c', 'd', 'e', 'f'].copyWithin(0, 2), ['c', 'd', 'e', 'f', 'e', 'f'],
|
||||
'["a", "b", "c", "d", "e", "f"].copyWithin(0, 2) must return ["c", "d", "e", "f", "e", "f"]'
|
||||
);
|
||||
|
||||
assert(compareArray(
|
||||
['a', 'b', 'c', 'd', 'e', 'f'].copyWithin(3, 0), ['a', 'b', 'c', 'a', 'b', 'c']
|
||||
), 'compareArray( ["a", "b", "c", "d", "e", "f"].copyWithin(3, 0), ["a", "b", "c", "a", "b", "c"] ) must return true');
|
||||
assert.compareArray(
|
||||
['a', 'b', 'c', 'd', 'e', 'f'].copyWithin(3, 0), ['a', 'b', 'c', 'a', 'b', 'c'],
|
||||
'["a", "b", "c", "d", "e", "f"].copyWithin(3, 0) must return ["a", "b", "c", "a", "b", "c"]'
|
||||
);
|
||||
|
||||
assert(compareArray(
|
||||
[0, 1, 2, 3, 4, 5].copyWithin(1, 4), [0, 4, 5, 3, 4, 5]
|
||||
), 'compareArray( [0, 1, 2, 3, 4, 5].copyWithin(1, 4), [0, 4, 5, 3, 4, 5] ) must return true');
|
||||
assert.compareArray(
|
||||
[0, 1, 2, 3, 4, 5].copyWithin(1, 4), [0, 4, 5, 3, 4, 5],
|
||||
'[0, 1, 2, 3, 4, 5].copyWithin(1, 4) must return [0, 4, 5, 3, 4, 5]'
|
||||
);
|
||||
|
@ -34,9 +34,9 @@ Map.prototype.set = function(k, v) {
|
||||
|
||||
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[1], iterable[1]));
|
||||
assert.sameValue(_this[0], map);
|
||||
assert.sameValue(_this[1], map);
|
||||
assert.compareArray(results[0], iterable[0], 'The value of results[0] is expected to equal the value of iterable[0]');
|
||||
assert.compareArray(results[1], iterable[1], 'The value of results[1] is expected to equal the value of iterable[1]');
|
||||
assert.sameValue(_this[0], map, 'The value of _this[0] is expected to equal the value of map');
|
||||
assert.sameValue(_this[1], map, 'The value of _this[1] is expected to equal the value of map');
|
||||
|
@ -12,7 +12,6 @@ includes: [compareArray.js]
|
||||
var str = new String("abc");
|
||||
str[5] = "de";
|
||||
|
||||
var expected = ["0", "1", "2", "5", "length"];
|
||||
var actual = Object.getOwnPropertyNames(str);
|
||||
|
||||
assert(compareArray(actual, 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"]');
|
||||
|
@ -10,7 +10,6 @@ includes: [compareArray.js]
|
||||
---*/
|
||||
|
||||
var arr = [0, 1, 2];
|
||||
var expected = ["0", "1", "2", "length"];
|
||||
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"]');
|
||||
|
@ -36,6 +36,5 @@ Object.defineProperty(obj, "d", {
|
||||
});
|
||||
|
||||
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"]');
|
||||
|
@ -30,22 +30,22 @@ let sequence = [1];
|
||||
Promise.all([
|
||||
a.catch(() => {
|
||||
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.');
|
||||
}),
|
||||
Promise.race([a, b]).catch(() => {
|
||||
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.');
|
||||
}),
|
||||
b.catch(() => {
|
||||
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.');
|
||||
})
|
||||
]).then(result => {
|
||||
compareArray(result, [true, true, true]);
|
||||
assert.sameValue(sequence.length, 5);
|
||||
assert.compareArray(result, [true, true, true], 'The value of result is expected to be [true, true, true]');
|
||||
assert.sameValue(sequence.length, 5, 'The value of sequence.length is expected to be 5');
|
||||
checkSequence(sequence);
|
||||
}).then($DONE, $DONE);
|
||||
|
||||
|
@ -30,22 +30,22 @@ let sequence = [1];
|
||||
Promise.all([
|
||||
a.then(() => {
|
||||
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.');
|
||||
}),
|
||||
Promise.race([a, b]).then(() => {
|
||||
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.');
|
||||
}),
|
||||
b.then(() => {
|
||||
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.');
|
||||
})
|
||||
]).then(result => {
|
||||
compareArray(result, [true, true, true]);
|
||||
assert.sameValue(sequence.length, 5);
|
||||
assert.compareArray(result, [true, true, true], 'The value of result is expected to be [true, true, true]');
|
||||
assert.sameValue(sequence.length, 5, 'The value of sequence.length is expected to be 5');
|
||||
checkSequence(sequence)
|
||||
}).then($DONE, $DONE);
|
||||
sequence.push(2);
|
||||
|
@ -23,25 +23,25 @@ for (x in p) {
|
||||
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 = [];
|
||||
for (x of p) {
|
||||
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 next = itor.next();
|
||||
assert.sameValue(next.value, 1);
|
||||
assert.sameValue(next.done, false);
|
||||
assert.sameValue(next.value, 1, 'The value of next.value is expected to be 1');
|
||||
assert.sameValue(next.done, false, 'The value of next.done is expected to be false');
|
||||
next = itor.next();
|
||||
assert.sameValue(next.value, 2);
|
||||
assert.sameValue(next.done, false);
|
||||
assert.sameValue(next.value, 2, 'The value of next.value is expected to be 2');
|
||||
assert.sameValue(next.done, false, 'The value of next.done is expected to be false');
|
||||
next = itor.next();
|
||||
assert.sameValue(next.value, 3);
|
||||
assert.sameValue(next.done, false);
|
||||
assert.sameValue(next.value, 3, 'The value of next.value is expected to be 3');
|
||||
assert.sameValue(next.done, false, 'The value of next.done is expected to be false');
|
||||
next = itor.next();
|
||||
assert.sameValue(next.value, undefined);
|
||||
assert.sameValue(next.done, true);
|
||||
assert.sameValue(next.value, undefined, 'The value of next.value is expected to equal undefined');
|
||||
assert.sameValue(next.done, true, 'The value of next.done is expected to be true');
|
||||
|
@ -45,12 +45,12 @@ Object.defineProperty(o1, 'p', {
|
||||
|
||||
var result = Reflect.getOwnPropertyDescriptor(o1, 'p');
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
Object.getOwnPropertyNames(result), ['get', 'set', 'enumerable', 'configurable']
|
||||
)
|
||||
assert.compareArray(
|
||||
Object.getOwnPropertyNames(result),
|
||||
['get', 'set', 'enumerable', 'configurable'],
|
||||
'Object.getOwnPropertyNames(Reflect.getOwnPropertyDescriptor(o1, "p")) must return ["get", "set", "enumerable", "configurable"]'
|
||||
);
|
||||
assert.sameValue(result.enumerable, false);
|
||||
assert.sameValue(result.configurable, true);
|
||||
assert.sameValue(result.get, fn);
|
||||
assert.sameValue(result.set, undefined);
|
||||
assert.sameValue(result.enumerable, false, 'The value of result.enumerable is expected to be false');
|
||||
assert.sameValue(result.configurable, true, 'The value of result.configurable is expected to be true');
|
||||
assert.sameValue(result.get, fn, 'The value of result.get is expected to equal the value of fn');
|
||||
assert.sameValue(result.set, undefined, 'The value of result.set is expected to equal undefined');
|
||||
|
@ -21,12 +21,12 @@ var o1 = {
|
||||
|
||||
var result = Reflect.getOwnPropertyDescriptor(o1, 'p');
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
Object.getOwnPropertyNames(result), ['value', 'writable', 'enumerable', 'configurable']
|
||||
)
|
||||
assert.compareArray(
|
||||
Object.getOwnPropertyNames(result),
|
||||
['value', 'writable', 'enumerable', 'configurable'],
|
||||
'Object.getOwnPropertyNames(Reflect.getOwnPropertyDescriptor(o1, "p")) must return ["value", "writable", "enumerable", "configurable"]'
|
||||
);
|
||||
assert.sameValue(result.value, 'foo');
|
||||
assert.sameValue(result.enumerable, true);
|
||||
assert.sameValue(result.configurable, true);
|
||||
assert.sameValue(result.writable, true);
|
||||
assert.sameValue(result.value, 'foo', 'The value of result.value is expected to be "foo"');
|
||||
assert.sameValue(result.enumerable, true, 'The value of result.enumerable is expected to be true');
|
||||
assert.sameValue(result.configurable, true, 'The value of result.configurable is expected to be true');
|
||||
assert.sameValue(result.writable, true, 'The value of result.writable is expected to be true');
|
||||
|
@ -27,12 +27,12 @@ o[s] = 42;
|
||||
|
||||
var result = Reflect.getOwnPropertyDescriptor(o, s);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
Object.getOwnPropertyNames(result), ['value', 'writable', 'enumerable', 'configurable']
|
||||
)
|
||||
assert.compareArray(
|
||||
Object.getOwnPropertyNames(result),
|
||||
['value', 'writable', 'enumerable', 'configurable'],
|
||||
'Object.getOwnPropertyNames(Reflect.getOwnPropertyDescriptor(o, s)) must return ["value", "writable", "enumerable", "configurable"]'
|
||||
);
|
||||
assert.sameValue(result.value, 42);
|
||||
assert.sameValue(result.enumerable, true);
|
||||
assert.sameValue(result.configurable, true);
|
||||
assert.sameValue(result.writable, true);
|
||||
assert.sameValue(result.value, 42, 'The value of result.value is expected to be 42');
|
||||
assert.sameValue(result.enumerable, true, 'The value of result.enumerable is expected to be true');
|
||||
assert.sameValue(result.configurable, true, 'The value of result.configurable is expected to be true');
|
||||
assert.sameValue(result.writable, true, 'The value of result.writable is expected to be true');
|
||||
|
@ -23,7 +23,4 @@ var o = Object.create(proto);
|
||||
o.p1 = 42;
|
||||
o.p2 = 43;
|
||||
o.p3 = 44;
|
||||
assert(
|
||||
compareArray(Reflect.ownKeys(o), ['p1', 'p2', 'p3']),
|
||||
'return object own keys'
|
||||
);
|
||||
assert.compareArray(Reflect.ownKeys(o), ['p1', 'p2', 'p3'], 'Reflect.ownKeys(Object.create(proto)) must return ["p1", "p2", "p3"]');
|
||||
|
@ -15,10 +15,10 @@ includes: [compareArray.js]
|
||||
features: [Reflect]
|
||||
---*/
|
||||
|
||||
assert(compareArray(Reflect.ownKeys({}), []));
|
||||
assert.compareArray(Reflect.ownKeys({}), [], 'Reflect.ownKeys({}) must return []');
|
||||
|
||||
var o = {
|
||||
d: 42
|
||||
};
|
||||
delete o.d;
|
||||
assert(compareArray(Reflect.ownKeys(o), []));
|
||||
assert.compareArray(Reflect.ownKeys(o), [], 'Reflect.ownKeys({d: 42}) must return []');
|
||||
|
@ -15,14 +15,14 @@ includes: [compareArray.js]
|
||||
features: [Reflect]
|
||||
---*/
|
||||
|
||||
assert(
|
||||
compareArray(Reflect.ownKeys([]), ['length']),
|
||||
'return non enumerable `length` from empty array'
|
||||
assert.compareArray(
|
||||
Reflect.ownKeys([]), ['length'],
|
||||
'Reflect.ownKeys([]) must return ["length"]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(Reflect.ownKeys([, , 2]), ['2', 'length']),
|
||||
'return array keys'
|
||||
assert.compareArray(
|
||||
Reflect.ownKeys([, , 2]), ['2', 'length'],
|
||||
'Reflect.ownKeys([, , 2]) must return ["2", "length"]'
|
||||
);
|
||||
|
||||
var o = {};
|
||||
@ -35,4 +35,4 @@ Object.defineProperty(o, 'p2', {
|
||||
enumerable: false
|
||||
});
|
||||
|
||||
assert(compareArray(Reflect.ownKeys(o), ['p1', 'p2']));
|
||||
assert.compareArray(Reflect.ownKeys(o), ['p1', 'p2'], 'Reflect.ownKeys({}) must return ["p1", "p2"]');
|
||||
|
@ -15,16 +15,15 @@ info: |
|
||||
---*/
|
||||
|
||||
// Properties created on result.groups in textual order.
|
||||
assert(compareArray(["fst", "snd"],
|
||||
Object.getOwnPropertyNames(
|
||||
/(?<fst>.)|(?<snd>.)/u.exec("abcd").groups)));
|
||||
assert.compareArray(["fst", "snd"], 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)');
|
||||
|
||||
// Properties are created with Define, not Set
|
||||
let counter = 0;
|
||||
Object.defineProperty(Object.prototype, 'x', {set() { counter++; }});
|
||||
let match = /(?<x>.)/.exec('a');
|
||||
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
|
||||
// (from CreateDataProperty)
|
||||
|
@ -9,38 +9,125 @@ includes: [compareArray.js]
|
||||
---*/
|
||||
|
||||
// Unicode mode
|
||||
assert(compareArray(["f", "c"], "abcdef".match(/(?<=(?<a>\w){3})f/u)));
|
||||
assert.sameValue("c", "abcdef".match(/(?<=(?<a>\w){3})f/u).groups.a);
|
||||
assert.sameValue("b", "abcdef".match(/(?<=(?<a>\w){4})f/u).groups.a);
|
||||
assert.sameValue("a", "abcdef".match(/(?<=(?<a>\w)+)f/u).groups.a);
|
||||
assert.sameValue(null, "abcdef".match(/(?<=(?<a>\w){6})f/u));
|
||||
assert.compareArray(
|
||||
["f", "c"],
|
||||
"abcdef".match(/(?<=(?<a>\w){3})f/u),
|
||||
'["f", "c"] must return the same value returned by "abcdef".match(/(?<=(?<a>w){3})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(["f", ""], "abcdef".match(/(?<a>(?<=\w{3}))f/u)));
|
||||
assert.compareArray(
|
||||
["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.sameValue(null, "abcdef".match(/(?<!(?<a>\D){3})f/u));
|
||||
assert.compareArray(
|
||||
["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(["f", undefined], "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)'
|
||||
);
|
||||
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
|
||||
assert(compareArray(["f", "c"], "abcdef".match(/(?<=(?<a>\w){3})f/)));
|
||||
assert.sameValue("c", "abcdef".match(/(?<=(?<a>\w){3})f/).groups.a);
|
||||
assert.sameValue("b", "abcdef".match(/(?<=(?<a>\w){4})f/).groups.a);
|
||||
assert.sameValue("a", "abcdef".match(/(?<=(?<a>\w)+)f/).groups.a);
|
||||
assert.sameValue(null, "abcdef".match(/(?<=(?<a>\w){6})f/));
|
||||
assert.compareArray(
|
||||
["f", "c"],
|
||||
"abcdef".match(/(?<=(?<a>\w){3})f/),
|
||||
'["f", "c"] must return the same value returned by "abcdef".match(/(?<=(?<a>w){3})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(["f", ""], "abcdef".match(/(?<a>(?<=\w{3}))f/)));
|
||||
assert.compareArray(
|
||||
["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.sameValue(null, "abcdef".match(/(?<!(?<a>\D){3})f/));
|
||||
assert.compareArray(
|
||||
["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(["f", undefined], "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/)'
|
||||
);
|
||||
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
|
||||
assert(compareArray(["fst", "snd"],
|
||||
Object.getOwnPropertyNames(
|
||||
/(?<=(?<fst>.)|(?<snd>.))/u.exec("abcd").groups)));
|
||||
assert.compareArray(["fst", "snd"], 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)');
|
||||
|
@ -8,36 +8,135 @@ features: [regexp-named-groups]
|
||||
includes: [compareArray.js]
|
||||
---*/
|
||||
|
||||
assert(compareArray(["a", "a"], "bab".match(/(?<a>a)/)));
|
||||
assert(compareArray(["a", "a"], "bab".match(/(?<a42>a)/)));
|
||||
assert(compareArray(["a", "a"], "bab".match(/(?<_>a)/)));
|
||||
assert(compareArray(["a", "a"], "bab".match(/(?<$>a)/)));
|
||||
assert(compareArray(["bab", "a"], "bab".match(/.(?<$>a)./)));
|
||||
assert(compareArray(["bab", "a", "b"], "bab".match(/.(?<a>a)(.)/)));
|
||||
assert(compareArray(["bab", "a", "b"], "bab".match(/.(?<a>a)(?<b>.)/)));
|
||||
assert(compareArray(["bab", "ab"], "bab".match(/.(?<a>\w\w)/)));
|
||||
assert(compareArray(["bab", "bab"], "bab".match(/(?<a>\w\w\w)/)));
|
||||
assert(compareArray(["bab", "ba", "b"], "bab".match(/(?<a>\w\w)(?<b>\w)/)));
|
||||
assert.compareArray(
|
||||
"bab".match(/(?<a>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(/(?<a42>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)/),
|
||||
["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;
|
||||
assert.sameValue(a, "a");
|
||||
assert.sameValue(b, "b");
|
||||
assert.sameValue(c, "c");
|
||||
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.sameValue(c, "c", 'The value of c is expected to be "c"');
|
||||
|
||||
assert(compareArray("bab".match(/(a)/), "bab".match(/(?<a>a)/)));
|
||||
assert(compareArray("bab".match(/(a)/), "bab".match(/(?<a42>a)/)));
|
||||
assert(compareArray("bab".match(/(a)/), "bab".match(/(?<_>a)/)));
|
||||
assert(compareArray("bab".match(/(a)/), "bab".match(/(?<$>a)/)));
|
||||
assert(compareArray("bab".match(/.(a)./), "bab".match(/.(?<$>a)./)));
|
||||
assert(compareArray("bab".match(/.(a)(.)/), "bab".match(/.(?<a>a)(.)/)));
|
||||
assert(compareArray("bab".match(/.(a)(.)/), "bab".match(/.(?<a>a)(?<b>.)/)));
|
||||
assert(compareArray("bab".match(/.(\w\w)/), "bab".match(/.(?<a>\w\w)/)));
|
||||
assert(compareArray("bab".match(/(\w\w\w)/), "bab".match(/(?<a>\w\w\w)/)));
|
||||
assert(compareArray("bab".match(/(\w\w)(\w)/), "bab".match(/(?<a>\w\w)(?<b>\w)/)));
|
||||
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(/(?<a42>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)./),
|
||||
"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(["baba", "b", "a"], "baba".match(/(.)(?<a>a)\1\2/)));
|
||||
assert(compareArray(["baba", "b", "a", "b", "a"],
|
||||
"baba".match(/(.)(?<a>a)(?<b>\1)(\2)/)));
|
||||
assert(compareArray(["<a", "<"], "<a".match(/(?<lt><)a/)));
|
||||
assert(compareArray([">a", ">"], ">a".match(/(?<gt>>)a/)));
|
||||
assert.compareArray(
|
||||
"bab".match(/(?<b>b).\1/),
|
||||
["bab", "b"],
|
||||
'"bab".match("/(?<a>.)(?<b>.)(?<c>.)k<c>k<b>k<a>/.exec("abccba").groups") must return ["bab", "b"]'
|
||||
);
|
||||
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", ">"]'
|
||||
);
|
||||
|
@ -9,26 +9,78 @@ includes: [compareArray.js]
|
||||
---*/
|
||||
|
||||
// Named references.
|
||||
assert(compareArray(["bab", "b"], "bab".match(/(?<b>.).\k<b>/)));
|
||||
assert.sameValue(null, "baa".match(/(?<b>.).\k<b>/));
|
||||
assert.compareArray(
|
||||
"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.
|
||||
assert(compareArray(["bab", "b"], "bab".match(/(?<a>\k<a>\w)../)));
|
||||
assert.sameValue("b", "bab".match(/(?<a>\k<a>\w)../).groups.a);
|
||||
assert.compareArray(
|
||||
"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.
|
||||
assert(compareArray(["bab", "b"], "bab".match(/\k<a>(?<a>b)\w\k<a>/)));
|
||||
assert.sameValue("b", "bab".match(/\k<a>(?<a>b)\w\k<a>/).groups.a);
|
||||
assert(compareArray(["bab", "b", "a"], "bab".match(/(?<b>b)\k<a>(?<a>a)\k<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>/).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;
|
||||
assert.sameValue(a, "a");
|
||||
assert.sameValue(b, "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", "b"], "bab".match(/\k<a>(?<a>b)\w\k<a>/)));
|
||||
assert(compareArray(["bab", "b", "a"], "bab".match(/(?<b>b)\k<a>(?<a>a)\k<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>/).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.
|
||||
assert.sameValue("a", /(?<a>a)(?<b>b)\k<a>/.exec("aba").groups.a);
|
||||
assert.sameValue("b", /(?<a>a)(?<b>b)\k<a>/.exec("aba").groups.b);
|
||||
assert.sameValue(undefined, /(?<a>a)(?<b>b)\k<a>/.exec("aba").groups.c);
|
||||
assert.sameValue(undefined, /(?<a>a)(?<b>b)\k<a>|(?<c>c)/.exec("aba").groups.c);
|
||||
assert.sameValue(
|
||||
/(?<a>a)(?<b>b)\k<a>/.exec("aba").groups.a,
|
||||
"a",
|
||||
'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'
|
||||
);
|
||||
|
@ -8,41 +8,149 @@ features: [regexp-named-groups]
|
||||
includes: [compareArray.js]
|
||||
---*/
|
||||
|
||||
assert(compareArray(["a", "a"], "bab".match(/(?<a>a)/u)));
|
||||
assert(compareArray(["a", "a"], "bab".match(/(?<a42>a)/u)));
|
||||
assert(compareArray(["a", "a"], "bab".match(/(?<_>a)/u)));
|
||||
assert(compareArray(["a", "a"], "bab".match(/(?<$>a)/u)));
|
||||
assert(compareArray(["bab", "a"], "bab".match(/.(?<$>a)./u)));
|
||||
assert(compareArray(["bab", "a", "b"], "bab".match(/.(?<a>a)(.)/u)));
|
||||
assert(compareArray(["bab", "a", "b"], "bab".match(/.(?<a>a)(?<b>.)/u)));
|
||||
assert(compareArray(["bab", "ab"], "bab".match(/.(?<a>\w\w)/u)));
|
||||
assert(compareArray(["bab", "bab"], "bab".match(/(?<a>\w\w\w)/u)));
|
||||
assert(compareArray(["bab", "ba", "b"], "bab".match(/(?<a>\w\w)(?<b>\w)/u)));
|
||||
assert.compareArray(
|
||||
"bab".match(/(?<a>a)/u),
|
||||
["a", "a"],
|
||||
'"bab".match(""bab".match(/(?<a>.(?<b>.(?<c>.)))/u).groups") must return ["a", "a"]'
|
||||
);
|
||||
assert.compareArray(
|
||||
"bab".match(/(?<a42>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),
|
||||
["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;
|
||||
assert.sameValue(a, "a");
|
||||
assert.sameValue(b, "b");
|
||||
assert.sameValue(c, "c");
|
||||
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.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("bab".match(/(a)/u), "bab".match(/(?<a42>a)/u)));
|
||||
assert(compareArray("bab".match(/(a)/u), "bab".match(/(?<_>a)/u)));
|
||||
assert(compareArray("bab".match(/(a)/u), "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("bab".match(/.(a)(.)/u), "bab".match(/.(?<a>a)(?<b>.)/u)));
|
||||
assert(compareArray("bab".match(/.(\w\w)/u), "bab".match(/.(?<a>\w\w)/u)));
|
||||
assert(compareArray("bab".match(/(\w\w\w)/u), "bab".match(/(?<a>\w\w\w)/u)));
|
||||
assert(compareArray("bab".match(/(\w\w)(\w)/u), "bab".match(/(?<a>\w\w)(?<b>\w)/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(/(?<a42>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)./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(["baba", "b", "a"], "baba".match(/(.)(?<a>a)\1\2/u)));
|
||||
assert(compareArray(["baba", "b", "a", "b", "a"],
|
||||
"baba".match(/(.)(?<a>a)(?<b>\1)(\2)/u)));
|
||||
assert(compareArray(["<a", "<"], "<a".match(/(?<lt><)a/u)));
|
||||
assert(compareArray([">a", ">"], ">a".match(/(?<gt>>)a/u)));
|
||||
assert.compareArray(
|
||||
"bab".match(/(?<b>b).\1/u),
|
||||
["bab", "b"],
|
||||
'"bab".match("/(?<a>.)(?<b>.)(?<c>.)k<c>k<b>k<a>/u.exec("abccba").groups") must return ["bab", "b"]'
|
||||
);
|
||||
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.
|
||||
assert(compareArray(["bab", "bab", "ab", "b"], "bab".match(/(?<a>.(?<b>.(?<c>.)))/u)));
|
||||
assert(compareArray({a: "bab", b: "ab", c: "b"},
|
||||
"bab".match(/(?<a>.(?<b>.(?<c>.)))/u).groups));
|
||||
assert.compareArray(
|
||||
"bab".match(/(?<a>.(?<b>.(?<c>.)))/u),
|
||||
["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"');
|
||||
}
|
||||
|
@ -22,26 +22,79 @@ includes: [compareArray.js]
|
||||
---*/
|
||||
|
||||
// Named references.
|
||||
assert(compareArray(["bab", "b"], "bab".match(/(?<b>.).\k<b>/u)));
|
||||
assert.sameValue(null, "baa".match(/(?<b>.).\k<b>/u));
|
||||
assert.compareArray(
|
||||
"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.
|
||||
assert(compareArray(["bab", "b"], "bab".match(/(?<a>\k<a>\w)../u)));
|
||||
assert.sameValue("b", "bab".match(/(?<a>\k<a>\w)../u).groups.a);
|
||||
assert.compareArray(
|
||||
"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.
|
||||
assert(compareArray(["bab", "b"], "bab".match(/\k<a>(?<a>b)\w\k<a>/u)));
|
||||
assert.sameValue("b", "bab".match(/\k<a>(?<a>b)\w\k<a>/u).groups.a);
|
||||
assert(compareArray(["bab", "b", "a"], "bab".match(/(?<b>b)\k<a>(?<a>a)\k<b>/u)));
|
||||
let {a, b} = "bab".match(/(?<b>b)\k<a>(?<a>a)\k<b>/u).groups;
|
||||
assert.sameValue(a, "a");
|
||||
assert.sameValue(b, "b");
|
||||
assert.compareArray(
|
||||
"bab".match(/\k<a>(?<a>b)\w\k<a>/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(/\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>/)));
|
||||
assert(compareArray(["bab", "b", "a"], "bab".match(/(?<b>b)\k<a>(?<a>a)\k<b>/)));
|
||||
let {a, b} = "bab".match(/(?<b>b)\k<a>(?<a>a)\k<b>/u).groups;
|
||||
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.
|
||||
assert.sameValue("a", /(?<a>a)(?<b>b)\k<a>/u.exec("aba").groups.a);
|
||||
assert.sameValue("b", /(?<a>a)(?<b>b)\k<a>/u.exec("aba").groups.b);
|
||||
assert.sameValue(undefined, /(?<a>a)(?<b>b)\k<a>/u.exec("aba").groups.c);
|
||||
assert.sameValue(undefined, /(?<a>a)(?<b>b)\k<a>|(?<c>c)/u.exec("aba").groups.c);
|
||||
assert.sameValue(
|
||||
/(?<a>a)(?<b>b)\k<a>/u.exec("aba").groups.a,
|
||||
"a",
|
||||
'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'
|
||||
);
|
||||
|
@ -25,7 +25,7 @@ const fields = {
|
||||
}
|
||||
}
|
||||
}
|
||||
assert(
|
||||
compareArray(cal.fields(fields), Array.from(fields)),
|
||||
'compareArray(cal.fields(fields), Array.from(fields)) must return true'
|
||||
assert.compareArray(
|
||||
cal.fields(fields), Array.from(fields),
|
||||
'cal.fields("{*[Symbol.iterator]() {let i = 0; while (i++ < 1000001) {yield "garbage " + i;}}}) must return the same value returned by Array.from(fields)'
|
||||
);
|
||||
|
@ -25,53 +25,40 @@ info: |
|
||||
includes: [compareArray.js, testBigIntTypedArray.js]
|
||||
features: [BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, null),
|
||||
[0n, 1n, 2n, 3n]
|
||||
),
|
||||
'null value coerced to 0'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, null),
|
||||
[0n, 1n, 2n, 3n],
|
||||
'new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, null) must return [0n, 1n, 2n, 3n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, NaN),
|
||||
[0n, 1n, 2n, 3n]
|
||||
),
|
||||
'NaN value coerced to 0'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, NaN),
|
||||
[0n, 1n, 2n, 3n],
|
||||
'new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, NaN) must return [0n, 1n, 2n, 3n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, false),
|
||||
[0n, 1n, 2n, 3n]
|
||||
),
|
||||
'false value coerced to 0'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, false),
|
||||
[0n, 1n, 2n, 3n],
|
||||
'new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, false) must return [0n, 1n, 2n, 3n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, true),
|
||||
[0n, 0n, 2n, 3n]
|
||||
),
|
||||
'true value coerced to 1'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, true),
|
||||
[0n, 0n, 2n, 3n],
|
||||
'new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, true) must return [0n, 0n, 2n, 3n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, '-2'),
|
||||
[0n, 0n, 1n, 3n]
|
||||
),
|
||||
'string "-2" value coerced to integer -2'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, '-2'),
|
||||
[0n, 0n, 1n, 3n],
|
||||
'new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, "-2") must return [0n, 0n, 1n, 3n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, -2.5),
|
||||
[0n, 0n, 1n, 3n]
|
||||
),
|
||||
'float -2.5 value coerced to integer -2'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, -2.5),
|
||||
[0n, 0n, 1n, 3n],
|
||||
'new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, -2.5) must return [0n, 0n, 1n, 3n]'
|
||||
);
|
||||
});
|
||||
|
@ -24,69 +24,52 @@ info: |
|
||||
includes: [compareArray.js, testBigIntTypedArray.js]
|
||||
features: [BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(1, undefined),
|
||||
[0n, 0n, 1n, 2n]
|
||||
),
|
||||
'undefined value coerced to 0'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(1, undefined),
|
||||
[0n, 0n, 1n, 2n],
|
||||
'new TA([0n, 1n, 2n, 3n]).copyWithin(1, undefined) must return [0n, 0n, 1n, 2n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(1, false),
|
||||
[0n, 0n, 1n, 2n]
|
||||
),
|
||||
'false value coerced to 0'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(1, false),
|
||||
[0n, 0n, 1n, 2n],
|
||||
'new TA([0n, 1n, 2n, 3n]).copyWithin(1, false) must return [0n, 0n, 1n, 2n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(1, NaN),
|
||||
[0n, 0n, 1n, 2n]
|
||||
),
|
||||
'NaN value coerced to 0'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(1, NaN),
|
||||
[0n, 0n, 1n, 2n],
|
||||
'new TA([0n, 1n, 2n, 3n]).copyWithin(1, NaN) must return [0n, 0n, 1n, 2n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(1, null),
|
||||
[0n, 0n, 1n, 2n]
|
||||
),
|
||||
'null value coerced to 0'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(1, null),
|
||||
[0n, 0n, 1n, 2n],
|
||||
'new TA([0n, 1n, 2n, 3n]).copyWithin(1, null) must return [0n, 0n, 1n, 2n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(0, true),
|
||||
[1n, 2n, 3n, 3n]
|
||||
),
|
||||
'true value coerced to 1'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(0, true),
|
||||
[1n, 2n, 3n, 3n],
|
||||
'new TA([0n, 1n, 2n, 3n]).copyWithin(0, true) must return [1n, 2n, 3n, 3n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(0, '1'),
|
||||
[1n, 2n, 3n, 3n]
|
||||
),
|
||||
'string "1" value coerced to 1'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(0, '1'),
|
||||
[1n, 2n, 3n, 3n],
|
||||
'new TA([0n, 1n, 2n, 3n]).copyWithin(0, "1") must return [1n, 2n, 3n, 3n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0.5),
|
||||
[0n, 0n, 1n, 2n]
|
||||
),
|
||||
'0.5 float value coerced to integer 0'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0.5),
|
||||
[0n, 0n, 1n, 2n],
|
||||
'new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0.5) must return [0n, 0n, 1n, 2n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1.5),
|
||||
[1n, 2n, 3n, 3n]
|
||||
),
|
||||
'1.5 float value coerced to integer 1'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1.5),
|
||||
[1n, 2n, 3n, 3n],
|
||||
'new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1.5) must return [1n, 2n, 3n, 3n]'
|
||||
);
|
||||
});
|
||||
|
@ -24,69 +24,52 @@ info: |
|
||||
includes: [compareArray.js, testBigIntTypedArray.js]
|
||||
features: [BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(undefined, 1),
|
||||
[1n, 2n, 3n, 3n]
|
||||
),
|
||||
'undefined value coerced to 0'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(undefined, 1),
|
||||
[1n, 2n, 3n, 3n],
|
||||
'new TA([0n, 1n, 2n, 3n]).copyWithin(undefined, 1) must return [1n, 2n, 3n, 3n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(false, 1),
|
||||
[1n, 2n, 3n, 3n]
|
||||
),
|
||||
'false value coerced to 0'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(false, 1),
|
||||
[1n, 2n, 3n, 3n],
|
||||
'new TA([0n, 1n, 2n, 3n]).copyWithin(false, 1) must return [1n, 2n, 3n, 3n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(NaN, 1),
|
||||
[1n, 2n, 3n, 3n]
|
||||
),
|
||||
'NaN value coerced to 0'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(NaN, 1),
|
||||
[1n, 2n, 3n, 3n],
|
||||
'new TA([0n, 1n, 2n, 3n]).copyWithin(NaN, 1) must return [1n, 2n, 3n, 3n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(null, 1),
|
||||
[1n, 2n, 3n, 3n]
|
||||
),
|
||||
'null value coerced to 0'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(null, 1),
|
||||
[1n, 2n, 3n, 3n],
|
||||
'new TA([0n, 1n, 2n, 3n]).copyWithin(null, 1) must return [1n, 2n, 3n, 3n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(true, 0),
|
||||
[0n, 0n, 1n, 2n]
|
||||
),
|
||||
'true value coerced to 1'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(true, 0),
|
||||
[0n, 0n, 1n, 2n],
|
||||
'new TA([0n, 1n, 2n, 3n]).copyWithin(true, 0) must return [0n, 0n, 1n, 2n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin('1', 0),
|
||||
[0n, 0n, 1n, 2n]
|
||||
),
|
||||
'string "1" value coerced to 1'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin('1', 0),
|
||||
[0n, 0n, 1n, 2n],
|
||||
'new TA([0n, 1n, 2n, 3n]).copyWithin("1", 0) must return [0n, 0n, 1n, 2n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(0.5, 1),
|
||||
[1n, 2n, 3n, 3n]
|
||||
),
|
||||
'0.5 float value coerced to integer 0'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(0.5, 1),
|
||||
[1n, 2n, 3n, 3n],
|
||||
'new TA([0n, 1n, 2n, 3n]).copyWithin(0.5, 1) must return [1n, 2n, 3n, 3n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(1.5, 0),
|
||||
[0n, 0n, 1n, 2n]
|
||||
),
|
||||
'1.5 float value coerced to integer 1'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(1.5, 0),
|
||||
[0n, 0n, 1n, 2n],
|
||||
'new TA([0n, 1n, 2n, 3n]).copyWithin(1.5, 0) must return [0n, 0n, 1n, 2n]'
|
||||
);
|
||||
});
|
||||
|
@ -27,69 +27,52 @@ info: |
|
||||
includes: [compareArray.js, testBigIntTypedArray.js]
|
||||
features: [BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1, -1),
|
||||
[1n, 2n, 2n, 3n]
|
||||
),
|
||||
'[0, 1, 2, 3].copyWithin(0, 1, -1) -> [1, 2, 2, 3]'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1, -1),
|
||||
[1n, 2n, 2n, 3n],
|
||||
'new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1, -1) must return [1n, 2n, 2n, 3n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(2, 0, -1),
|
||||
[0n, 1n, 0n, 1n, 2n]
|
||||
),
|
||||
'[0, 1, 2, 3, 4].copyWithin(2, 0, -1) -> [0, 1, 0, 1, 2]'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(2, 0, -1),
|
||||
[0n, 1n, 0n, 1n, 2n],
|
||||
'new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(2, 0, -1) must return [0n, 1n, 0n, 1n, 2n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(1, 2, -2),
|
||||
[0n, 2n, 2n, 3n, 4n]
|
||||
),
|
||||
'[0, 1, 2, 3, 4].copyWithin(1, 2, -2) -> [0, 2, 2, 3, 4]'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(1, 2, -2),
|
||||
[0n, 2n, 2n, 3n, 4n],
|
||||
'new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(1, 2, -2) must return [0n, 2n, 2n, 3n, 4n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(0, -2, -1),
|
||||
[2n, 1n, 2n, 3n]
|
||||
),
|
||||
'[0, 1, 2, 3].copyWithin(0, -2, -1) -> [2, 1, 2, 3]'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(0, -2, -1),
|
||||
[2n, 1n, 2n, 3n],
|
||||
'new TA([0n, 1n, 2n, 3n]).copyWithin(0, -2, -1) must return [2n, 1n, 2n, 3n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(2, -2, -1),
|
||||
[0n, 1n, 3n, 3n, 4n]
|
||||
),
|
||||
'[0, 1, 2, 3, 4].copyWithin(2, -2, 1) -> [0, 1, 3, 3, 4]'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(2, -2, -1),
|
||||
[0n, 1n, 3n, 3n, 4n],
|
||||
'new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(2, -2, -1) must return [0n, 1n, 3n, 3n, 4n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(-3, -2, -1),
|
||||
[0n, 2n, 2n, 3n]
|
||||
),
|
||||
'[0, 1, 2, 3].copyWithin(-3, -2, -1) -> [0, 2, 2, 3]'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(-3, -2, -1),
|
||||
[0n, 2n, 2n, 3n],
|
||||
'new TA([0n, 1n, 2n, 3n]).copyWithin(-3, -2, -1) must return [0n, 2n, 2n, 3n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-2, -3, -1),
|
||||
[0n, 1n, 2n, 2n, 3n]
|
||||
),
|
||||
'[0, 1, 2, 3, 4].copyWithin(-2, -3, -1) -> [0, 1, 2, 2, 3]'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-2, -3, -1),
|
||||
[0n, 1n, 2n, 2n, 3n],
|
||||
'new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-2, -3, -1) must return [0n, 1n, 2n, 2n, 3n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-5, -2, -1),
|
||||
[3n, 1n, 2n, 3n, 4n]
|
||||
),
|
||||
'[0, 1, 2, 3, 4].copyWithin(-5, -2, -1) -> [3, 1, 2, 3, 4]'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-5, -2, -1),
|
||||
[3n, 1n, 2n, 3n, 4n],
|
||||
'new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-5, -2, -1) must return [3n, 1n, 2n, 3n, 4n]'
|
||||
);
|
||||
});
|
||||
|
@ -27,85 +27,64 @@ info: |
|
||||
includes: [compareArray.js, testBigIntTypedArray.js]
|
||||
features: [BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1, -10),
|
||||
[0n, 1n, 2n, 3n]
|
||||
),
|
||||
'[0, 1, 2, 3].copyWithin(0, 1, -10) -> [0, 1, 2, 3]'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1, -10),
|
||||
[0n, 1n, 2n, 3n],
|
||||
'new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1, -10) must return [0n, 1n, 2n, 3n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, 1, -Infinity),
|
||||
[1n, 2n, 3n, 4n, 5n]
|
||||
),
|
||||
'[1, 2, 3, 4, 5].copyWithin(0, 1, -Infinity) -> [1, 2, 3, 4, 5]'
|
||||
assert.compareArray(
|
||||
new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, 1, -Infinity),
|
||||
[1n, 2n, 3n, 4n, 5n],
|
||||
'new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, 1, -Infinity) must return [1n, 2n, 3n, 4n, 5n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(0, -2, -10),
|
||||
[0n, 1n, 2n, 3n]
|
||||
),
|
||||
'[0, 1, 2, 3].copyWithin(0, -2, -10) -> [0, 1, 2, 3]'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(0, -2, -10),
|
||||
[0n, 1n, 2n, 3n],
|
||||
'new TA([0n, 1n, 2n, 3n]).copyWithin(0, -2, -10) must return [0n, 1n, 2n, 3n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, -2, -Infinity),
|
||||
[1n, 2n, 3n, 4n, 5n]
|
||||
),
|
||||
'[1, 2, 3, 4, 5].copyWithin(0, -2, -Infinity) -> [1, 2, 3, 4, 5]'
|
||||
assert.compareArray(
|
||||
new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, -2, -Infinity),
|
||||
[1n, 2n, 3n, 4n, 5n],
|
||||
'new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, -2, -Infinity) must return [1n, 2n, 3n, 4n, 5n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(0, -9, -10),
|
||||
[0n, 1n, 2n, 3n]
|
||||
),
|
||||
'[0, 1, 2, 3].copyWithin(0, -9, -10) -> [0, 1, 2, 3]'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(0, -9, -10),
|
||||
[0n, 1n, 2n, 3n],
|
||||
'new TA([0n, 1n, 2n, 3n]).copyWithin(0, -9, -10) must return [0n, 1n, 2n, 3n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, -9, -Infinity),
|
||||
[1n, 2n, 3n, 4n, 5n]
|
||||
),
|
||||
'[1, 2, 3, 4, 5].copyWithin(0, -9, -Infinity) -> [1, 2, 3, 4, 5]'
|
||||
assert.compareArray(
|
||||
new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, -9, -Infinity),
|
||||
[1n, 2n, 3n, 4n, 5n],
|
||||
'new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, -9, -Infinity) must return [1n, 2n, 3n, 4n, 5n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(-3, -2, -10),
|
||||
[0n, 1n, 2n, 3n]
|
||||
),
|
||||
'[0, 1, 2, 3].copyWithin(-3, -2, -10) -> [0, 1, 2, 3]'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(-3, -2, -10),
|
||||
[0n, 1n, 2n, 3n],
|
||||
'new TA([0n, 1n, 2n, 3n]).copyWithin(-3, -2, -10) must return [0n, 1n, 2n, 3n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(-3, -2, -Infinity),
|
||||
[1n, 2n, 3n, 4n, 5n]
|
||||
),
|
||||
'[1, 2, 3, 4, 5].copyWithin(-3, -2, -Infinity) -> [1, 2, 3, 4, 5]'
|
||||
assert.compareArray(
|
||||
new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(-3, -2, -Infinity),
|
||||
[1n, 2n, 3n, 4n, 5n],
|
||||
'new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(-3, -2, -Infinity) must return [1n, 2n, 3n, 4n, 5n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(-7, -8, -9),
|
||||
[0n, 1n, 2n, 3n]
|
||||
),
|
||||
'[0, 1, 2, 3].copyWithin(-7, -8, -9) -> [0, 1, 2, 3]'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(-7, -8, -9),
|
||||
[0n, 1n, 2n, 3n],
|
||||
'new TA([0n, 1n, 2n, 3n]).copyWithin(-7, -8, -9) must return [0n, 1n, 2n, 3n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(-7, -8, -Infinity),
|
||||
[1n, 2n, 3n, 4n, 5n]
|
||||
),
|
||||
'[1, 2, 3, 4, 5].copyWithin(-7, -8, -Infinity) -> [1, 2, 3, 4, 5]'
|
||||
assert.compareArray(
|
||||
new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(-7, -8, -Infinity),
|
||||
[1n, 2n, 3n, 4n, 5n],
|
||||
'new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(-7, -8, -Infinity) must return [1n, 2n, 3n, 4n, 5n]'
|
||||
);
|
||||
});
|
||||
|
@ -25,69 +25,52 @@ info: |
|
||||
includes: [compareArray.js, testBigIntTypedArray.js]
|
||||
features: [BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(0, -10),
|
||||
[0n, 1n, 2n, 3n]
|
||||
),
|
||||
'[0, 1, 2, 3]).copyWithin(0, -10) -> [0, 1, 2, 3]'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(0, -10),
|
||||
[0n, 1n, 2n, 3n],
|
||||
'new TA([0n, 1n, 2n, 3n]).copyWithin(0, -10) must return [0n, 1n, 2n, 3n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, -Infinity),
|
||||
[1n, 2n, 3n, 4n, 5n]
|
||||
),
|
||||
'[1, 2, 3, 4, 5]).copyWithin(0, -Infinity) -> [1, 2, 3, 4, 5]'
|
||||
assert.compareArray(
|
||||
new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, -Infinity),
|
||||
[1n, 2n, 3n, 4n, 5n],
|
||||
'new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, -Infinity) must return [1n, 2n, 3n, 4n, 5n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(2, -10),
|
||||
[0n, 1n, 0n, 1n, 2n]
|
||||
),
|
||||
'[0, 1, 2, 3, 4]).copyWithin(2, -2) -> [0, 1, 0, 1, 2]'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(2, -10),
|
||||
[0n, 1n, 0n, 1n, 2n],
|
||||
'new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(2, -10) must return [0n, 1n, 0n, 1n, 2n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(2, -Infinity),
|
||||
[1n, 2n, 1n, 2n, 3n]
|
||||
),
|
||||
'[1, 2, 3, 4, 5]).copyWithin(2, -Infinity) -> [1, 2, 1, 2, 3]'
|
||||
assert.compareArray(
|
||||
new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(2, -Infinity),
|
||||
[1n, 2n, 1n, 2n, 3n],
|
||||
'new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(2, -Infinity) must return [1n, 2n, 1n, 2n, 3n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(10, -10),
|
||||
[0n, 1n, 2n, 3n, 4n]
|
||||
),
|
||||
'[0, 1, 2, 3, 4]).copyWithin(10, -10) -> [0, 1, 2, 3, 4]'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(10, -10),
|
||||
[0n, 1n, 2n, 3n, 4n],
|
||||
'new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(10, -10) must return [0n, 1n, 2n, 3n, 4n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(10, -Infinity),
|
||||
[1n, 2n, 3n, 4n, 5n]
|
||||
),
|
||||
'[1, 2, 3, 4, 5]).copyWithin(10, -Infinity) -> [1, 2, 3, 4, 5]'
|
||||
assert.compareArray(
|
||||
new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(10, -Infinity),
|
||||
[1n, 2n, 3n, 4n, 5n],
|
||||
'new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(10, -Infinity) must return [1n, 2n, 3n, 4n, 5n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(-9, -10),
|
||||
[0n, 1n, 2n, 3n]
|
||||
),
|
||||
'[0, 1, 2, 3].copyWithin(-9, -10) -> [0, 1, 2, 3]'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(-9, -10),
|
||||
[0n, 1n, 2n, 3n],
|
||||
'new TA([0n, 1n, 2n, 3n]).copyWithin(-9, -10) must return [0n, 1n, 2n, 3n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(-9, -Infinity),
|
||||
[1n, 2n, 3n, 4n, 5n]
|
||||
),
|
||||
'[1, 2, 3, 4, 5].copyWithin(-9, -Infinity) -> [1, 2, 3, 4, 5]'
|
||||
assert.compareArray(
|
||||
new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(-9, -Infinity),
|
||||
[1n, 2n, 3n, 4n, 5n],
|
||||
'new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(-9, -Infinity) must return [1n, 2n, 3n, 4n, 5n]'
|
||||
);
|
||||
});
|
||||
|
@ -25,37 +25,28 @@ info: |
|
||||
includes: [compareArray.js, testBigIntTypedArray.js]
|
||||
features: [BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(-10, 0),
|
||||
[0n, 1n, 2n, 3n]
|
||||
),
|
||||
'[0, 1, 2, 3].copyWithin(-10, 0) -> [0, 1, 2, 3]'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(-10, 0),
|
||||
[0n, 1n, 2n, 3n],
|
||||
'new TA([0n, 1n, 2n, 3n]).copyWithin(-10, 0) must return [0n, 1n, 2n, 3n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(-Infinity, 0),
|
||||
[1n, 2n, 3n, 4n, 5n]
|
||||
),
|
||||
'[1, 2, 3, 4, 5].copyWithin(-Infinity, 0) -> [1, 2, 3, 4, 5]'
|
||||
assert.compareArray(
|
||||
new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(-Infinity, 0),
|
||||
[1n, 2n, 3n, 4n, 5n],
|
||||
'new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(-Infinity, 0) must return [1n, 2n, 3n, 4n, 5n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-10, 2),
|
||||
[2n, 3n, 4n, 3n, 4n]
|
||||
),
|
||||
'[0, 1, 2, 3, 4].copyWithin(-10, 2) -> [2, 3, 4, 3, 4]'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-10, 2),
|
||||
[2n, 3n, 4n, 3n, 4n],
|
||||
'new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-10, 2) must return [2n, 3n, 4n, 3n, 4n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(-Infinity, 2),
|
||||
[3n, 4n, 5n, 4n, 5n]
|
||||
),
|
||||
'[1, 2, 3, 4, 5].copyWithin(-Infinity, 2) -> [3, 4, 5, 4, 5]'
|
||||
assert.compareArray(
|
||||
new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(-Infinity, 2),
|
||||
[3n, 4n, 5n, 4n, 5n],
|
||||
'new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(-Infinity, 2) must return [3n, 4n, 5n, 4n, 5n]'
|
||||
);
|
||||
});
|
||||
|
@ -25,53 +25,40 @@ info: |
|
||||
includes: [compareArray.js, testBigIntTypedArray.js]
|
||||
features: [BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(0, -1),
|
||||
[3n, 1n, 2n, 3n]
|
||||
),
|
||||
'[0, 1, 2, 3].copyWithin(0, -1) -> [3, 1, 2, 3]'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(0, -1),
|
||||
[3n, 1n, 2n, 3n],
|
||||
'new TA([0n, 1n, 2n, 3n]).copyWithin(0, -1) must return [3n, 1n, 2n, 3n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(2, -2),
|
||||
[0n, 1n, 3n, 4n, 4n]
|
||||
),
|
||||
'[0, 1, 2, 3, 4].copyWithin(2, -2) -> [0, 1, 3, 4, 4]'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(2, -2),
|
||||
[0n, 1n, 3n, 4n, 4n],
|
||||
'new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(2, -2) must return [0n, 1n, 3n, 4n, 4n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(1, -2),
|
||||
[0n, 3n, 4n, 3n, 4n]
|
||||
),
|
||||
'[0, 1, 2, 3, 4].copyWithin(1, -2) -> [0, 3, 4, 3, 4]'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(1, -2),
|
||||
[0n, 3n, 4n, 3n, 4n],
|
||||
'new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(1, -2) must return [0n, 3n, 4n, 3n, 4n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(-1, -2),
|
||||
[0n, 1n, 2n, 2n]
|
||||
),
|
||||
'[0, 1, 2, 3].copyWithin(-1, -2) -> [ 0, 1, 2, 2 ]'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(-1, -2),
|
||||
[0n, 1n, 2n, 2n],
|
||||
'new TA([0n, 1n, 2n, 3n]).copyWithin(-1, -2) must return [0n, 1n, 2n, 2n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-2, -3),
|
||||
[0n, 1n, 2n, 2n, 3n]
|
||||
),
|
||||
'[0, 1, 2, 3, 4].copyWithin(-2, -3) -> [0, 1, 2, 2, 3]'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-2, -3),
|
||||
[0n, 1n, 2n, 2n, 3n],
|
||||
'new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-2, -3) must return [0n, 1n, 2n, 2n, 3n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-5, -2),
|
||||
[3n, 4n, 2n, 3n, 4n]
|
||||
),
|
||||
'[0, 1, 2, 3, 4].copyWithin(-5, -2) -> [3, 4, 2, 3, 4]'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-5, -2),
|
||||
[3n, 4n, 2n, 3n, 4n],
|
||||
'new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-5, -2) must return [3n, 4n, 2n, 3n, 4n]'
|
||||
);
|
||||
});
|
||||
|
@ -25,29 +25,22 @@ info: |
|
||||
includes: [compareArray.js, testBigIntTypedArray.js]
|
||||
features: [BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(-1, 0),
|
||||
[0n, 1n, 2n, 0n]
|
||||
),
|
||||
'[0, 1, 2, 3].copyWithin(-1, 0) -> [0, 1, 2, 0]'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(-1, 0),
|
||||
[0n, 1n, 2n, 0n],
|
||||
'new TA([0n, 1n, 2n, 3n]).copyWithin(-1, 0) must return [0n, 1n, 2n, 0n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-2, 2),
|
||||
[0n, 1n, 2n, 2n, 3n]
|
||||
),
|
||||
'[0, 1, 2, 3, 4].copyWithin(-2, 2) -> [0, 1, 2, 2, 3]'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-2, 2),
|
||||
[0n, 1n, 2n, 2n, 3n],
|
||||
'new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-2, 2) must return [0n, 1n, 2n, 2n, 3n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(-1, 2),
|
||||
[0n, 1n, 2n, 2n]
|
||||
),
|
||||
'[0, 1, 2, 3].copyWithin(-1, 2) -> [0, 1, 2, 2]'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(-1, 2),
|
||||
[0n, 1n, 2n, 2n],
|
||||
'new TA([0n, 1n, 2n, 3n]).copyWithin(-1, 2) must return [0n, 1n, 2n, 2n]'
|
||||
);
|
||||
});
|
||||
|
@ -18,37 +18,28 @@ info: |
|
||||
includes: [compareArray.js, testBigIntTypedArray.js]
|
||||
features: [BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1, 6),
|
||||
[1n, 2n, 3n, 3n]
|
||||
),
|
||||
'[0, 1, 2, 3].copyWithin(0, 1, 6) -> [1, 2, 3, 3]'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1, 6),
|
||||
[1n, 2n, 3n, 3n],
|
||||
'new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1, 6) must return [1n, 2n, 3n, 3n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, 1, Infinity),
|
||||
[2n, 3n, 4n, 5n, 5n]
|
||||
),
|
||||
'[1, 2, 3, 4, 5].copyWithin(0, 1, Infinity) -> [2, 3, 4, 5, 5]'
|
||||
assert.compareArray(
|
||||
new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, 1, Infinity),
|
||||
[2n, 3n, 4n, 5n, 5n],
|
||||
'new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, 1, Infinity) must return [2n, 3n, 4n, 5n, 5n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(1, 3, 6),
|
||||
[0n, 3n, 4n, 5n, 4n, 5n]
|
||||
),
|
||||
'[0, 1, 2, 3, 4, 5].copyWithin(1, 3, 6) -> [0, 3, 4, 5, 4, 5]'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(1, 3, 6),
|
||||
[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]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(1, 3, Infinity),
|
||||
[1n, 4n, 5n, 4n, 5n]
|
||||
),
|
||||
'[1, 2, 3, 4, 5].copyWithin(1, 3, Infinity) -> [1, 4, 5, 4, 5]'
|
||||
assert.compareArray(
|
||||
new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(1, 3, Infinity),
|
||||
[1n, 4n, 5n, 4n, 5n],
|
||||
'new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(1, 3, Infinity) must return [1n, 4n, 5n, 4n, 5n]'
|
||||
);
|
||||
});
|
||||
|
@ -18,57 +18,46 @@ info: |
|
||||
includes: [compareArray.js, testBigIntTypedArray.js]
|
||||
features: [BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(6, 0),
|
||||
[0n, 1n, 2n, 3n, 4n, 5n]
|
||||
)
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(6, 0),
|
||||
[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(
|
||||
compareArray(
|
||||
new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(Infinity, 0),
|
||||
[1n, 2n, 3n, 4n, 5n]
|
||||
),
|
||||
'[1, 2, 3, 4, 5].copyWithin(Infinity, 0) -> [1, 2, 3, 4, 5]'
|
||||
assert.compareArray(
|
||||
new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(Infinity, 0),
|
||||
[1n, 2n, 3n, 4n, 5n],
|
||||
'new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(Infinity, 0) must return [1n, 2n, 3n, 4n, 5n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(0, 6),
|
||||
[0n, 1n, 2n, 3n, 4n, 5n]
|
||||
)
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(0, 6),
|
||||
[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(
|
||||
compareArray(
|
||||
new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, Infinity),
|
||||
[1n, 2n, 3n, 4n, 5n]
|
||||
),
|
||||
'[1, 2, 3, 4, 5].copyWithin(0, Infinity) -> [1, 2, 3, 4, 5]'
|
||||
assert.compareArray(
|
||||
new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, Infinity),
|
||||
[1n, 2n, 3n, 4n, 5n],
|
||||
'new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, Infinity) must return [1n, 2n, 3n, 4n, 5n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(6, 6),
|
||||
[0n, 1n, 2n, 3n, 4n, 5n]
|
||||
)
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(6, 6),
|
||||
[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(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(10, 10),
|
||||
[0n, 1n, 2n, 3n, 4n, 5n]
|
||||
)
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(10, 10),
|
||||
[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(
|
||||
compareArray(
|
||||
new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(Infinity, Infinity),
|
||||
[1n, 2n, 3n, 4n, 5n]
|
||||
),
|
||||
'[1, 2, 3, 4, 5].copyWithin(Infinity, Infinity) -> [1, 2, 3, 4, 5]'
|
||||
assert.compareArray(
|
||||
new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(Infinity, Infinity),
|
||||
[1n, 2n, 3n, 4n, 5n],
|
||||
'new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(Infinity, Infinity) must return [1n, 2n, 3n, 4n, 5n]'
|
||||
);
|
||||
});
|
||||
|
@ -18,33 +18,28 @@ info: |
|
||||
includes: [compareArray.js, testBigIntTypedArray.js]
|
||||
features: [BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([1n, 2n, 3n, 4n, 5n, 6n]).copyWithin(0, 0),
|
||||
[1n, 2n, 3n, 4n, 5n, 6n]
|
||||
)
|
||||
assert.compareArray(
|
||||
new TA([1n, 2n, 3n, 4n, 5n, 6n]).copyWithin(0, 0),
|
||||
[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(
|
||||
compareArray(
|
||||
new TA([1n, 2n, 3n, 4n, 5n, 6n]).copyWithin(0, 2),
|
||||
[3n, 4n, 5n, 6n, 5n, 6n]
|
||||
)
|
||||
assert.compareArray(
|
||||
new TA([1n, 2n, 3n, 4n, 5n, 6n]).copyWithin(0, 2),
|
||||
[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(
|
||||
compareArray(
|
||||
new TA([1n, 2n, 3n, 4n, 5n, 6n]).copyWithin(3, 0),
|
||||
[1n, 2n, 3n, 1n, 2n, 3n]
|
||||
)
|
||||
assert.compareArray(
|
||||
new TA([1n, 2n, 3n, 4n, 5n, 6n]).copyWithin(3, 0),
|
||||
[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(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(1, 4),
|
||||
[0n, 4n, 5n, 3n, 4n, 5n]
|
||||
)
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(1, 4),
|
||||
[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]'
|
||||
);
|
||||
});
|
||||
|
@ -20,28 +20,22 @@ features: [BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(0, 0, 0),
|
||||
[0n, 1n, 2n, 3n]
|
||||
),
|
||||
'[0, 1, 2, 3].copyWithin(0, 0, 0) -> [0, 1, 2, 3]'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(0, 0, 0),
|
||||
[0n, 1n, 2n, 3n],
|
||||
'new TA([0n, 1n, 2n, 3n]).copyWithin(0, 0, 0) must return [0n, 1n, 2n, 3n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(0, 0, 2),
|
||||
[0n, 1n, 2n, 3n]
|
||||
),
|
||||
'[0, 1, 2, 3].copyWithin(0, 0, 2) -> [0, 1, 2, 3]'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(0, 0, 2),
|
||||
[0n, 1n, 2n, 3n],
|
||||
'new TA([0n, 1n, 2n, 3n]).copyWithin(0, 0, 2) must return [0n, 1n, 2n, 3n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1, 2),
|
||||
[1n, 1n, 2n, 3n]
|
||||
),
|
||||
'[0, 1, 2, 3].copyWithin(0, 1, 2) -> [1, 1, 2, 3]'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1, 2),
|
||||
[1n, 1n, 2n, 3n],
|
||||
'new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1, 2) must return [1n, 1n, 2n, 3n]'
|
||||
);
|
||||
|
||||
/*
|
||||
@ -55,19 +49,15 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
* from = 0 + 2 - 1
|
||||
* to = 1 + 2 - 1
|
||||
*/
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, 2),
|
||||
[0n, 0n, 1n, 3n]
|
||||
),
|
||||
'[0, 1, 2, 3].copyWithin(1, 0, 2) -> [0, 0, 1, 3]'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, 2),
|
||||
[0n, 0n, 1n, 3n],
|
||||
'new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, 2) must return [0n, 0n, 1n, 3n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(1, 3, 5),
|
||||
[0n, 3n, 4n, 3n, 4n, 5n]
|
||||
),
|
||||
'[0, 1, 2, 3, 4, 5].copyWithin(1, 3, 5) -> [0, 3, 4, 3, 4, 5]'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(1, 3, 5),
|
||||
[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]'
|
||||
);
|
||||
});
|
||||
|
@ -25,21 +25,16 @@ info: |
|
||||
includes: [compareArray.js, testBigIntTypedArray.js]
|
||||
features: [BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1, undefined),
|
||||
[1n, 2n, 3n, 3n]
|
||||
),
|
||||
'[0, 1, 2, 3].copyWithin(0, 1, undefined) -> [1, 2, 3]'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1, undefined),
|
||||
[1n, 2n, 3n, 3n],
|
||||
'new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1, undefined) must return [1n, 2n, 3n, 3n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1),
|
||||
[1n, 2n, 3n, 3n]
|
||||
),
|
||||
'[0, 1, 2, 3].copyWithin(0, 1) -> [1, 2, 3, 3]'
|
||||
assert.compareArray(
|
||||
new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1),
|
||||
[1n, 2n, 3n, 3n],
|
||||
'new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1) must return [1n, 2n, 3n, 3n]'
|
||||
);
|
||||
});
|
||||
|
@ -38,7 +38,11 @@ function body(FloatArray) {
|
||||
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]);
|
||||
|
@ -27,51 +27,45 @@ features: [TypedArray]
|
||||
---*/
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(1, 0, null),
|
||||
[0, 1, 2, 3]
|
||||
),
|
||||
'null value coerced to 0'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(1, 0, null),
|
||||
[0, 1, 2, 3]
|
||||
,
|
||||
'new TA([0, 1, 2, 3]).copyWithin(1, 0, null) must return [0, 1, 2, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(1, 0, NaN),
|
||||
[0, 1, 2, 3]
|
||||
),
|
||||
'NaN value coerced to 0'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(1, 0, NaN),
|
||||
[0, 1, 2, 3]
|
||||
,
|
||||
'new TA([0, 1, 2, 3]).copyWithin(1, 0, NaN) must return [0, 1, 2, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(1, 0, false),
|
||||
[0, 1, 2, 3]
|
||||
),
|
||||
'false value coerced to 0'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(1, 0, false),
|
||||
[0, 1, 2, 3]
|
||||
,
|
||||
'new TA([0, 1, 2, 3]).copyWithin(1, 0, false) must return [0, 1, 2, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(1, 0, true),
|
||||
[0, 0, 2, 3]
|
||||
),
|
||||
'true value coerced to 1'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(1, 0, true),
|
||||
[0, 0, 2, 3]
|
||||
,
|
||||
'new TA([0, 1, 2, 3]).copyWithin(1, 0, true) must return [0, 0, 2, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(1, 0, '-2'),
|
||||
[0, 0, 1, 3]
|
||||
),
|
||||
'string "-2" value coerced to integer -2'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(1, 0, '-2'),
|
||||
[0, 0, 1, 3]
|
||||
,
|
||||
'new TA([0, 1, 2, 3]).copyWithin(1, 0, "-2") must return [0, 0, 1, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(1, 0, -2.5),
|
||||
[0, 0, 1, 3]
|
||||
),
|
||||
'float -2.5 value coerced to integer -2'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(1, 0, -2.5),
|
||||
[0, 0, 1, 3]
|
||||
,
|
||||
'new TA([0, 1, 2, 3]).copyWithin(1, 0, -2.5) must return [0, 0, 1, 3]'
|
||||
);
|
||||
});
|
||||
|
@ -26,67 +26,51 @@ features: [TypedArray]
|
||||
---*/
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(1, undefined),
|
||||
[0, 0, 1, 2]
|
||||
),
|
||||
'undefined value coerced to 0'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(1, undefined),
|
||||
[0, 0, 1, 2],
|
||||
'new TA([0, 1, 2, 3]).copyWithin(1, undefined) must return [0, 0, 1, 2]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(1, false),
|
||||
[0, 0, 1, 2]
|
||||
),
|
||||
'false value coerced to 0'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(1, false),
|
||||
[0, 0, 1, 2],
|
||||
'new TA([0, 1, 2, 3]).copyWithin(1, false) must return [0, 0, 1, 2]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(1, NaN),
|
||||
[0, 0, 1, 2]
|
||||
),
|
||||
'NaN value coerced to 0'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(1, NaN),
|
||||
[0, 0, 1, 2],
|
||||
'new TA([0, 1, 2, 3]).copyWithin(1, NaN) must return [0, 0, 1, 2]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(1, null),
|
||||
[0, 0, 1, 2]
|
||||
),
|
||||
'null value coerced to 0'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(1, null),
|
||||
[0, 0, 1, 2],
|
||||
'new TA([0, 1, 2, 3]).copyWithin(1, null) must return [0, 0, 1, 2]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(0, true),
|
||||
[1, 2, 3, 3]
|
||||
),
|
||||
'true value coerced to 1'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(0, true),
|
||||
[1, 2, 3, 3],
|
||||
'new TA([0, 1, 2, 3]).copyWithin(0, true) must return [1, 2, 3, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(0, '1'),
|
||||
[1, 2, 3, 3]
|
||||
),
|
||||
'string "1" value coerced to 1'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(0, '1'),
|
||||
[1, 2, 3, 3],
|
||||
'new TA([0, 1, 2, 3]).copyWithin(0, "1") must return [1, 2, 3, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(1, 0.5),
|
||||
[0, 0, 1, 2]
|
||||
),
|
||||
'0.5 float value coerced to integer 0'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(1, 0.5),
|
||||
[0, 0, 1, 2],
|
||||
'new TA([0, 1, 2, 3]).copyWithin(1, 0.5) must return [0, 0, 1, 2]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(0, 1.5),
|
||||
[1, 2, 3, 3]
|
||||
),
|
||||
'1.5 float value coerced to integer 1'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(0, 1.5),
|
||||
[1, 2, 3, 3],
|
||||
'new TA([0, 1, 2, 3]).copyWithin(0, 1.5) must return [1, 2, 3, 3]'
|
||||
);
|
||||
});
|
||||
|
@ -26,75 +26,57 @@ features: [TypedArray]
|
||||
---*/
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(undefined, 1),
|
||||
[1, 2, 3, 3]
|
||||
),
|
||||
'undefined value coerced to 0'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(undefined, 1),
|
||||
[1, 2, 3, 3],
|
||||
'new TA([0, 1, 2, 3]).copyWithin(undefined, 1) must return [1, 2, 3, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(false, 1),
|
||||
[1, 2, 3, 3]
|
||||
),
|
||||
'false value coerced to 0'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(false, 1),
|
||||
[1, 2, 3, 3],
|
||||
'new TA([0, 1, 2, 3]).copyWithin(false, 1) must return [1, 2, 3, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(NaN, 1),
|
||||
[1, 2, 3, 3]
|
||||
),
|
||||
'NaN value coerced to 0'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(NaN, 1),
|
||||
[1, 2, 3, 3],
|
||||
'new TA([0, 1, 2, 3]).copyWithin(NaN, 1) must return [1, 2, 3, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(null, 1),
|
||||
[1, 2, 3, 3]
|
||||
),
|
||||
'null value coerced to 0'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(null, 1),
|
||||
[1, 2, 3, 3],
|
||||
'new TA([0, 1, 2, 3]).copyWithin(null, 1) must return [1, 2, 3, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(true, 0),
|
||||
[0, 0, 1, 2]
|
||||
),
|
||||
'true value coerced to 1'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(true, 0),
|
||||
[0, 0, 1, 2],
|
||||
'new TA([0, 1, 2, 3]).copyWithin(true, 0) must return [0, 0, 1, 2]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin('1', 0),
|
||||
[0, 0, 1, 2]
|
||||
),
|
||||
'string "1" value coerced to 1'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin('1', 0),
|
||||
[0, 0, 1, 2],
|
||||
'new TA([0, 1, 2, 3]).copyWithin("1", 0) must return [0, 0, 1, 2]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(0.5, 1),
|
||||
[1, 2, 3, 3]
|
||||
),
|
||||
'0.5 float value coerced to integer 0'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(0.5, 1),
|
||||
[1, 2, 3, 3],
|
||||
'new TA([0, 1, 2, 3]).copyWithin(0.5, 1) must return [1, 2, 3, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(1.5, 0),
|
||||
[0, 0, 1, 2]
|
||||
),
|
||||
'1.5 float value coerced to integer 1'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(1.5, 0),
|
||||
[0, 0, 1, 2],
|
||||
'new TA([0, 1, 2, 3]).copyWithin(1.5, 0) must return [0, 0, 1, 2]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin({}, 1),
|
||||
[1, 2, 3, 3]
|
||||
),
|
||||
'object value coerced to integer 0'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin({}, 1),
|
||||
[1, 2, 3, 3],
|
||||
'new TA([0, 1, 2, 3]).copyWithin({}, 1) must return [1, 2, 3, 3]'
|
||||
);
|
||||
});
|
||||
|
@ -29,67 +29,51 @@ features: [TypedArray]
|
||||
---*/
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(0, 1, -1),
|
||||
[1, 2, 2, 3]
|
||||
),
|
||||
'[0, 1, 2, 3].copyWithin(0, 1, -1) -> [1, 2, 2, 3]'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(0, 1, -1),
|
||||
[1, 2, 2, 3],
|
||||
'new TA([0, 1, 2, 3]).copyWithin(0, 1, -1) must return [1, 2, 2, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3, 4]).copyWithin(2, 0, -1),
|
||||
[0, 1, 0, 1, 2]
|
||||
),
|
||||
'[0, 1, 2, 3, 4].copyWithin(2, 0, -1) -> [0, 1, 0, 1, 2]'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3, 4]).copyWithin(2, 0, -1),
|
||||
[0, 1, 0, 1, 2],
|
||||
'new TA([0, 1, 2, 3, 4]).copyWithin(2, 0, -1) must return [0, 1, 0, 1, 2]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3, 4]).copyWithin(1, 2, -2),
|
||||
[0, 2, 2, 3, 4]
|
||||
),
|
||||
'[0, 1, 2, 3, 4].copyWithin(1, 2, -2) -> [0, 2, 2, 3, 4]'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3, 4]).copyWithin(1, 2, -2),
|
||||
[0, 2, 2, 3, 4],
|
||||
'new TA([0, 1, 2, 3, 4]).copyWithin(1, 2, -2) must return [0, 2, 2, 3, 4]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(0, -2, -1),
|
||||
[2, 1, 2, 3]
|
||||
),
|
||||
'[0, 1, 2, 3].copyWithin(0, -2, -1) -> [2, 1, 2, 3]'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(0, -2, -1),
|
||||
[2, 1, 2, 3],
|
||||
'new TA([0, 1, 2, 3]).copyWithin(0, -2, -1) must return [2, 1, 2, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3, 4]).copyWithin(2, -2, -1),
|
||||
[0, 1, 3, 3, 4]
|
||||
),
|
||||
'[0, 1, 2, 3, 4].copyWithin(2, -2, 1) -> [0, 1, 3, 3, 4]'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3, 4]).copyWithin(2, -2, -1),
|
||||
[0, 1, 3, 3, 4],
|
||||
'new TA([0, 1, 2, 3, 4]).copyWithin(2, -2, -1) must return [0, 1, 3, 3, 4]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(-3, -2, -1),
|
||||
[0, 2, 2, 3]
|
||||
),
|
||||
'[0, 1, 2, 3].copyWithin(-3, -2, -1) -> [0, 2, 2, 3]'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(-3, -2, -1),
|
||||
[0, 2, 2, 3],
|
||||
'new TA([0, 1, 2, 3]).copyWithin(-3, -2, -1) must return [0, 2, 2, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3, 4]).copyWithin(-2, -3, -1),
|
||||
[0, 1, 2, 2, 3]
|
||||
),
|
||||
'[0, 1, 2, 3, 4].copyWithin(-2, -3, -1) -> [0, 1, 2, 2, 3]'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3, 4]).copyWithin(-2, -3, -1),
|
||||
[0, 1, 2, 2, 3],
|
||||
'new TA([0, 1, 2, 3, 4]).copyWithin(-2, -3, -1) must return [0, 1, 2, 2, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3, 4]).copyWithin(-5, -2, -1),
|
||||
[3, 1, 2, 3, 4]
|
||||
),
|
||||
'[0, 1, 2, 3, 4].copyWithin(-5, -2, -1) -> [3, 1, 2, 3, 4]'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3, 4]).copyWithin(-5, -2, -1),
|
||||
[3, 1, 2, 3, 4],
|
||||
'new TA([0, 1, 2, 3, 4]).copyWithin(-5, -2, -1) must return [3, 1, 2, 3, 4]'
|
||||
);
|
||||
});
|
||||
|
@ -29,83 +29,63 @@ features: [TypedArray]
|
||||
---*/
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(0, 1, -10),
|
||||
[0, 1, 2, 3]
|
||||
),
|
||||
'[0, 1, 2, 3].copyWithin(0, 1, -10) -> [0, 1, 2, 3]'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(0, 1, -10),
|
||||
[0, 1, 2, 3],
|
||||
'new TA([0, 1, 2, 3]).copyWithin(0, 1, -10) must return [0, 1, 2, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([1, 2, 3, 4, 5]).copyWithin(0, 1, -Infinity),
|
||||
[1, 2, 3, 4, 5]
|
||||
),
|
||||
'[1, 2, 3, 4, 5].copyWithin(0, 1, -Infinity) -> [1, 2, 3, 4, 5]'
|
||||
assert.compareArray(
|
||||
new TA([1, 2, 3, 4, 5]).copyWithin(0, 1, -Infinity),
|
||||
[1, 2, 3, 4, 5],
|
||||
'new TA([1, 2, 3, 4, 5]).copyWithin(0, 1, -Infinity) must return [1, 2, 3, 4, 5]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(0, -2, -10),
|
||||
[0, 1, 2, 3]
|
||||
),
|
||||
'[0, 1, 2, 3].copyWithin(0, -2, -10) -> [0, 1, 2, 3]'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(0, -2, -10),
|
||||
[0, 1, 2, 3],
|
||||
'new TA([0, 1, 2, 3]).copyWithin(0, -2, -10) must return [0, 1, 2, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([1, 2, 3, 4, 5]).copyWithin(0, -2, -Infinity),
|
||||
[1, 2, 3, 4, 5]
|
||||
),
|
||||
'[1, 2, 3, 4, 5].copyWithin(0, -2, -Infinity) -> [1, 2, 3, 4, 5]'
|
||||
assert.compareArray(
|
||||
new TA([1, 2, 3, 4, 5]).copyWithin(0, -2, -Infinity),
|
||||
[1, 2, 3, 4, 5],
|
||||
'new TA([1, 2, 3, 4, 5]).copyWithin(0, -2, -Infinity) must return [1, 2, 3, 4, 5]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(0, -9, -10),
|
||||
[0, 1, 2, 3]
|
||||
),
|
||||
'[0, 1, 2, 3].copyWithin(0, -9, -10) -> [0, 1, 2, 3]'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(0, -9, -10),
|
||||
[0, 1, 2, 3],
|
||||
'new TA([0, 1, 2, 3]).copyWithin(0, -9, -10) must return [0, 1, 2, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([1, 2, 3, 4, 5]).copyWithin(0, -9, -Infinity),
|
||||
[1, 2, 3, 4, 5]
|
||||
),
|
||||
'[1, 2, 3, 4, 5].copyWithin(0, -9, -Infinity) -> [1, 2, 3, 4, 5]'
|
||||
assert.compareArray(
|
||||
new TA([1, 2, 3, 4, 5]).copyWithin(0, -9, -Infinity),
|
||||
[1, 2, 3, 4, 5],
|
||||
'new TA([1, 2, 3, 4, 5]).copyWithin(0, -9, -Infinity) must return [1, 2, 3, 4, 5]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(-3, -2, -10),
|
||||
[0, 1, 2, 3]
|
||||
),
|
||||
'[0, 1, 2, 3].copyWithin(-3, -2, -10) -> [0, 1, 2, 3]'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(-3, -2, -10),
|
||||
[0, 1, 2, 3],
|
||||
'new TA([0, 1, 2, 3]).copyWithin(-3, -2, -10) must return [0, 1, 2, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([1, 2, 3, 4, 5]).copyWithin(-3, -2, -Infinity),
|
||||
[1, 2, 3, 4, 5]
|
||||
),
|
||||
'[1, 2, 3, 4, 5].copyWithin(-3, -2, -Infinity) -> [1, 2, 3, 4, 5]'
|
||||
assert.compareArray(
|
||||
new TA([1, 2, 3, 4, 5]).copyWithin(-3, -2, -Infinity),
|
||||
[1, 2, 3, 4, 5],
|
||||
'new TA([1, 2, 3, 4, 5]).copyWithin(-3, -2, -Infinity) must return [1, 2, 3, 4, 5]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(-7, -8, -9),
|
||||
[0, 1, 2, 3]
|
||||
),
|
||||
'[0, 1, 2, 3].copyWithin(-7, -8, -9) -> [0, 1, 2, 3]'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(-7, -8, -9),
|
||||
[0, 1, 2, 3],
|
||||
'new TA([0, 1, 2, 3]).copyWithin(-7, -8, -9) must return [0, 1, 2, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([1, 2, 3, 4, 5]).copyWithin(-7, -8, -Infinity),
|
||||
[1, 2, 3, 4, 5]
|
||||
),
|
||||
'[1, 2, 3, 4, 5].copyWithin(-7, -8, -Infinity) -> [1, 2, 3, 4, 5]'
|
||||
assert.compareArray(
|
||||
new TA([1, 2, 3, 4, 5]).copyWithin(-7, -8, -Infinity),
|
||||
[1, 2, 3, 4, 5],
|
||||
'new TA([1, 2, 3, 4, 5]).copyWithin(-7, -8, -Infinity) must return [1, 2, 3, 4, 5]'
|
||||
);
|
||||
});
|
||||
|
@ -27,67 +27,51 @@ features: [TypedArray]
|
||||
---*/
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(0, -10),
|
||||
[0, 1, 2, 3]
|
||||
),
|
||||
'[0, 1, 2, 3]).copyWithin(0, -10) -> [0, 1, 2, 3]'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(0, -10),
|
||||
[0, 1, 2, 3],
|
||||
'new TA([0, 1, 2, 3]).copyWithin(0, -10) must return [0, 1, 2, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([1, 2, 3, 4, 5]).copyWithin(0, -Infinity),
|
||||
[1, 2, 3, 4, 5]
|
||||
),
|
||||
'[1, 2, 3, 4, 5]).copyWithin(0, -Infinity) -> [1, 2, 3, 4, 5]'
|
||||
assert.compareArray(
|
||||
new TA([1, 2, 3, 4, 5]).copyWithin(0, -Infinity),
|
||||
[1, 2, 3, 4, 5],
|
||||
'new TA([1, 2, 3, 4, 5]).copyWithin(0, -Infinity) must return [1, 2, 3, 4, 5]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3, 4]).copyWithin(2, -10),
|
||||
[0, 1, 0, 1, 2]
|
||||
),
|
||||
'[0, 1, 2, 3, 4]).copyWithin(2, -2) -> [0, 1, 0, 1, 2]'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3, 4]).copyWithin(2, -10),
|
||||
[0, 1, 0, 1, 2],
|
||||
'new TA([0, 1, 2, 3, 4]).copyWithin(2, -10) must return [0, 1, 0, 1, 2]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([1, 2, 3, 4, 5]).copyWithin(2, -Infinity),
|
||||
[1, 2, 1, 2, 3]
|
||||
),
|
||||
'[1, 2, 3, 4, 5]).copyWithin(2, -Infinity) -> [1, 2, 1, 2, 3]'
|
||||
assert.compareArray(
|
||||
new TA([1, 2, 3, 4, 5]).copyWithin(2, -Infinity),
|
||||
[1, 2, 1, 2, 3],
|
||||
'new TA([1, 2, 3, 4, 5]).copyWithin(2, -Infinity) must return [1, 2, 1, 2, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3, 4]).copyWithin(10, -10),
|
||||
[0, 1, 2, 3, 4]
|
||||
),
|
||||
'[0, 1, 2, 3, 4]).copyWithin(10, -10) -> [0, 1, 2, 3, 4]'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3, 4]).copyWithin(10, -10),
|
||||
[0, 1, 2, 3, 4],
|
||||
'new TA([0, 1, 2, 3, 4]).copyWithin(10, -10) must return [0, 1, 2, 3, 4]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([1, 2, 3, 4, 5]).copyWithin(10, -Infinity),
|
||||
[1, 2, 3, 4, 5]
|
||||
),
|
||||
'[1, 2, 3, 4, 5]).copyWithin(10, -Infinity) -> [1, 2, 3, 4, 5]'
|
||||
assert.compareArray(
|
||||
new TA([1, 2, 3, 4, 5]).copyWithin(10, -Infinity),
|
||||
[1, 2, 3, 4, 5],
|
||||
'new TA([1, 2, 3, 4, 5]).copyWithin(10, -Infinity) must return [1, 2, 3, 4, 5]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(-9, -10),
|
||||
[0, 1, 2, 3]
|
||||
),
|
||||
'[0, 1, 2, 3].copyWithin(-9, -10) -> [0, 1, 2, 3]'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(-9, -10),
|
||||
[0, 1, 2, 3],
|
||||
'new TA([0, 1, 2, 3]).copyWithin(-9, -10) must return [0, 1, 2, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([1, 2, 3, 4, 5]).copyWithin(-9, -Infinity),
|
||||
[1, 2, 3, 4, 5]
|
||||
),
|
||||
'[1, 2, 3, 4, 5].copyWithin(-9, -Infinity) -> [1, 2, 3, 4, 5]'
|
||||
assert.compareArray(
|
||||
new TA([1, 2, 3, 4, 5]).copyWithin(-9, -Infinity),
|
||||
[1, 2, 3, 4, 5],
|
||||
'new TA([1, 2, 3, 4, 5]).copyWithin(-9, -Infinity) must return [1, 2, 3, 4, 5]'
|
||||
);
|
||||
});
|
||||
|
@ -27,35 +27,27 @@ features: [TypedArray]
|
||||
---*/
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(-10, 0),
|
||||
[0, 1, 2, 3]
|
||||
),
|
||||
'[0, 1, 2, 3].copyWithin(-10, 0) -> [0, 1, 2, 3]'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(-10, 0),
|
||||
[0, 1, 2, 3],
|
||||
'new TA([0, 1, 2, 3]).copyWithin(-10, 0) must return [0, 1, 2, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([1, 2, 3, 4, 5]).copyWithin(-Infinity, 0),
|
||||
[1, 2, 3, 4, 5]
|
||||
),
|
||||
'[1, 2, 3, 4, 5].copyWithin(-Infinity, 0) -> [1, 2, 3, 4, 5]'
|
||||
assert.compareArray(
|
||||
new TA([1, 2, 3, 4, 5]).copyWithin(-Infinity, 0),
|
||||
[1, 2, 3, 4, 5],
|
||||
'new TA([1, 2, 3, 4, 5]).copyWithin(-Infinity, 0) must return [1, 2, 3, 4, 5]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3, 4]).copyWithin(-10, 2),
|
||||
[2, 3, 4, 3, 4]
|
||||
),
|
||||
'[0, 1, 2, 3, 4].copyWithin(-10, 2) -> [2, 3, 4, 3, 4]'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3, 4]).copyWithin(-10, 2),
|
||||
[2, 3, 4, 3, 4],
|
||||
'new TA([0, 1, 2, 3, 4]).copyWithin(-10, 2) must return [2, 3, 4, 3, 4]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([1, 2, 3, 4, 5]).copyWithin(-Infinity, 2),
|
||||
[3, 4, 5, 4, 5]
|
||||
),
|
||||
'[1, 2, 3, 4, 5].copyWithin(-Infinity, 2) -> [3, 4, 5, 4, 5]'
|
||||
assert.compareArray(
|
||||
new TA([1, 2, 3, 4, 5]).copyWithin(-Infinity, 2),
|
||||
[3, 4, 5, 4, 5],
|
||||
'new TA([1, 2, 3, 4, 5]).copyWithin(-Infinity, 2) must return [3, 4, 5, 4, 5]'
|
||||
);
|
||||
});
|
||||
|
@ -27,51 +27,39 @@ features: [TypedArray]
|
||||
---*/
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(0, -1),
|
||||
[3, 1, 2, 3]
|
||||
),
|
||||
'[0, 1, 2, 3].copyWithin(0, -1) -> [3, 1, 2, 3]'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(0, -1),
|
||||
[3, 1, 2, 3],
|
||||
'new TA([0, 1, 2, 3]).copyWithin(0, -1) must return [3, 1, 2, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3, 4]).copyWithin(2, -2),
|
||||
[0, 1, 3, 4, 4]
|
||||
),
|
||||
'[0, 1, 2, 3, 4].copyWithin(2, -2) -> [0, 1, 3, 4, 4]'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3, 4]).copyWithin(2, -2),
|
||||
[0, 1, 3, 4, 4],
|
||||
'new TA([0, 1, 2, 3, 4]).copyWithin(2, -2) must return [0, 1, 3, 4, 4]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3, 4]).copyWithin(1, -2),
|
||||
[0, 3, 4, 3, 4]
|
||||
),
|
||||
'[0, 1, 2, 3, 4].copyWithin(1, -2) -> [0, 3, 4, 3, 4]'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3, 4]).copyWithin(1, -2),
|
||||
[0, 3, 4, 3, 4],
|
||||
'new TA([0, 1, 2, 3, 4]).copyWithin(1, -2) must return [0, 3, 4, 3, 4]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(-1, -2),
|
||||
[0, 1, 2, 2]
|
||||
),
|
||||
'[0, 1, 2, 3].copyWithin(-1, -2) -> [ 0, 1, 2, 2 ]'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(-1, -2),
|
||||
[0, 1, 2, 2],
|
||||
'new TA([0, 1, 2, 3]).copyWithin(-1, -2) must return [0, 1, 2, 2]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3, 4]).copyWithin(-2, -3),
|
||||
[0, 1, 2, 2, 3]
|
||||
),
|
||||
'[0, 1, 2, 3, 4].copyWithin(-2, -3) -> [0, 1, 2, 2, 3]'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3, 4]).copyWithin(-2, -3),
|
||||
[0, 1, 2, 2, 3],
|
||||
'new TA([0, 1, 2, 3, 4]).copyWithin(-2, -3) must return [0, 1, 2, 2, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3, 4]).copyWithin(-5, -2),
|
||||
[3, 4, 2, 3, 4]
|
||||
),
|
||||
'[0, 1, 2, 3, 4].copyWithin(-5, -2) -> [3, 4, 2, 3, 4]'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3, 4]).copyWithin(-5, -2),
|
||||
[3, 4, 2, 3, 4],
|
||||
'new TA([0, 1, 2, 3, 4]).copyWithin(-5, -2) must return [3, 4, 2, 3, 4]'
|
||||
);
|
||||
});
|
||||
|
@ -27,27 +27,21 @@ features: [TypedArray]
|
||||
---*/
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(-1, 0),
|
||||
[0, 1, 2, 0]
|
||||
),
|
||||
'[0, 1, 2, 3].copyWithin(-1, 0) -> [0, 1, 2, 0]'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(-1, 0),
|
||||
[0, 1, 2, 0],
|
||||
'new TA([0, 1, 2, 3]).copyWithin(-1, 0) must return [0, 1, 2, 0]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3, 4]).copyWithin(-2, 2),
|
||||
[0, 1, 2, 2, 3]
|
||||
),
|
||||
'[0, 1, 2, 3, 4].copyWithin(-2, 2) -> [0, 1, 2, 2, 3]'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3, 4]).copyWithin(-2, 2),
|
||||
[0, 1, 2, 2, 3],
|
||||
'new TA([0, 1, 2, 3, 4]).copyWithin(-2, 2) must return [0, 1, 2, 2, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(-1, 2),
|
||||
[0, 1, 2, 2]
|
||||
),
|
||||
'[0, 1, 2, 3].copyWithin(-1, 2) -> [0, 1, 2, 2]'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(-1, 2),
|
||||
[0, 1, 2, 2],
|
||||
'new TA([0, 1, 2, 3]).copyWithin(-1, 2) must return [0, 1, 2, 2]'
|
||||
);
|
||||
});
|
||||
|
@ -20,35 +20,27 @@ features: [TypedArray]
|
||||
---*/
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(0, 1, 6),
|
||||
[1, 2, 3, 3]
|
||||
),
|
||||
'[0, 1, 2, 3].copyWithin(0, 1, 6) -> [1, 2, 3, 3]'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(0, 1, 6),
|
||||
[1, 2, 3, 3],
|
||||
'new TA([0, 1, 2, 3]).copyWithin(0, 1, 6) must return [1, 2, 3, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([1, 2, 3, 4, 5]).copyWithin(0, 1, Infinity),
|
||||
[2, 3, 4, 5, 5]
|
||||
),
|
||||
'[1, 2, 3, 4, 5].copyWithin(0, 1, Infinity) -> [2, 3, 4, 5, 5]'
|
||||
assert.compareArray(
|
||||
new TA([1, 2, 3, 4, 5]).copyWithin(0, 1, Infinity),
|
||||
[2, 3, 4, 5, 5],
|
||||
'new TA([1, 2, 3, 4, 5]).copyWithin(0, 1, Infinity) must return [2, 3, 4, 5, 5]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3, 4, 5]).copyWithin(1, 3, 6),
|
||||
[0, 3, 4, 5, 4, 5]
|
||||
),
|
||||
'[0, 1, 2, 3, 4, 5].copyWithin(1, 3, 6) -> [0, 3, 4, 5, 4, 5]'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3, 4, 5]).copyWithin(1, 3, 6),
|
||||
[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]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([1, 2, 3, 4, 5]).copyWithin(1, 3, Infinity),
|
||||
[1, 4, 5, 4, 5]
|
||||
),
|
||||
'[1, 2, 3, 4, 5].copyWithin(1, 3, Infinity) -> [1, 4, 5, 4, 5]'
|
||||
assert.compareArray(
|
||||
new TA([1, 2, 3, 4, 5]).copyWithin(1, 3, Infinity),
|
||||
[1, 4, 5, 4, 5],
|
||||
'new TA([1, 2, 3, 4, 5]).copyWithin(1, 3, Infinity) must return [1, 4, 5, 4, 5]'
|
||||
);
|
||||
});
|
||||
|
@ -20,55 +20,45 @@ features: [TypedArray]
|
||||
---*/
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3, 4, 5]).copyWithin(6, 0),
|
||||
[0, 1, 2, 3, 4, 5]
|
||||
)
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3, 4, 5]).copyWithin(6, 0),
|
||||
[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(
|
||||
compareArray(
|
||||
new TA([1, 2, 3, 4, 5]).copyWithin(Infinity, 0),
|
||||
[1, 2, 3, 4, 5]
|
||||
),
|
||||
'[1, 2, 3, 4, 5].copyWithin(Infinity, 0) -> [1, 2, 3, 4, 5]'
|
||||
assert.compareArray(
|
||||
new TA([1, 2, 3, 4, 5]).copyWithin(Infinity, 0),
|
||||
[1, 2, 3, 4, 5],
|
||||
'new TA([1, 2, 3, 4, 5]).copyWithin(Infinity, 0) must return [1, 2, 3, 4, 5]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3, 4, 5]).copyWithin(0, 6),
|
||||
[0, 1, 2, 3, 4, 5]
|
||||
)
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3, 4, 5]).copyWithin(0, 6),
|
||||
[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(
|
||||
compareArray(
|
||||
new TA([1, 2, 3, 4, 5]).copyWithin(0, Infinity),
|
||||
[1, 2, 3, 4, 5]
|
||||
),
|
||||
'[1, 2, 3, 4, 5].copyWithin(0, Infinity) -> [1, 2, 3, 4, 5]'
|
||||
assert.compareArray(
|
||||
new TA([1, 2, 3, 4, 5]).copyWithin(0, Infinity),
|
||||
[1, 2, 3, 4, 5],
|
||||
'new TA([1, 2, 3, 4, 5]).copyWithin(0, Infinity) must return [1, 2, 3, 4, 5]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3, 4, 5]).copyWithin(6, 6),
|
||||
[0, 1, 2, 3, 4, 5]
|
||||
)
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3, 4, 5]).copyWithin(6, 6),
|
||||
[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(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3, 4, 5]).copyWithin(10, 10),
|
||||
[0, 1, 2, 3, 4, 5]
|
||||
)
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3, 4, 5]).copyWithin(10, 10),
|
||||
[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(
|
||||
compareArray(
|
||||
new TA([1, 2, 3, 4, 5]).copyWithin(Infinity, Infinity),
|
||||
[1, 2, 3, 4, 5]
|
||||
),
|
||||
'[1, 2, 3, 4, 5].copyWithin(Infinity, Infinity) -> [1, 2, 3, 4, 5]'
|
||||
assert.compareArray(
|
||||
new TA([1, 2, 3, 4, 5]).copyWithin(Infinity, Infinity),
|
||||
[1, 2, 3, 4, 5],
|
||||
'new TA([1, 2, 3, 4, 5]).copyWithin(Infinity, Infinity) must return [1, 2, 3, 4, 5]'
|
||||
);
|
||||
});
|
||||
|
@ -20,31 +20,27 @@ features: [TypedArray]
|
||||
---*/
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([1, 2, 3, 4, 5, 6]).copyWithin(0, 0),
|
||||
[1, 2, 3, 4, 5, 6]
|
||||
)
|
||||
assert.compareArray(
|
||||
new TA([1, 2, 3, 4, 5, 6]).copyWithin(0, 0),
|
||||
[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(
|
||||
compareArray(
|
||||
new TA([1, 2, 3, 4, 5, 6]).copyWithin(0, 2),
|
||||
[3, 4, 5, 6, 5, 6]
|
||||
)
|
||||
assert.compareArray(
|
||||
new TA([1, 2, 3, 4, 5, 6]).copyWithin(0, 2),
|
||||
[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(
|
||||
compareArray(
|
||||
new TA([1, 2, 3, 4, 5, 6]).copyWithin(3, 0),
|
||||
[1, 2, 3, 1, 2, 3]
|
||||
)
|
||||
assert.compareArray(
|
||||
new TA([1, 2, 3, 4, 5, 6]).copyWithin(3, 0),
|
||||
[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(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3, 4, 5]).copyWithin(1, 4),
|
||||
[0, 4, 5, 3, 4, 5]
|
||||
)
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3, 4, 5]).copyWithin(1, 4),
|
||||
[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]'
|
||||
);
|
||||
});
|
||||
|
@ -20,28 +20,22 @@ features: [TypedArray]
|
||||
---*/
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(0, 0, 0),
|
||||
[0, 1, 2, 3]
|
||||
),
|
||||
'[0, 1, 2, 3].copyWithin(0, 0, 0) -> [0, 1, 2, 3]'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(0, 0, 0),
|
||||
[0, 1, 2, 3],
|
||||
'new TA([0, 1, 2, 3]).copyWithin(0, 0, 0) must return [0, 1, 2, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(0, 0, 2),
|
||||
[0, 1, 2, 3]
|
||||
),
|
||||
'[0, 1, 2, 3].copyWithin(0, 0, 2) -> [0, 1, 2, 3]'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(0, 0, 2),
|
||||
[0, 1, 2, 3],
|
||||
'new TA([0, 1, 2, 3]).copyWithin(0, 0, 2) must return [0, 1, 2, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(0, 1, 2),
|
||||
[1, 1, 2, 3]
|
||||
),
|
||||
'[0, 1, 2, 3].copyWithin(0, 1, 2) -> [1, 1, 2, 3]'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(0, 1, 2),
|
||||
[1, 1, 2, 3],
|
||||
'new TA([0, 1, 2, 3]).copyWithin(0, 1, 2) must return [1, 1, 2, 3]'
|
||||
);
|
||||
|
||||
/*
|
||||
@ -55,19 +49,15 @@ testWithTypedArrayConstructors(function(TA) {
|
||||
* from = 0 + 2 - 1
|
||||
* to = 1 + 2 - 1
|
||||
*/
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(1, 0, 2),
|
||||
[0, 0, 1, 3]
|
||||
),
|
||||
'[0, 1, 2, 3].copyWithin(1, 0, 2) -> [0, 0, 1, 3]'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(1, 0, 2),
|
||||
[0, 0, 1, 3],
|
||||
'new TA([0, 1, 2, 3]).copyWithin(1, 0, 2) must return [0, 0, 1, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3, 4, 5]).copyWithin(1, 3, 5),
|
||||
[0, 3, 4, 3, 4, 5]
|
||||
),
|
||||
'[0, 1, 2, 3, 4, 5].copyWithin(1, 3, 5) -> [0, 3, 4, 3, 4, 5]'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3, 4, 5]).copyWithin(1, 3, 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]'
|
||||
);
|
||||
});
|
||||
|
@ -27,19 +27,15 @@ features: [TypedArray]
|
||||
---*/
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(0, 1, undefined),
|
||||
[1, 2, 3, 3]
|
||||
),
|
||||
'[0, 1, 2, 3].copyWithin(0, 1, undefined) -> [1, 2, 3]'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(0, 1, undefined),
|
||||
[1, 2, 3, 3],
|
||||
'new TA([0, 1, 2, 3]).copyWithin(0, 1, undefined) must return [1, 2, 3, 3]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(0, 1),
|
||||
[1, 2, 3, 3]
|
||||
),
|
||||
'[0, 1, 2, 3].copyWithin(0, 1) -> [1, 2, 3, 3]'
|
||||
assert.compareArray(
|
||||
new TA([0, 1, 2, 3]).copyWithin(0, 1),
|
||||
[1, 2, 3, 3],
|
||||
'new TA([0, 1, 2, 3]).copyWithin(0, 1) must return [1, 2, 3, 3]'
|
||||
);
|
||||
});
|
||||
|
@ -11,24 +11,19 @@ info: |
|
||||
includes: [testBigIntTypedArray.js, compareArray.js]
|
||||
features: [BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
var typedArray = new TA([0n, 42n, 64n]);
|
||||
var itor = typedArray.entries();
|
||||
|
||||
var next = itor.next();
|
||||
assert(compareArray(next.value, [0, 0n]));
|
||||
assert.sameValue(next.done, false);
|
||||
|
||||
assert.compareArray(next.value, [0, 0n], 'The value of next.value is expected to be [0, 0n]');
|
||||
assert.sameValue(next.done, false, 'The value of next.done is expected to be false');
|
||||
next = itor.next();
|
||||
assert(compareArray(next.value, [1, 42n]));
|
||||
assert.sameValue(next.done, false);
|
||||
|
||||
assert.compareArray(next.value, [1, 42n], 'The value of next.value is expected to be [1, 42n]');
|
||||
assert.sameValue(next.done, false, 'The value of next.done is expected to be false');
|
||||
next = itor.next();
|
||||
assert(compareArray(next.value, [2, 64n]));
|
||||
assert.sameValue(next.done, false);
|
||||
|
||||
assert.compareArray(next.value, [2, 64n], 'The value of next.value is expected to be [2, 64n]');
|
||||
assert.sameValue(next.done, false, 'The value of next.done is expected to be false');
|
||||
next = itor.next();
|
||||
assert.sameValue(next.value, undefined);
|
||||
assert.sameValue(next.done, true);
|
||||
assert.sameValue(next.value, undefined, 'The value of next.value is expected to equal undefined');
|
||||
assert.sameValue(next.done, true, 'The value of next.done is expected to be true');
|
||||
});
|
||||
|
@ -19,18 +19,18 @@ testWithTypedArrayConstructors(function(TA) {
|
||||
var itor = typedArray.entries();
|
||||
|
||||
var next = itor.next();
|
||||
assert(compareArray(next.value, [0, 0]));
|
||||
assert.sameValue(next.done, false);
|
||||
assert.compareArray(next.value, [0, 0], 'The value of next.value is expected to be [0, 0]');
|
||||
assert.sameValue(next.done, false, 'The value of next.done is expected to be false');
|
||||
|
||||
next = itor.next();
|
||||
assert(compareArray(next.value, [1, 42]));
|
||||
assert.sameValue(next.done, false);
|
||||
assert.compareArray(next.value, [1, 42], 'The value of next.value is expected to be [1, 42]');
|
||||
assert.sameValue(next.done, false, 'The value of next.done is expected to be false');
|
||||
|
||||
next = itor.next();
|
||||
assert(compareArray(next.value, [2, 64]));
|
||||
assert.sameValue(next.done, false);
|
||||
assert.compareArray(next.value, [2, 64], 'The value of next.value is expected to be [2, 64]');
|
||||
assert.sameValue(next.done, false, 'The value of next.done is expected to be false');
|
||||
|
||||
next = itor.next();
|
||||
assert.sameValue(next.value, undefined);
|
||||
assert.sameValue(next.done, true);
|
||||
assert.sameValue(next.value, undefined, 'The value of next.value is expected to equal undefined');
|
||||
assert.sameValue(next.done, true, 'The value of next.done is expected to be true');
|
||||
});
|
||||
|
@ -30,75 +30,64 @@ info: |
|
||||
includes: [compareArray.js, testBigIntTypedArray.js]
|
||||
features: [BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
assert(
|
||||
compareArray(new TA([0n, 0n]).fill(1n, undefined), [1n, 1n]),
|
||||
'`undefined` start coerced to 0'
|
||||
assert.compareArray(
|
||||
new TA([0n, 0n]).fill(1n, undefined),
|
||||
[1n, 1n],
|
||||
'new TA([0n, 0n]).fill(1n, undefined) must return [1n, 1n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(new TA([0n, 0n]).fill(1n, 0, undefined), [1n, 1n]),
|
||||
'If end is undefined, let relativeEnd be len'
|
||||
assert.compareArray(
|
||||
new TA([0n, 0n]).fill(1n, 0, undefined),
|
||||
[1n, 1n],
|
||||
'new TA([0n, 0n]).fill(1n, 0, undefined) must return [1n, 1n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(new TA([0n, 0n]).fill(1n, null), [1n, 1n]),
|
||||
'`null` start coerced to 0'
|
||||
assert.compareArray(new TA([0n, 0n]).fill(1n, null), [1n, 1n], 'new TA([0n, 0n]).fill(1n, null) must return [1n, 1n]');
|
||||
|
||||
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(
|
||||
compareArray(new TA([0n, 0n]).fill(1n, 0, null), [0n, 0n]),
|
||||
'`null` end coerced to 0'
|
||||
assert.compareArray(new TA([0n, 0n]).fill(1n, true), [0n, 1n], 'new TA([0n, 0n]).fill(1n, true) must return [0n, 1n]');
|
||||
|
||||
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(
|
||||
compareArray(new TA([0n, 0n]).fill(1n, true), [0n, 1n]),
|
||||
'`true` start coerced to 1'
|
||||
assert.compareArray(new TA([0n, 0n]).fill(1n, false), [1n, 1n], 'new TA([0n, 0n]).fill(1n, false) must return [1n, 1n]');
|
||||
|
||||
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(
|
||||
compareArray(new TA([0n, 0n]).fill(1n, 0, true), [1n, 0n]),
|
||||
'`true` end coerced to 1'
|
||||
assert.compareArray(new TA([0n, 0n]).fill(1n, NaN), [1n, 1n], 'new TA([0n, 0n]).fill(1n, NaN) must return [1n, 1n]');
|
||||
|
||||
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(
|
||||
compareArray(new TA([0n, 0n]).fill(1n, false), [1n, 1n]),
|
||||
'`false` start coerced to 0'
|
||||
assert.compareArray(new TA([0n, 0n]).fill(1n, '1'), [0n, 1n], 'new TA([0n, 0n]).fill(1n, "1") must return [0n, 1n]');
|
||||
|
||||
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(
|
||||
compareArray(new TA([0n, 0n]).fill(1n, 0, false), [0n, 0n]),
|
||||
'`false` end coerced to 0'
|
||||
);
|
||||
assert.compareArray(new TA([0n, 0n]).fill(1n, 1.5), [0n, 1n], 'new TA([0n, 0n]).fill(1n, 1.5) must return [0n, 1n]');
|
||||
|
||||
assert(
|
||||
compareArray(new TA([0n, 0n]).fill(1n, NaN), [1n, 1n]),
|
||||
'`NaN` start coerced to 0'
|
||||
);
|
||||
|
||||
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'
|
||||
assert.compareArray(
|
||||
new TA([0n, 0n]).fill(1n, 0, 1.5),
|
||||
[1n, 0n],
|
||||
'new TA([0n, 0n]).fill(1n, 0, 1.5) must return [1n, 0n]'
|
||||
);
|
||||
});
|
||||
|
@ -32,11 +32,34 @@ info: |
|
||||
includes: [compareArray.js, testBigIntTypedArray.js]
|
||||
features: [BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
assert(compareArray(new TA([0n, 0n, 0n]).fill(8n, 1, 2), [0n, 8n, 0n]));
|
||||
assert(compareArray(new TA([0n, 0n, 0n, 0n, 0n]).fill(8n, -3, 4), [0n, 0n, 8n, 8n, 0n]));
|
||||
assert(compareArray(new TA([0n, 0n, 0n, 0n, 0n]).fill(8n, -2, -1), [0n, 0n, 0n, 8n, 0n]));
|
||||
assert(compareArray(new TA([0n, 0n, 0n, 0n, 0n]).fill(8n, -1, -3), [0n, 0n, 0n, 0n, 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]).fill(8n, 1, 2),
|
||||
[0n, 8n, 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, -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]'
|
||||
);
|
||||
});
|
||||
|
@ -29,25 +29,28 @@ info: |
|
||||
includes: [compareArray.js, testBigIntTypedArray.js]
|
||||
features: [BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
assert(
|
||||
compareArray(new TA([0n, 0n, 0n]).fill(8n, 0, 1), [8n, 0n, 0n]),
|
||||
"Fill elements from custom end position"
|
||||
assert.compareArray(
|
||||
new TA([0n, 0n, 0n]).fill(8n, 0, 1),
|
||||
[8n, 0n, 0n],
|
||||
'new TA([0n, 0n, 0n]).fill(8n, 0, 1) must return [8n, 0n, 0n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(new TA([0n, 0n, 0n]).fill(8n, 0, -1), [8n, 8n, 0n]),
|
||||
"negative end sets final position to max((length + relativeEnd), 0)"
|
||||
assert.compareArray(
|
||||
new TA([0n, 0n, 0n]).fill(8n, 0, -1),
|
||||
[8n, 8n, 0n],
|
||||
'new TA([0n, 0n, 0n]).fill(8n, 0, -1) must return [8n, 8n, 0n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(new TA([0n, 0n, 0n]).fill(8n, 0, 5), [8n, 8n, 8n]),
|
||||
"end position is never higher than of length"
|
||||
assert.compareArray(
|
||||
new TA([0n, 0n, 0n]).fill(8n, 0, 5),
|
||||
[8n, 8n, 8n],
|
||||
'new TA([0n, 0n, 0n]).fill(8n, 0, 5) must return [8n, 8n, 8n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(new TA([0n, 0n, 0n]).fill(8n, 0, -4), [0n, 0n, 0n]),
|
||||
"end position is 0 when (len + relativeEnd) < 0"
|
||||
assert.compareArray(
|
||||
new TA([0n, 0n, 0n]).fill(8n, 0, -4),
|
||||
[0n, 0n, 0n],
|
||||
'new TA([0n, 0n, 0n]).fill(8n, 0, -4) must return [0n, 0n, 0n]'
|
||||
);
|
||||
});
|
||||
|
@ -27,25 +27,28 @@ info: |
|
||||
includes: [compareArray.js, testBigIntTypedArray.js]
|
||||
features: [BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
assert(
|
||||
compareArray(new TA([0n, 0n, 0n]).fill(8n, 1), [0n, 8n, 8n]),
|
||||
"Fill elements from custom start position"
|
||||
assert.compareArray(
|
||||
new TA([0n, 0n, 0n]).fill(8n, 1),
|
||||
[0n, 8n, 8n],
|
||||
'new TA([0n, 0n, 0n]).fill(8n, 1) must return [0n, 8n, 8n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(new TA([0n, 0n, 0n]).fill(8n, 4), [0n, 0n, 0n]),
|
||||
"start position is never higher than length"
|
||||
assert.compareArray(
|
||||
new TA([0n, 0n, 0n]).fill(8n, 4),
|
||||
[0n, 0n, 0n],
|
||||
'new TA([0n, 0n, 0n]).fill(8n, 4) must return [0n, 0n, 0n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(new TA([0n, 0n, 0n]).fill(8n, -1), [0n, 0n, 8n]),
|
||||
"start < 0 sets initial position to max((len + relativeStart), 0)"
|
||||
assert.compareArray(
|
||||
new TA([0n, 0n, 0n]).fill(8n, -1),
|
||||
[0n, 0n, 8n],
|
||||
'new TA([0n, 0n, 0n]).fill(8n, -1) must return [0n, 0n, 8n]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(new TA([0n, 0n, 0n]).fill(8n, -5), [8n, 8n, 8n]),
|
||||
"start position is 0 when (len + relativeStart) < 0"
|
||||
assert.compareArray(
|
||||
new TA([0n, 0n, 0n]).fill(8n, -5),
|
||||
[8n, 8n, 8n],
|
||||
'new TA([0n, 0n, 0n]).fill(8n, -5) must return [8n, 8n, 8n]'
|
||||
);
|
||||
});
|
||||
|
@ -27,18 +27,12 @@ info: |
|
||||
includes: [compareArray.js, testBigIntTypedArray.js]
|
||||
features: [BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
assert(
|
||||
compareArray(
|
||||
new TA().fill(8n),
|
||||
[]
|
||||
),
|
||||
"does not fill an empty instance"
|
||||
);
|
||||
assert.compareArray(new TA().fill(8n), [], 'new TA().fill(8n) must return []');
|
||||
|
||||
assert(
|
||||
compareArray(new TA([0n, 0n, 0n]).fill(8n), [8n, 8n, 8n]),
|
||||
"Default start and end indexes are 0 and this.length"
|
||||
assert.compareArray(
|
||||
new TA([0n, 0n, 0n]).fill(8n),
|
||||
[8n, 8n, 8n],
|
||||
'new TA([0n, 0n, 0n]).fill(8n) must return [8n, 8n, 8n]'
|
||||
);
|
||||
});
|
||||
|
@ -32,73 +32,73 @@ features: [TypedArray]
|
||||
---*/
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
assert(
|
||||
compareArray(new TA([0, 0]).fill(1, undefined), [1, 1]),
|
||||
'`undefined` start coerced to 0'
|
||||
assert.compareArray(
|
||||
new TA([0, 0]).fill(1, undefined), [1, 1],
|
||||
'new TA([0, 0]).fill(1, undefined) must return [1, 1]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(new TA([0, 0]).fill(1, 0, undefined), [1, 1]),
|
||||
'If end is undefined, let relativeEnd be len'
|
||||
assert.compareArray(
|
||||
new TA([0, 0]).fill(1, 0, undefined), [1, 1],
|
||||
'new TA([0, 0]).fill(1, 0, undefined) must return [1, 1]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(new TA([0, 0]).fill(1, null), [1, 1]),
|
||||
'`null` start coerced to 0'
|
||||
assert.compareArray(
|
||||
new TA([0, 0]).fill(1, null), [1, 1],
|
||||
'new TA([0, 0]).fill(1, null) must return [1, 1]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(new TA([0, 0]).fill(1, 0, null), [0, 0]),
|
||||
'`null` end coerced to 0'
|
||||
assert.compareArray(
|
||||
new TA([0, 0]).fill(1, 0, null), [0, 0],
|
||||
'new TA([0, 0]).fill(1, 0, null) must return [0, 0]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(new TA([0, 0]).fill(1, true), [0, 1]),
|
||||
'`true` start coerced to 1'
|
||||
assert.compareArray(
|
||||
new TA([0, 0]).fill(1, true), [0, 1],
|
||||
'new TA([0, 0]).fill(1, true) must return [0, 1]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(new TA([0, 0]).fill(1, 0, true), [1, 0]),
|
||||
'`true` end coerced to 1'
|
||||
assert.compareArray(
|
||||
new TA([0, 0]).fill(1, 0, true), [1, 0],
|
||||
'new TA([0, 0]).fill(1, 0, true) must return [1, 0]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(new TA([0, 0]).fill(1, false), [1, 1]),
|
||||
'`false` start coerced to 0'
|
||||
assert.compareArray(
|
||||
new TA([0, 0]).fill(1, false), [1, 1],
|
||||
'new TA([0, 0]).fill(1, false) must return [1, 1]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(new TA([0, 0]).fill(1, 0, false), [0, 0]),
|
||||
'`false` end coerced to 0'
|
||||
assert.compareArray(
|
||||
new TA([0, 0]).fill(1, 0, false), [0, 0],
|
||||
'new TA([0, 0]).fill(1, 0, false) must return [0, 0]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(new TA([0, 0]).fill(1, NaN), [1, 1]),
|
||||
'`NaN` start coerced to 0'
|
||||
assert.compareArray(
|
||||
new TA([0, 0]).fill(1, NaN), [1, 1],
|
||||
'new TA([0, 0]).fill(1, NaN) must return [1, 1]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(new TA([0, 0]).fill(1, 0, NaN), [0, 0]),
|
||||
'`NaN` end coerced to 0'
|
||||
assert.compareArray(
|
||||
new TA([0, 0]).fill(1, 0, NaN), [0, 0],
|
||||
'new TA([0, 0]).fill(1, 0, NaN) must return [0, 0]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(new TA([0, 0]).fill(1, '1'), [0, 1]),
|
||||
'string start coerced'
|
||||
assert.compareArray(
|
||||
new TA([0, 0]).fill(1, '1'), [0, 1],
|
||||
'new TA([0, 0]).fill(1, "1") must return [0, 1]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(new TA([0, 0]).fill(1, 0, '1'), [1, 0]),
|
||||
'string end coerced'
|
||||
assert.compareArray(
|
||||
new TA([0, 0]).fill(1, 0, '1'), [1, 0],
|
||||
'new TA([0, 0]).fill(1, 0, "1") must return [1, 0]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(new TA([0, 0]).fill(1, 1.5), [0, 1]),
|
||||
'start as a float number coerced'
|
||||
assert.compareArray(
|
||||
new TA([0, 0]).fill(1, 1.5), [0, 1],
|
||||
'new TA([0, 0]).fill(1, 1.5) must return [0, 1]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(new TA([0, 0]).fill(1, 0, 1.5), [1, 0]),
|
||||
'end as a float number coerced'
|
||||
assert.compareArray(
|
||||
new TA([0, 0]).fill(1, 0, 1.5), [1, 0],
|
||||
'new TA([0, 0]).fill(1, 0, 1.5) must return [1, 0]'
|
||||
);
|
||||
});
|
||||
|
@ -34,9 +34,25 @@ features: [TypedArray]
|
||||
---*/
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
assert(compareArray(new TA([0, 0, 0]).fill(8, 1, 2), [0, 8, 0]));
|
||||
assert(compareArray(new TA([0, 0, 0, 0, 0]).fill(8, -3, 4), [0, 0, 8, 8, 0]));
|
||||
assert(compareArray(new TA([0, 0, 0, 0, 0]).fill(8, -2, -1), [0, 0, 0, 8, 0]));
|
||||
assert(compareArray(new TA([0, 0, 0, 0, 0]).fill(8, -1, -3), [0, 0, 0, 0, 0]));
|
||||
assert(compareArray(new TA([0, 0, 0, 0, 0]).fill(8, 1, 3), [0, 8, 8, 0, 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],
|
||||
'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]'
|
||||
);
|
||||
});
|
||||
|
@ -31,23 +31,23 @@ features: [TypedArray]
|
||||
---*/
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
assert(
|
||||
compareArray(new TA([0, 0, 0]).fill(8, 0, 1), [8, 0, 0]),
|
||||
"Fill elements from custom end position"
|
||||
assert.compareArray(
|
||||
new TA([0, 0, 0]).fill(8, 0, 1), [8, 0, 0],
|
||||
'new TA([0, 0, 0]).fill(8, 0, 1) must return [8, 0, 0]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(new TA([0, 0, 0]).fill(8, 0, -1), [8, 8, 0]),
|
||||
"negative end sets final position to max((length + relativeEnd), 0)"
|
||||
assert.compareArray(
|
||||
new TA([0, 0, 0]).fill(8, 0, -1), [8, 8, 0],
|
||||
'new TA([0, 0, 0]).fill(8, 0, -1) must return [8, 8, 0]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(new TA([0, 0, 0]).fill(8, 0, 5), [8, 8, 8]),
|
||||
"end position is never higher than of length"
|
||||
assert.compareArray(
|
||||
new TA([0, 0, 0]).fill(8, 0, 5), [8, 8, 8],
|
||||
'new TA([0, 0, 0]).fill(8, 0, 5) must return [8, 8, 8]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(new TA([0, 0, 0]).fill(8, 0, -4), [0, 0, 0]),
|
||||
"end position is 0 when (len + relativeEnd) < 0"
|
||||
assert.compareArray(
|
||||
new TA([0, 0, 0]).fill(8, 0, -4), [0, 0, 0],
|
||||
'new TA([0, 0, 0]).fill(8, 0, -4) must return [0, 0, 0]'
|
||||
);
|
||||
});
|
||||
|
@ -29,23 +29,23 @@ features: [TypedArray]
|
||||
---*/
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
assert(
|
||||
compareArray(new TA([0, 0, 0]).fill(8, 1), [0, 8, 8]),
|
||||
"Fill elements from custom start position"
|
||||
assert.compareArray(
|
||||
new TA([0, 0, 0]).fill(8, 1), [0, 8, 8],
|
||||
'new TA([0, 0, 0]).fill(8, 1) must return [0, 8, 8]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(new TA([0, 0, 0]).fill(8, 4), [0, 0, 0]),
|
||||
"start position is never higher than length"
|
||||
assert.compareArray(
|
||||
new TA([0, 0, 0]).fill(8, 4), [0, 0, 0],
|
||||
'new TA([0, 0, 0]).fill(8, 4) must return [0, 0, 0]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(new TA([0, 0, 0]).fill(8, -1), [0, 0, 8]),
|
||||
"start < 0 sets initial position to max((len + relativeStart), 0)"
|
||||
assert.compareArray(
|
||||
new TA([0, 0, 0]).fill(8, -1), [0, 0, 8],
|
||||
'new TA([0, 0, 0]).fill(8, -1) must return [0, 0, 8]'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(new TA([0, 0, 0]).fill(8, -5), [8, 8, 8]),
|
||||
"start position is 0 when (len + relativeStart) < 0"
|
||||
assert.compareArray(
|
||||
new TA([0, 0, 0]).fill(8, -5), [8, 8, 8],
|
||||
'new TA([0, 0, 0]).fill(8, -5) must return [8, 8, 8]'
|
||||
);
|
||||
});
|
||||
|
@ -29,16 +29,13 @@ features: [TypedArray]
|
||||
---*/
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
assert(
|
||||
compareArray(
|
||||
new TA().fill(8),
|
||||
[]
|
||||
),
|
||||
"does not fill an empty instance"
|
||||
assert.compareArray(
|
||||
new TA().fill(8), [],
|
||||
'new TA().fill(8) must return []'
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(new TA([0, 0, 0]).fill(8), [8, 8, 8]),
|
||||
"Default start and end indexes are 0 and this.length"
|
||||
assert.compareArray(
|
||||
new TA([0, 0, 0]).fill(8), [8, 8, 8],
|
||||
'new TA([0, 0, 0]).fill(8) must return [8, 8, 8]'
|
||||
);
|
||||
});
|
||||
|
@ -15,10 +15,7 @@ info: |
|
||||
includes: [testBigIntTypedArray.js, compareArray.js]
|
||||
features: [BigInt, Symbol, TypedArray]
|
||||
---*/
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
var sample = new TA([40n, 41n, 42n]);
|
||||
|
||||
[
|
||||
true,
|
||||
1,
|
||||
@ -32,7 +29,9 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
0.1,
|
||||
-0.1
|
||||
].forEach(function(val) {
|
||||
var result = sample.filter(function() { return val; });
|
||||
assert(compareArray(result, sample), val);
|
||||
const sample = new TA([40n, 41n, 42n]);
|
||||
const result = sample.filter(() => val);
|
||||
|
||||
assert.compareArray(result, sample, 'The value of result is expected to equal the value of sample');
|
||||
});
|
||||
});
|
||||
|
@ -48,7 +48,6 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
};
|
||||
|
||||
result = sample.filter(function() {});
|
||||
|
||||
assert.sameValue(result, other, "returned another typedarray");
|
||||
assert(compareArray(result, [1n, 0n, 1n]), "the returned object is preserved");
|
||||
assert.sameValue(result, other, 'The value of result is expected to equal the value of other');
|
||||
assert.compareArray(result, [1n, 0n, 1n], 'The value of result is expected to be [1n, 0n, 1n]');
|
||||
});
|
||||
|
@ -35,22 +35,23 @@ info: |
|
||||
includes: [testBigIntTypedArray.js, compareArray.js]
|
||||
features: [BigInt, Symbol.species, TypedArray]
|
||||
---*/
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
var sample = new TA([40n, 41n, 42n]);
|
||||
var calls = 0;
|
||||
var other, result;
|
||||
|
||||
sample.constructor = {};
|
||||
|
||||
sample.constructor[Symbol.species] = function(captured) {
|
||||
calls++;
|
||||
other = new TA(captured);
|
||||
return other;
|
||||
};
|
||||
|
||||
result = sample.filter(function() { return true; });
|
||||
result = sample.filter(function() {
|
||||
return true;
|
||||
});
|
||||
|
||||
assert.sameValue(calls, 1, "ctor called once");
|
||||
assert.sameValue(result, other, "return is instance of custom constructor");
|
||||
assert(compareArray(result, [40n, 41n, 42n]), "values are set on the new obj");
|
||||
assert.sameValue(calls, 1, 'The value of calls is expected to be 1');
|
||||
assert.sameValue(result, other, 'The value of result is expected to equal the value of other');
|
||||
assert.compareArray(result, [40n, 41n, 42n], 'The value of result is expected to be [40n, 41n, 42n]');
|
||||
});
|
||||
|
@ -15,16 +15,17 @@ info: |
|
||||
includes: [testBigIntTypedArray.js, compareArray.js]
|
||||
features: [BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
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]), "values are set #1");
|
||||
assert.compareArray(result, [41n, 1n, 42n, 7n], 'The value of result is expected to be [41n, 1n, 42n, 7n]');
|
||||
|
||||
result = sample.filter(function(v) {
|
||||
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]');
|
||||
});
|
||||
|
@ -33,6 +33,6 @@ testWithTypedArrayConstructors(function(TA) {
|
||||
-0.1
|
||||
].forEach(function(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');
|
||||
});
|
||||
});
|
||||
|
@ -49,6 +49,6 @@ testWithTypedArrayConstructors(function(TA) {
|
||||
|
||||
result = sample.filter(function() {});
|
||||
|
||||
assert.sameValue(result, other, "returned another typedarray");
|
||||
assert(compareArray(result, [1, 0, 1]), "the returned object is preserved");
|
||||
assert.sameValue(result, other, 'The value of result is expected to equal the value of other');
|
||||
assert.compareArray(result, [1, 0, 1], 'The value of result is expected to be [1, 0, 1]');
|
||||
});
|
||||
|
@ -50,7 +50,7 @@ testWithTypedArrayConstructors(function(TA) {
|
||||
|
||||
result = sample.filter(function() { return true; });
|
||||
|
||||
assert.sameValue(calls, 1, "ctor called once");
|
||||
assert.sameValue(result, other, "return is instance of custom constructor");
|
||||
assert(compareArray(result, [40, 41, 42]), "values are set on the new obj");
|
||||
assert.sameValue(calls, 1, 'The value of calls is expected to be 1');
|
||||
assert.sameValue(result, other, 'The value of result is expected to equal the value of other');
|
||||
assert.compareArray(result, [40, 41, 42], 'The value of result is expected to be [40, 41, 42]');
|
||||
});
|
||||
|
@ -21,10 +21,10 @@ testWithTypedArrayConstructors(function(TA) {
|
||||
var result;
|
||||
|
||||
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) {
|
||||
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]');
|
||||
});
|
||||
|
@ -28,51 +28,57 @@ info: |
|
||||
includes: [compareArray.js, testBigIntTypedArray.js]
|
||||
features: [BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
var arr = [1n, 2n, 3n];
|
||||
var sample;
|
||||
var result;
|
||||
|
||||
sample = new TA(3);
|
||||
|
||||
sample.find(function(val, i) {
|
||||
sample[i] = arr[i];
|
||||
|
||||
assert.sameValue(val, 0n, "value is not mapped to instance");
|
||||
assert.sameValue(val, 0n, 'The value of val is expected to be 0n');
|
||||
});
|
||||
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);
|
||||
|
||||
result = sample.find(function(val, i) {
|
||||
if ( i === 0 ) {
|
||||
if (i === 0) {
|
||||
sample[2] = 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);
|
||||
|
||||
result = sample.find(function(val, i) {
|
||||
if ( i === 0 ) {
|
||||
if (i === 0) {
|
||||
sample[2] = 7n;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
result = sample.find(function(val, i) {
|
||||
if ( i > 0 ) {
|
||||
if (i > 0) {
|
||||
sample[0] = 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);
|
||||
|
||||
result = sample.find(function() {
|
||||
sample[0] = 7n;
|
||||
return true;
|
||||
});
|
||||
assert.sameValue(result, 1n, "find() returns previous found value");
|
||||
|
||||
assert.sameValue(result, 1n, 'The value of result is expected to be 1n');
|
||||
});
|
||||
|
@ -38,9 +38,9 @@ testWithTypedArrayConstructors(function(TA) {
|
||||
sample.find(function(val, 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);
|
||||
result = sample.find(function(val, i) {
|
||||
@ -49,7 +49,7 @@ testWithTypedArrayConstructors(function(TA) {
|
||||
}
|
||||
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);
|
||||
result = sample.find(function(val, i) {
|
||||
@ -58,7 +58,7 @@ testWithTypedArrayConstructors(function(TA) {
|
||||
}
|
||||
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);
|
||||
result = sample.find(function(val, i) {
|
||||
@ -67,12 +67,12 @@ testWithTypedArrayConstructors(function(TA) {
|
||||
}
|
||||
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);
|
||||
result = sample.find(function() {
|
||||
sample[0] = 7;
|
||||
return true;
|
||||
});
|
||||
assert.sameValue(result, 1, "find() returns previous found value");
|
||||
assert.sameValue(result, 1, 'The value of result is expected to be 1');
|
||||
});
|
||||
|
@ -24,44 +24,49 @@ info: |
|
||||
includes: [compareArray.js, testBigIntTypedArray.js]
|
||||
features: [BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
var arr = [10n, 20n, 30n];
|
||||
var sample;
|
||||
var result;
|
||||
|
||||
sample = new TA(3);
|
||||
|
||||
sample.findIndex(function(val, i) {
|
||||
sample[i] = arr[i];
|
||||
|
||||
assert.sameValue(val, 0n, "value is not mapped to instance");
|
||||
assert.sameValue(val, 0n, 'The value of val is expected to be 0n');
|
||||
});
|
||||
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);
|
||||
|
||||
result = sample.findIndex(function(val, i) {
|
||||
if ( i === 0 ) {
|
||||
if (i === 0) {
|
||||
sample[2] = 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);
|
||||
|
||||
result = sample.findIndex(function(val, i) {
|
||||
if ( i === 0 ) {
|
||||
if (i === 0) {
|
||||
sample[2] = 7n;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
result = sample.findIndex(function(val, i) {
|
||||
if ( i > 0 ) {
|
||||
if (i > 0) {
|
||||
sample[0] = 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');
|
||||
});
|
||||
|
@ -34,9 +34,9 @@ testWithTypedArrayConstructors(function(TA) {
|
||||
sample.findIndex(function(val, 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);
|
||||
result = sample.findIndex(function(val, i) {
|
||||
@ -45,7 +45,7 @@ testWithTypedArrayConstructors(function(TA) {
|
||||
}
|
||||
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);
|
||||
result = sample.findIndex(function(val, i) {
|
||||
@ -54,7 +54,7 @@ testWithTypedArrayConstructors(function(TA) {
|
||||
}
|
||||
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);
|
||||
result = sample.findIndex(function(val, i) {
|
||||
@ -63,5 +63,5 @@ testWithTypedArrayConstructors(function(TA) {
|
||||
}
|
||||
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');
|
||||
});
|
||||
|
@ -17,50 +17,69 @@ includes: [compareArray.js, testBigIntTypedArray.js]
|
||||
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) {
|
||||
var arr = [1n, 2n, 3n];
|
||||
var sample;
|
||||
var result;
|
||||
|
||||
sample = new TA(3);
|
||||
|
||||
sample.findLast(function(val, i) {
|
||||
sample[i] = arr[i];
|
||||
|
||||
assert.sameValue(val, 0n, "value is not mapped to instance");
|
||||
assert.sameValue(val, 0n, 'The value of val is expected to be 0n');
|
||||
});
|
||||
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);
|
||||
|
||||
result = sample.findLast(function(val, i) {
|
||||
if ( i === 2 ) {
|
||||
if (i === 2) {
|
||||
sample[0] = 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);
|
||||
|
||||
result = sample.findLast(function(val, i) {
|
||||
if ( i === 2 ) {
|
||||
if (i === 2) {
|
||||
sample[0] = 7n;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
result = sample.findLast(function(val, i) {
|
||||
if ( i < 2 ) {
|
||||
if (i < 2) {
|
||||
sample[2] = 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);
|
||||
|
||||
result = sample.findLast(function() {
|
||||
sample[2] = 7n;
|
||||
return true;
|
||||
});
|
||||
assert.sameValue(result, 3n, "findLast() returns previous found value");
|
||||
|
||||
assert.sameValue(result, 3n, 'The value of result is expected to be 3n');
|
||||
});
|
||||
|
@ -17,6 +17,18 @@ includes: [compareArray.js, testTypedArray.js]
|
||||
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) {
|
||||
var arr = [1, 2, 3];
|
||||
var sample;
|
||||
@ -26,9 +38,9 @@ testWithTypedArrayConstructors(function(TA) {
|
||||
sample.findLast(function(val, 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);
|
||||
result = sample.findLast(function(val, i) {
|
||||
@ -37,7 +49,7 @@ testWithTypedArrayConstructors(function(TA) {
|
||||
}
|
||||
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);
|
||||
result = sample.findLast(function(val, i) {
|
||||
@ -46,7 +58,7 @@ testWithTypedArrayConstructors(function(TA) {
|
||||
}
|
||||
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);
|
||||
result = sample.findLast(function(val, i) {
|
||||
@ -55,12 +67,12 @@ testWithTypedArrayConstructors(function(TA) {
|
||||
}
|
||||
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);
|
||||
result = sample.findLast(function() {
|
||||
sample[2] = 7;
|
||||
return true;
|
||||
});
|
||||
assert.sameValue(result, 3, "findLast() returns previous found value");
|
||||
assert.sameValue(result, 3, 'The value of result is expected to be 3');
|
||||
});
|
||||
|
@ -16,43 +16,61 @@ includes: [compareArray.js, testBigIntTypedArray.js]
|
||||
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) {
|
||||
var arr = [10n, 20n, 30n];
|
||||
var sample;
|
||||
var result;
|
||||
|
||||
sample = new TA(3);
|
||||
|
||||
sample.findLastIndex(function(val, i) {
|
||||
sample[i] = arr[i];
|
||||
|
||||
assert.sameValue(val, 0n, "value is not mapped to instance");
|
||||
assert.sameValue(val, 0n, 'The value of val is expected to be 0n');
|
||||
});
|
||||
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);
|
||||
|
||||
result = sample.findLastIndex(function(val, i) {
|
||||
if ( i === 2 ) {
|
||||
if (i === 2) {
|
||||
sample[0] = 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);
|
||||
|
||||
result = sample.findLastIndex(function(val, i) {
|
||||
if ( i === 2 ) {
|
||||
if (i === 2) {
|
||||
sample[0] = 7n;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
result = sample.findLastIndex(function(val, i) {
|
||||
if ( i < 2 ) {
|
||||
if (i < 2) {
|
||||
sample[2] = 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');
|
||||
});
|
||||
|
@ -16,6 +16,18 @@ includes: [compareArray.js, testTypedArray.js]
|
||||
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) {
|
||||
var arr = [10, 20, 30];
|
||||
var sample;
|
||||
@ -25,9 +37,9 @@ testWithTypedArrayConstructors(function(TA) {
|
||||
sample.findLastIndex(function(val, 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);
|
||||
result = sample.findLastIndex(function(val, i) {
|
||||
@ -36,7 +48,7 @@ testWithTypedArrayConstructors(function(TA) {
|
||||
}
|
||||
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);
|
||||
result = sample.findLastIndex(function(val, i) {
|
||||
@ -45,7 +57,7 @@ testWithTypedArrayConstructors(function(TA) {
|
||||
}
|
||||
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);
|
||||
result = sample.findLastIndex(function(val, i) {
|
||||
@ -54,5 +66,5 @@ testWithTypedArrayConstructors(function(TA) {
|
||||
}
|
||||
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');
|
||||
});
|
||||
|
@ -35,20 +35,21 @@ info: |
|
||||
includes: [testBigIntTypedArray.js, compareArray.js]
|
||||
features: [BigInt, Symbol.species, TypedArray]
|
||||
---*/
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
var sample = new TA([40n]);
|
||||
var otherTA = TA === BigInt64Array ? BigUint64Array : BigInt64Array;
|
||||
var other = new otherTA([1n, 0n, 1n]);
|
||||
var result;
|
||||
|
||||
sample.constructor = {};
|
||||
|
||||
sample.constructor[Symbol.species] = function() {
|
||||
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(compareArray(result, [47n, 0n, 1n]), "values are set on returned typedarray");
|
||||
assert.sameValue(result, other, 'The value of result is expected to equal the value of other');
|
||||
assert.compareArray(result, [47n, 0n, 1n], 'The value of result is expected to be [47n, 0n, 1n]');
|
||||
});
|
||||
|
@ -35,22 +35,23 @@ info: |
|
||||
includes: [testBigIntTypedArray.js, compareArray.js]
|
||||
features: [BigInt, Symbol.species, TypedArray]
|
||||
---*/
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
var sample = new TA([40n, 41n, 42n]);
|
||||
var calls = 0;
|
||||
var other, result;
|
||||
|
||||
sample.constructor = {};
|
||||
|
||||
sample.constructor[Symbol.species] = function(len) {
|
||||
calls++;
|
||||
other = new TA(len);
|
||||
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(result, other, "return is instance of custom constructor");
|
||||
assert(compareArray(result, [47n, 48n, 49n]), "values are set on the new obj");
|
||||
assert.sameValue(calls, 1, 'The value of calls is expected to be 1');
|
||||
assert.sameValue(result, other, 'The value of result is expected to equal the value of other');
|
||||
assert.compareArray(result, [47n, 48n, 49n], 'The value of result is expected to be [47n, 48n, 49n]');
|
||||
});
|
||||
|
@ -65,7 +65,7 @@ function body(FloatArray) {
|
||||
sampleBytes = new Uint8Array(sample.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]);
|
||||
|
@ -49,6 +49,6 @@ testWithTypedArrayConstructors(function(TA) {
|
||||
|
||||
result = sample.map(function(a) { return a + 7; });
|
||||
|
||||
assert.sameValue(result, other, "returned another typedarray");
|
||||
assert(compareArray(result, [47, 0, 1]), "values are set on returned typedarray");
|
||||
assert.sameValue(result, other, 'The value of result is expected to equal the value of other');
|
||||
assert.compareArray(result, [47, 0, 1], 'The value of result is expected to be [47, 0, 1]');
|
||||
});
|
||||
|
@ -50,7 +50,7 @@ testWithTypedArrayConstructors(function(TA) {
|
||||
|
||||
result = sample.map(function(a) { return a + 7; });
|
||||
|
||||
assert.sameValue(calls, 1, "ctor called once");
|
||||
assert.sameValue(result, other, "return is instance of custom constructor");
|
||||
assert(compareArray(result, [47, 48, 49]), "values are set on the new obj");
|
||||
assert.sameValue(calls, 1, 'The value of calls is expected to be 1');
|
||||
assert.sameValue(result, other, 'The value of result is expected to equal the value of other');
|
||||
assert.compareArray(result, [47, 48, 49], 'The value of result is expected to be [47, 48, 49]');
|
||||
});
|
||||
|
@ -18,40 +18,25 @@ info: |
|
||||
includes: [testBigIntTypedArray.js, compareArray.js]
|
||||
features: [BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
var buffer = new ArrayBuffer(64);
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
var sample = new TA(buffer, 0, 4);
|
||||
var other = new TA(buffer, 0, 5);
|
||||
|
||||
sample[0] = 42n;
|
||||
sample[1] = 43n;
|
||||
sample[2] = 2n;
|
||||
sample[3] = 1n;
|
||||
other[4] = 7n;
|
||||
|
||||
sample.reverse();
|
||||
assert(
|
||||
compareArray(sample, [1n, 2n, 43n, 42n])
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(other, [1n, 2n, 43n, 42n, 7n])
|
||||
);
|
||||
|
||||
assert.compareArray(sample, [1n, 2n, 43n, 42n], 'The value of sample is expected to be [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]');
|
||||
sample[0] = 7n;
|
||||
sample[1] = 17n;
|
||||
sample[2] = 1n;
|
||||
sample[3] = 0n;
|
||||
other[4] = 42n;
|
||||
|
||||
other.reverse();
|
||||
assert(
|
||||
compareArray(other, [42n, 0n, 1n, 17n, 7n])
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(sample, [42n, 0n, 1n, 17n])
|
||||
);
|
||||
assert.compareArray(other, [42n, 0n, 1n, 17n, 7n], 'The value of other is expected to be [42n, 0n, 1n, 17n, 7n]');
|
||||
assert.compareArray(sample, [42n, 0n, 1n, 17n], 'The value of sample is expected to be [42n, 0n, 1n, 17n]');
|
||||
});
|
||||
|
@ -32,13 +32,8 @@ testWithTypedArrayConstructors(function(TA) {
|
||||
other[4] = 7;
|
||||
|
||||
sample.reverse();
|
||||
assert(
|
||||
compareArray(sample, [1, 2, 43, 42])
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(other, [1, 2, 43, 42, 7])
|
||||
);
|
||||
assert.compareArray(sample, [1, 2, 43, 42], 'The value of sample is expected to be [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]');
|
||||
|
||||
sample[0] = 7;
|
||||
sample[1] = 17;
|
||||
@ -47,11 +42,6 @@ testWithTypedArrayConstructors(function(TA) {
|
||||
other[4] = 42;
|
||||
|
||||
other.reverse();
|
||||
assert(
|
||||
compareArray(other, [42, 0, 1, 17, 7])
|
||||
);
|
||||
|
||||
assert(
|
||||
compareArray(sample, [42, 0, 1, 17])
|
||||
);
|
||||
assert.compareArray(other, [42, 0, 1, 17, 7], 'The value of other is expected to be [42, 0, 1, 17, 7]');
|
||||
assert.compareArray(sample, [42, 0, 1, 17], 'The value of sample is expected to be [42, 0, 1, 17]');
|
||||
});
|
||||
|
@ -17,79 +17,72 @@ info: |
|
||||
includes: [testBigIntTypedArray.js, compareArray.js]
|
||||
features: [BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
var sample;
|
||||
|
||||
sample = new TA([1n, 2n]);
|
||||
sample.set([42n], "");
|
||||
assert(compareArray(sample, [42n, 2n]), "the empty string");
|
||||
|
||||
sample.set([42n], '');
|
||||
assert.compareArray(sample, [42n, 2n], 'The value of sample is expected to be [42n, 2n]');
|
||||
sample = new TA([1n, 2n]);
|
||||
sample.set([42n], "0");
|
||||
assert(compareArray(sample, [42n, 2n]), "'0'");
|
||||
|
||||
sample.set([42n], '0');
|
||||
assert.compareArray(sample, [42n, 2n], 'The value of sample is expected to be [42n, 2n]');
|
||||
sample = new TA([1n, 2n]);
|
||||
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.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.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.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.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.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.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.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.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.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.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.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.set([42n], "1");
|
||||
assert(compareArray(sample, [1n, 42n]), "'1'");
|
||||
|
||||
sample.set([42n], '1');
|
||||
assert.compareArray(sample, [1n, 42n], 'The value of sample is expected to be [1n, 42n]');
|
||||
sample = new TA([1n, 2n]);
|
||||
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.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.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]');
|
||||
});
|
||||
|
@ -21,28 +21,25 @@ info: |
|
||||
includes: [testBigIntTypedArray.js, compareArray.js]
|
||||
features: [BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
var obj = {
|
||||
length: 4,
|
||||
"0": 42n,
|
||||
"1": 43n,
|
||||
"3": 44n
|
||||
};
|
||||
Object.defineProperty(obj, "2", {
|
||||
get: function() {
|
||||
throw new Test262Error();
|
||||
}
|
||||
});
|
||||
length: 4,
|
||||
'0': 42n,
|
||||
'1': 43n,
|
||||
'3': 44n
|
||||
};
|
||||
|
||||
Object.defineProperty(obj, '2', {
|
||||
get: function() {
|
||||
throw new Test262Error();
|
||||
}
|
||||
});
|
||||
|
||||
var sample = new TA([1n, 2n, 3n, 4n]);
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
sample.set(obj);
|
||||
});
|
||||
}, 'sample.set(obj) throws a Test262Error exception');
|
||||
|
||||
assert(
|
||||
compareArray(sample, [42n, 43n, 3n, 4n]),
|
||||
"values are set until exception"
|
||||
);
|
||||
assert.compareArray(sample, [42n, 43n, 3n, 4n], 'The value of sample is expected to be [42n, 43n, 3n, 4n]');
|
||||
});
|
||||
|
@ -21,24 +21,20 @@ info: |
|
||||
includes: [testBigIntTypedArray.js, compareArray.js]
|
||||
features: [BigInt, Symbol, TypedArray]
|
||||
---*/
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
var obj = {
|
||||
length: 4,
|
||||
"0": 42n,
|
||||
"1": 43n,
|
||||
"2": Symbol("1"),
|
||||
"3": 44n
|
||||
length: 4,
|
||||
'0': 42n,
|
||||
'1': 43n,
|
||||
'2': Symbol('1'),
|
||||
'3': 44n
|
||||
};
|
||||
|
||||
var sample = new TA([1n, 2n, 3n, 4n]);
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
sample.set(obj);
|
||||
});
|
||||
}, 'sample.set(obj) throws a TypeError exception');
|
||||
|
||||
assert(
|
||||
compareArray(sample, [42n, 43n, 3n, 4n]),
|
||||
"values are set until exception"
|
||||
);
|
||||
assert.compareArray(sample, [42n, 43n, 3n, 4n], 'The value of sample is expected to be [42n, 43n, 3n, 4n]');
|
||||
});
|
||||
|
@ -21,28 +21,26 @@ info: |
|
||||
includes: [testBigIntTypedArray.js, compareArray.js]
|
||||
features: [BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
var obj = {
|
||||
length: 4,
|
||||
"0": 42n,
|
||||
"1": 43n,
|
||||
"2": {
|
||||
valueOf: function() {
|
||||
throw new Test262Error();
|
||||
}
|
||||
},
|
||||
"3": 44n
|
||||
length: 4,
|
||||
'0': 42n,
|
||||
'1': 43n,
|
||||
|
||||
'2': {
|
||||
valueOf: function() {
|
||||
throw new Test262Error();
|
||||
}
|
||||
},
|
||||
|
||||
'3': 44n
|
||||
};
|
||||
|
||||
var sample = new TA([1n, 2n, 3n, 4n]);
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
sample.set(obj);
|
||||
});
|
||||
}, 'sample.set(obj) throws a Test262Error exception');
|
||||
|
||||
assert(
|
||||
compareArray(sample, [42n, 43n, 3n, 4n]),
|
||||
"values are set until exception"
|
||||
);
|
||||
assert.compareArray(sample, [42n, 43n, 3n, 4n], 'The value of sample is expected to be [42n, 43n, 3n, 4n]');
|
||||
});
|
||||
|
@ -21,13 +21,14 @@ info: |
|
||||
includes: [testBigIntTypedArray.js, compareArray.js]
|
||||
features: [BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
var sample = new TA(5);
|
||||
var calls = [];
|
||||
|
||||
var obj = {
|
||||
length: 3
|
||||
};
|
||||
|
||||
Object.defineProperty(obj, 0, {
|
||||
get: function() {
|
||||
calls.push(0);
|
||||
@ -54,19 +55,16 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
|
||||
Object.defineProperty(obj, 3, {
|
||||
get: function() {
|
||||
throw new Test262Error("Should not call obj[3]");
|
||||
throw new Test262Error('Should not call obj[3]');
|
||||
}
|
||||
});
|
||||
|
||||
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(
|
||||
compareArray(sample, [0n, 42n, 43n, 44n, 0n]),
|
||||
"values are set for src length"
|
||||
);
|
||||
|
||||
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"
|
||||
assert.compareArray(
|
||||
calls,
|
||||
[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"]'
|
||||
);
|
||||
});
|
||||
|
@ -21,43 +21,38 @@ info: |
|
||||
includes: [testBigIntTypedArray.js, compareArray.js]
|
||||
features: [BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
var src = [42n, 43n];
|
||||
|
||||
var srcObj = {
|
||||
length: 2,
|
||||
'0': 7n,
|
||||
'1': 17n
|
||||
};
|
||||
var sample, result;
|
||||
|
||||
var sample, result;
|
||||
sample = new TA([1n, 2n, 3n, 4n]);
|
||||
result = sample.set(src, 0);
|
||||
assert(compareArray(sample, [42n, 43n, 3n, 4n]), "offset: 0, result: " + sample);
|
||||
assert.sameValue(result, undefined, "returns undefined");
|
||||
|
||||
assert.compareArray(sample, [42n, 43n, 3n, 4n], 'The value of sample is expected to be [42n, 43n, 3n, 4n]');
|
||||
assert.sameValue(result, undefined, 'The value of result is expected to equal undefined');
|
||||
sample = new TA([1n, 2n, 3n, 4n]);
|
||||
result = sample.set(src, 1);
|
||||
assert(compareArray(sample, [1n, 42n, 43n, 4n]), "offset: 1, result: " + sample);
|
||||
assert.sameValue(result, undefined, "returns undefined");
|
||||
|
||||
assert.compareArray(sample, [1n, 42n, 43n, 4n], 'The value of sample is expected to be [1n, 42n, 43n, 4n]');
|
||||
assert.sameValue(result, undefined, 'The value of result is expected to equal undefined');
|
||||
sample = new TA([1n, 2n, 3n, 4n]);
|
||||
result = sample.set(src, 2);
|
||||
assert(compareArray(sample, [1n, 2n, 42n, 43n]), "offset: 2, result: " + sample);
|
||||
assert.sameValue(result, undefined, "returns undefined");
|
||||
|
||||
assert.compareArray(sample, [1n, 2n, 42n, 43n], 'The value of sample is expected to be [1n, 2n, 42n, 43n]');
|
||||
assert.sameValue(result, undefined, 'The value of result is expected to equal undefined');
|
||||
sample = new TA([1n, 2n, 3n, 4n]);
|
||||
result = sample.set(srcObj, 0);
|
||||
assert(compareArray(sample, [7n, 17n, 3n, 4n]), "offset: 0, result: " + sample);
|
||||
assert.sameValue(result, undefined, "returns undefined");
|
||||
|
||||
assert.compareArray(sample, [7n, 17n, 3n, 4n], 'The value of sample is expected to be [7n, 17n, 3n, 4n]');
|
||||
assert.sameValue(result, undefined, 'The value of result is expected to equal undefined');
|
||||
sample = new TA([1n, 2n, 3n, 4n]);
|
||||
result = sample.set(srcObj, 1);
|
||||
assert(compareArray(sample, [1n, 7n, 17n, 4n]), "offset: 1, result: " + sample);
|
||||
assert.sameValue(result, undefined, "returns undefined");
|
||||
|
||||
assert.compareArray(sample, [1n, 7n, 17n, 4n], 'The value of sample is expected to be [1n, 7n, 17n, 4n]');
|
||||
assert.sameValue(result, undefined, 'The value of result is expected to equal undefined');
|
||||
sample = new TA([1n, 2n, 3n, 4n]);
|
||||
result = sample.set(srcObj, 2);
|
||||
assert(compareArray(sample, [1n, 2n, 7n, 17n]), "offset: 2, result: " + sample);
|
||||
assert.sameValue(result, undefined, "returns undefined");
|
||||
assert.compareArray(sample, [1n, 2n, 7n, 17n], 'The value of sample is expected to be [1n, 2n, 7n, 17n]');
|
||||
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
Loading…
x
Reference in New Issue
Block a user