Restore original tests for TypedArrays and optimize files

- optimize file names
- BigInt folder for TAs.from and of
- copy tests preparing for bigint
- copy ta prototype methods for bigint
- Use an exclusive harness for bigint typedarrays
- add features
- use proper harness
- use preper harness
- Restore original tests for TypedArrays
- final fixes
- fix includes
This commit is contained in:
Leo Balter 2018-02-09 13:39:06 -05:00
parent 5722ac494b
commit c1bc43b1b1
1039 changed files with 33943 additions and 385 deletions

View File

@ -0,0 +1,77 @@
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: |
Collection of functions used to assert the correctness of BigInt TypedArray objects.
---*/
/**
* Array containing every typed array constructor.
*/
var BigIntTypedArrayConstructors = [
BigInt64Array,
BigUint64Array
];
/**
* The %TypedArray% intrinsic constructor function.
*/
var TypedArray = Object.getPrototypeOf(Int8Array);
function convertToBigInt(x) {
return (Array.isArray(x)) ? x.map(convertToBigInt) : BigInt(x);
}
/**
* Callback for testing a typed array constructor.
*
* @callback typedArrayConstructorCallback
* @param {Function} Constructor the constructor object to test with.
*/
/**
* Calls the provided function for every typed array constructor.
*
* @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
* @param {Array} selected - An optional Array with filtered typed arrays
*/
function testWithBigIntTypedArrayConstructors(f, selected) {
var constructors = selected || BigIntTypedArrayConstructors;
for (var i = 0; i < constructors.length; ++i) {
var constructor = constructors[i];
try {
f(constructor);
} catch (e) {
e.message += " (Testing with " + constructor.name + ".)";
throw e;
}
}
}
/**
* Helper for conversion operations on TypedArrays, the expected values
* properties are indexed in order to match the respective value for each
* TypedArray constructor
* @param {Function} fn - the function to call for each constructor and value.
* will be called with the constructor, value, expected
* value, and a initial value that can be used to avoid
* a false positive with an equivalent expected value.
*/
function testBigIntTypedArrayConversions(byteConversionValues, fn) {
var values = byteConversionValues.values;
var expected = byteConversionValues.expected;
testWithBigIntTypedArrayConstructors(function(TA) {
var name = TA.name.slice(0, -5);
return values.forEach(function(value, index) {
var exp = expected[name][index];
var initial = 0;
if (exp === 0) {
initial = 1;
}
fn(TA, value, exp, initial);
});
});
}

View File

@ -20,22 +20,11 @@ var typedArrayConstructors = [
Uint8ClampedArray
];
var numericTypedArrayConstructors = typedArrayConstructors.slice();
if (typeof BigInt !== "undefined") {
typedArrayConstructors.push(BigInt64Array);
typedArrayConstructors.push(BigUint64Array);
}
/**
* The %TypedArray% intrinsic constructor function.
*/
var TypedArray = Object.getPrototypeOf(Int8Array);
function convertToBigInt(x) {
return (Array.isArray(x)) ? x.map(convertToBigInt) : BigInt(x);
}
/**
* Callback for testing a typed array constructor.
*
@ -52,12 +41,9 @@ function convertToBigInt(x) {
function testWithTypedArrayConstructors(f, selected) {
var constructors = selected || typedArrayConstructors;
for (var i = 0; i < constructors.length; ++i) {
// TODO: Remove this
var N = function(x) { return x; };
var constructor = constructors[i];
if (constructor.name == "BigInt64Array" ||
constructor.name == "BigUint64Array") {
N = convertToBigInt;
}
try {
f(constructor, N);
} catch (e) {

View File

@ -0,0 +1,21 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-get-%typedarray%.prototype-@@tostringtag
description: The getter method does not throw with a detached buffer
info: |
22.2.3.32 get %TypedArray%.prototype [ @@toStringTag ]
...
4. Let name be the value of O's [[TypedArrayName]] internal slot.
5. Assert: name is a String value.
6. Return name.
includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
features: [BigInt, Symbol.toStringTag, TypedArray]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA(1);
$DETACHBUFFER(sample.buffer);
assert.sameValue(sample[Symbol.toStringTag], TA.name);
});

View File

@ -0,0 +1,20 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.2.3.31
description: >
Return undefined if this value does not have a [[TypedArrayName]] internal slot
info: |
22.2.3.31 get %TypedArray%.prototype [ @@toStringTag ]
1. Let O be the this value.
...
3. If O does not have a [[TypedArrayName]] internal slot, return undefined.
...
includes: [testBigIntTypedArray.js]
features: [BigInt, Symbol.toStringTag, TypedArray]
---*/
var TypedArrayPrototype = TypedArray.prototype;
assert.sameValue(TypedArrayPrototype[Symbol.toStringTag], undefined);

View File

@ -0,0 +1,21 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.2.3.31
description: If this value is not Object, return undefined.
info: |
22.2.3.31 get %TypedArray%.prototype [ @@toStringTag ]
1. Let O be the this value.
2. If Type(O) is not Object, return undefined.
...
includes: [testBigIntTypedArray.js]
features: [BigInt, Symbol.toStringTag, TypedArray]
---*/
var TypedArrayPrototype = TypedArray.prototype;
var getter = Object.getOwnPropertyDescriptor(
TypedArrayPrototype, Symbol.toStringTag
).get;
assert.sameValue(getter(), undefined);

View File

@ -0,0 +1,32 @@
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.2.3.31
description: >
get %TypedArray%.prototype [ @@toStringTag ].length is 0.
info: |
get %TypedArray%.prototype [ @@toStringTag ]
17 ECMAScript Standard Built-in Objects:
Every built-in Function object, including constructors, has a length
property whose value is an integer. Unless otherwise specified, this
value is equal to the largest number of named arguments shown in the
subclause headings for the function description, including optional
parameters. However, rest parameters shown using the form ...name
are not included in the default argument count.
Unless otherwise specified, the length property of a built-in Function
object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
[[Configurable]]: true }.
includes: [propertyHelper.js, testBigIntTypedArray.js]
features: [BigInt, Symbol.toStringTag]
---*/
var desc = Object.getOwnPropertyDescriptor(TypedArray.prototype, Symbol.toStringTag);
assert.sameValue(desc.get.length, 0);
verifyNotEnumerable(desc.get, "length");
verifyNotWritable(desc.get, "length");
verifyConfigurable(desc.get, "length");

View File

@ -0,0 +1,29 @@
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.2.3.31
description: >
get %TypedArray%.prototype [ @@toStringTag ].name is "get [Symbol.toStringTag]".
info: |
get %TypedArray%.prototype [ @@toStringTag ]
17 ECMAScript Standard Built-in Objects:
Every built-in Function object, including constructors, that is not
identified as an anonymous function has a name property whose value
is a String.
Unless otherwise specified, the name property of a built-in Function
object, if it exists, has the attributes { [[Writable]]: false,
[[Enumerable]]: false, [[Configurable]]: true }.
includes: [propertyHelper.js, testBigIntTypedArray.js]
features: [BigInt, Symbol.toStringTag]
---*/
var desc = Object.getOwnPropertyDescriptor(TypedArray.prototype, Symbol.toStringTag);
assert.sameValue(desc.get.name, "get [Symbol.toStringTag]");
verifyNotEnumerable(desc.get, "name");
verifyNotWritable(desc.get, "name");
verifyConfigurable(desc.get, "name");

View File

@ -0,0 +1,28 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.2.3.31
description: >
"@@toStringTag" property of TypedArrayPrototype
info: |
22.2.3.31 get %TypedArray%.prototype [ @@toStringTag ]
%TypedArray%.prototype[@@toStringTag] is an accessor property whose set
accessor function is undefined.
...
This property has the attributes { [[Enumerable]]: false, [[Configurable]]:
true }.
includes: [propertyHelper.js, testBigIntTypedArray.js]
features: [BigInt, Symbol.toStringTag]
---*/
var TypedArrayPrototype = TypedArray.prototype;
var desc = Object.getOwnPropertyDescriptor(
TypedArrayPrototype, Symbol.toStringTag
);
assert.sameValue(desc.set, undefined);
assert.sameValue(typeof desc.get, 'function');
verifyNotEnumerable(TypedArrayPrototype, Symbol.toStringTag);
verifyConfigurable(TypedArrayPrototype, Symbol.toStringTag);

View File

@ -0,0 +1,21 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-get-%typedarray%.prototype-@@tostringtag
description: >
Return value from the [[TypedArrayName]] internal slot
info: |
22.2.3.32 get %TypedArray%.prototype [ @@toStringTag ]
...
4. Let name be the value of O's [[TypedArrayName]] internal slot.
5. Assert: name is a String value.
6. Return name.
includes: [testBigIntTypedArray.js]
features: [BigInt, Symbol.toStringTag, TypedArray]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
var ta = new TA();
assert.sameValue(ta[Symbol.toStringTag], TA.name, "property value");
});

View File

@ -0,0 +1,29 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-get-%typedarray%.prototype-@@tostringtag
description: >
Return undefined when `this` does not have a [[TypedArrayName]] internal slot
info: |
22.2.3.32 get %TypedArray%.prototype [ @@toStringTag ]
1. Let O be the this value.
...
3. If O does not have a [[TypedArrayName]] internal slot, return undefined.
...
includes: [testBigIntTypedArray.js]
features: [BigInt, Symbol.toStringTag, DataView, TypedArray]
---*/
var TypedArrayPrototype = TypedArray.prototype;
var getter = Object.getOwnPropertyDescriptor(
TypedArrayPrototype, Symbol.toStringTag
).get;
assert.sameValue(getter.call({}), undefined);
assert.sameValue(getter.call([]), undefined);
assert.sameValue(getter.call(new ArrayBuffer(8)), undefined);
var ab = new ArrayBuffer(8);
var dv = new DataView(ab, 0, 1);
assert.sameValue(getter.call(dv), undefined);

View File

@ -0,0 +1,27 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-get-%typedarray%.prototype-@@tostringtag
description: Return undefined when `this` is not Object
info: |
22.2.3.32 get %TypedArray%.prototype [ @@toStringTag ]
1. Let O be the this value.
2. If Type(O) is not Object, return undefined.
...
includes: [testBigIntTypedArray.js]
features: [BigInt, Symbol, Symbol.toStringTag, TypedArray]
---*/
var TypedArrayPrototype = TypedArray.prototype;
var getter = Object.getOwnPropertyDescriptor(
TypedArrayPrototype, Symbol.toStringTag
).get;
assert.sameValue(getter.call(undefined), undefined, "this is undefined");
assert.sameValue(getter.call(42), undefined, "this is 42");
assert.sameValue(getter.call("foo"), undefined, "this is a string");
assert.sameValue(getter.call(true), undefined, "this is true");
assert.sameValue(getter.call(false), undefined, "this is false");
assert.sameValue(getter.call(Symbol("s")), undefined, "this is a Symbol");
assert.sameValue(getter.call(null), undefined, "this is null");

View File

@ -0,0 +1,21 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-get-%typedarray%.prototype.buffer
description: The getter method does not throw with a detached buffer
info: |
22.2.3.1 get %TypedArray%.prototype.buffer
...
4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot.
5. Return buffer.
includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
features: [BigInt, TypedArray]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
var buffer = new ArrayBuffer(8);
var sample = new TA(buffer, 0, 1);
$DETACHBUFFER(sample.buffer);
assert.sameValue(sample.buffer, buffer);
}, [BigInt64Array, BigUint64Array]);

View File

@ -0,0 +1,22 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.2.3.1
description: >
Return buffer from [[ViewedArrayBuffer]] internal slot
info: |
22.2.3.1 get %TypedArray%.prototype.buffer
...
4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot.
5. Return buffer.
includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
var buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT);
var ta = new TA(buffer);
assert.sameValue(ta.buffer, buffer);
}, [BigInt64Array, BigUint64Array]);

View File

@ -0,0 +1,21 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-get-%typedarray%.prototype.bytelength
description: Returns 0 if the instance has a detached buffer
info: |
22.2.3.2 get %TypedArray%.prototype.byteLength
...
4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot.
5. If IsDetachedBuffer(buffer) is true, return 0.
...
includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
features: [BigInt, TypedArray]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA(1);
$DETACHBUFFER(sample.buffer);
assert.sameValue(sample.byteLength, 0);
});

View File

@ -0,0 +1,24 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.2.3.2
description: >
Return value from [[ByteLength]] internal slot
info: |
22.2.3.2 get %TypedArray%.prototype.byteLength
...
6. Let size be the value of O's [[ByteLength]] internal slot.
7. Return size.
includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
var bytesPerElement = TA.BYTES_PER_ELEMENT;
var ta1 = new TA();
assert.sameValue(ta1.byteLength, 0);
var ta2 = new TA(42);
assert.sameValue(ta2.byteLength, 42 * bytesPerElement);
});

View File

@ -0,0 +1,22 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-get-%typedarray%.prototype.byteoffset
description: Returns 0 if the instance has a detached buffer
info: |
22.2.3.3 get %TypedArray%.prototype.byteOffset
...
4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot.
5. If IsDetachedBuffer(buffer) is true, return 0.
...
includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
features: [BigInt, TypedArray]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
var buffer = new ArrayBuffer(128);
var sample = new TA(buffer, 8, 1);
$DETACHBUFFER(sample.buffer);
assert.sameValue(sample.byteOffset, 0);
});

View File

@ -0,0 +1,31 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.2.3.3
description: >
Return value from [[ByteOffset]] internal slot
info: |
22.2.3.3 get %TypedArray%.prototype.byteOffset
...
6. Let offset be the value of O's [[ByteOffset]] internal slot.
7. Return size.
includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
var ta1 = new TA();
assert.sameValue(ta1.byteOffset, 0, "Regular typedArray");
var offset = 4 * TA.BYTES_PER_ELEMENT;
var buffer1 = new ArrayBuffer(8 * TA.BYTES_PER_ELEMENT);
var ta2 = new TA(buffer1, offset);
assert.sameValue(ta2.byteOffset, offset, "TA(buffer, offset)");
var buffer2 = new ArrayBuffer(8 * TA.BYTES_PER_ELEMENT);
var sample = new TA(buffer2, offset);
var ta3 = new TA(sample);
assert.sameValue(ta3.byteOffset, 0, "TA(typedArray)");
});

View File

@ -0,0 +1,77 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.copywithin
es6id: 22.2.3.5
description: >
end argument is coerced to an integer values.
info: |
22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
%TypedArray%.prototype.copyWithin is a distinct function that implements the
same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
that the this object's [[ArrayLength]] internal slot is accessed in place of
performing a [[Get]] of "length" and the actual copying of values in step 12
must be performed in a manner that preserves the bit-level encoding of the
source data.
...
22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
...
7. If end is undefined, let relativeEnd be len; else let relativeEnd be ?
ToInteger(end).
...
includes: [compareArray.js, testBigIntTypedArray.js]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3])).copyWithin(1, 0, null),
convertToBigInt([0, 1, 2, 3])
),
'null value coerced to 0'
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3])).copyWithin(1, 0, NaN),
convertToBigInt([0, 1, 2, 3])
),
'NaN value coerced to 0'
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3])).copyWithin(1, 0, false),
convertToBigInt([0, 1, 2, 3])
),
'false value coerced to 0'
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3])).copyWithin(1, 0, true),
convertToBigInt([0, 0, 2, 3])
),
'true value coerced to 1'
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3])).copyWithin(1, 0, '-2'),
convertToBigInt([0, 0, 1, 3])
),
'string "-2" value coerced to integer -2'
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3])).copyWithin(1, 0, -2.5),
convertToBigInt([0, 0, 1, 3])
),
'float -2.5 value coerced to integer -2'
);
});

View File

@ -0,0 +1,92 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.copywithin
es6id: 22.2.3.5
description: >
start argument is coerced to an integer value.
info: |
22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
%TypedArray%.prototype.copyWithin is a distinct function that implements the
same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
that the this object's [[ArrayLength]] internal slot is accessed in place of
performing a [[Get]] of "length" and the actual copying of values in step 12
must be performed in a manner that preserves the bit-level encoding of the
source data.
...
22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
...
5. Let relativeStart be ? ToInteger(start).
...
includes: [compareArray.js, testBigIntTypedArray.js]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3])).copyWithin(1, undefined),
convertToBigInt([0, 0, 1, 2])
),
'undefined value coerced to 0'
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3])).copyWithin(1, false),
convertToBigInt([0, 0, 1, 2])
),
'false value coerced to 0'
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3])).copyWithin(1, NaN),
convertToBigInt([0, 0, 1, 2])
),
'NaN value coerced to 0'
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3])).copyWithin(1, null),
convertToBigInt([0, 0, 1, 2])
),
'null value coerced to 0'
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3])).copyWithin(0, true),
convertToBigInt([1, 2, 3, 3])
),
'true value coerced to 1'
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3])).copyWithin(0, '1'),
convertToBigInt([1, 2, 3, 3])
),
'string "1" value coerced to 1'
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3])).copyWithin(1, 0.5),
convertToBigInt([0, 0, 1, 2])
),
'0.5 float value coerced to integer 0'
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3])).copyWithin(0, 1.5),
convertToBigInt([1, 2, 3, 3])
),
'1.5 float value coerced to integer 1'
);
});

View File

@ -0,0 +1,92 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.copywithin
es6id: 22.2.3.5
description: >
target argument is coerced to an integer value.
info: |
22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
%TypedArray%.prototype.copyWithin is a distinct function that implements the
same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
that the this object's [[ArrayLength]] internal slot is accessed in place of
performing a [[Get]] of "length" and the actual copying of values in step 12
must be performed in a manner that preserves the bit-level encoding of the
source data.
...
22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
...
3. Let relativeTarget be ? ToInteger(target).
...
includes: [compareArray.js, testBigIntTypedArray.js]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3])).copyWithin(undefined, 1),
convertToBigInt([1, 2, 3, 3])
),
'undefined value coerced to 0'
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3])).copyWithin(false, 1),
convertToBigInt([1, 2, 3, 3])
),
'false value coerced to 0'
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3])).copyWithin(NaN, 1),
convertToBigInt([1, 2, 3, 3])
),
'NaN value coerced to 0'
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3])).copyWithin(null, 1),
convertToBigInt([1, 2, 3, 3])
),
'null value coerced to 0'
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3])).copyWithin(true, 0),
convertToBigInt([0, 0, 1, 2])
),
'true value coerced to 1'
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3])).copyWithin('1', 0),
convertToBigInt([0, 0, 1, 2])
),
'string "1" value coerced to 1'
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3])).copyWithin(0.5, 1),
convertToBigInt([1, 2, 3, 3])
),
'0.5 float value coerced to integer 0'
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3])).copyWithin(1.5, 0),
convertToBigInt([0, 0, 1, 2])
),
'1.5 float value coerced to integer 1'
);
});

View File

@ -0,0 +1,34 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.copywithin
description: Throws a TypeError if this has a detached buffer
info: |
22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [, end ] )
This function is not generic. ValidateTypedArray is applied to the this value
prior to evaluating the algorithm. If its result is an abrupt completion that
exception is thrown instead of evaluating the algorithm.
22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
...
5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
...
includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
features: [BigInt, TypedArray]
---*/
var obj = {
valueOf: function() {
throw new Test262Error();
}
};
testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA(1);
$DETACHBUFFER(sample.buffer);
assert.throws(TypeError, function() {
sample.copyWithin(obj, obj);
});
});

View File

@ -0,0 +1,50 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.copywithin
es6id: 22.2.3.5
description: >
Unreachable abrupt from Get(O, "length") as [[ArrayLength]] is returned.
info: |
22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
%TypedArray%.prototype.copyWithin is a distinct function that implements the
same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
that the this object's [[ArrayLength]] internal slot is accessed in place of
performing a [[Get]] of "length" and the actual copying of values in step 12
must be performed in a manner that preserves the bit-level encoding of the
source data.
...
22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
1. Let O be ? ToObject(this value).
2. Let len be ? ToLength(? Get(O, "length")).
...
includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray]
---*/
Object.defineProperty(TypedArray.prototype, "length", {
get: function() {
throw new Test262Error();
}
});
testWithBigIntTypedArrayConstructors(function(TA) {
Object.defineProperty(TA.prototype, "length", {
get: function() {
throw new Test262Error();
}
});
var sample = new TA();
Object.defineProperty(sample, "length", {
get: function() {
throw new Test262Error();
}
});
assert.sameValue(sample.copyWithin(0, 0), sample);
});

View File

@ -0,0 +1,29 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.2.3.5
description: Throws a TypeError exception when invoked as a function
info: |
22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [, end ] )
This function is not generic. ValidateTypedArray is applied to the this value
prior to evaluating the algorithm. If its result is an abrupt completion that
exception is thrown instead of evaluating the algorithm.
22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
1. If Type(O) is not Object, throw a TypeError exception.
2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
exception.
...
includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray]
---*/
var copyWithin = TypedArray.prototype.copyWithin;
assert.sameValue(typeof copyWithin, 'function');
assert.throws(TypeError, function() {
copyWithin();
});

View File

@ -0,0 +1,29 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.2.3.5
description: Requires a [[TypedArrayName]] internal slot.
info: |
22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [, end ] )
This function is not generic. ValidateTypedArray is applied to the this value
prior to evaluating the algorithm. If its result is an abrupt completion that
exception is thrown instead of evaluating the algorithm.
22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
1. If Type(O) is not Object, throw a TypeError exception.
2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
exception.
...
includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray]
---*/
var TypedArrayPrototype = TypedArray.prototype;
assert.sameValue(typeof TypedArrayPrototype.copyWithin, 'function');
assert.throws(TypeError, function() {
TypedArrayPrototype.copyWithin();
});

View File

@ -0,0 +1,29 @@
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.2.3.5
description: >
%TypedArray%.prototype.copyWithin.length is 2.
info: |
%TypedArray%.prototype.copyWithin (target, start [, end ] )
17 ECMAScript Standard Built-in Objects:
Every built-in Function object, including constructors, has a length
property whose value is an integer. Unless otherwise specified, this
value is equal to the largest number of named arguments shown in the
subclause headings for the function description, including optional
parameters. However, rest parameters shown using the form ...name
are not included in the default argument count.
Unless otherwise specified, the length property of a built-in Function
object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
[[Configurable]]: true }.
includes: [propertyHelper.js, testBigIntTypedArray.js]
---*/
assert.sameValue(TypedArray.prototype.copyWithin.length, 2);
verifyNotEnumerable(TypedArray.prototype.copyWithin, "length");
verifyNotWritable(TypedArray.prototype.copyWithin, "length");
verifyConfigurable(TypedArray.prototype.copyWithin, "length");

View File

@ -0,0 +1,26 @@
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.2.3.5
description: >
%TypedArray%.prototype.copyWithin.name is "copyWithin".
info: |
%TypedArray%.prototype.copyWithin (target, start [, end ] )
17 ECMAScript Standard Built-in Objects:
Every built-in Function object, including constructors, that is not
identified as an anonymous function has a name property whose value
is a String.
Unless otherwise specified, the name property of a built-in Function
object, if it exists, has the attributes { [[Writable]]: false,
[[Enumerable]]: false, [[Configurable]]: true }.
includes: [propertyHelper.js, testBigIntTypedArray.js]
---*/
assert.sameValue(TypedArray.prototype.copyWithin.name, "copyWithin");
verifyNotEnumerable(TypedArray.prototype.copyWithin, "name");
verifyNotWritable(TypedArray.prototype.copyWithin, "name");
verifyConfigurable(TypedArray.prototype.copyWithin, "name");

View File

@ -0,0 +1,95 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.copywithin
es6id: 22.2.3.5
description: >
Set values with negative end argument.
info: |
22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
%TypedArray%.prototype.copyWithin is a distinct function that implements the
same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
that the this object's [[ArrayLength]] internal slot is accessed in place of
performing a [[Get]] of "length" and the actual copying of values in step 12
must be performed in a manner that preserves the bit-level encoding of the
source data.
...
22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
...
7. If end is undefined, let relativeEnd be len; else let relativeEnd be ?
ToInteger(end).
8. If relativeEnd < 0, let final be max((len + relativeEnd), 0); else let
final be min(relativeEnd, len).
...
includes: [compareArray.js, testBigIntTypedArray.js]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3])).copyWithin(0, 1, -1),
convertToBigInt([1, 2, 2, 3])
),
'[0, 1, 2, 3].copyWithin(0, 1, -1) -> [1, 2, 2, 3]'
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3, 4])).copyWithin(2, 0, -1),
convertToBigInt([0, 1, 0, 1, 2])
),
'[0, 1, 2, 3, 4].copyWithin(2, 0, -1) -> [0, 1, 0, 1, 2]'
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3, 4])).copyWithin(1, 2, -2),
convertToBigInt([0, 2, 2, 3, 4])
),
'[0, 1, 2, 3, 4].copyWithin(1, 2, -2) -> [0, 2, 2, 3, 4]'
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3])).copyWithin(0, -2, -1),
convertToBigInt([2, 1, 2, 3])
),
'[0, 1, 2, 3].copyWithin(0, -2, -1) -> [2, 1, 2, 3]'
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3, 4])).copyWithin(2, -2, -1),
convertToBigInt([0, 1, 3, 3, 4])
),
'[0, 1, 2, 3, 4].copyWithin(2, -2, 1) -> [0, 1, 3, 3, 4]'
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3])).copyWithin(-3, -2, -1),
convertToBigInt([0, 2, 2, 3])
),
'[0, 1, 2, 3].copyWithin(-3, -2, -1) -> [0, 2, 2, 3]'
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3, 4])).copyWithin(-2, -3, -1),
convertToBigInt([0, 1, 2, 2, 3])
),
'[0, 1, 2, 3, 4].copyWithin(-2, -3, -1) -> [0, 1, 2, 2, 3]'
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3, 4])).copyWithin(-5, -2, -1),
convertToBigInt([3, 1, 2, 3, 4])
),
'[0, 1, 2, 3, 4].copyWithin(-5, -2, -1) -> [3, 1, 2, 3, 4]'
);
});

View File

@ -0,0 +1,111 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.copywithin
es6id: 22.2.3.5
description: >
Set values with negative out of bounds end argument.
info: |
22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
%TypedArray%.prototype.copyWithin is a distinct function that implements the
same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
that the this object's [[ArrayLength]] internal slot is accessed in place of
performing a [[Get]] of "length" and the actual copying of values in step 12
must be performed in a manner that preserves the bit-level encoding of the
source data.
...
22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
...
7. If end is undefined, let relativeEnd be len; else let relativeEnd be ?
ToInteger(end).
8. If relativeEnd < 0, let final be max((len + relativeEnd), 0); else let
final be min(relativeEnd, len).
...
includes: [compareArray.js, testBigIntTypedArray.js]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3])).copyWithin(0, 1, -10),
convertToBigInt([0, 1, 2, 3])
),
'[0, 1, 2, 3].copyWithin(0, 1, -10) -> [0, 1, 2, 3]'
);
assert(
compareArray(
new TA(convertToBigInt([1, 2, 3, 4, 5])).copyWithin(0, 1, -Infinity),
convertToBigInt([1, 2, 3, 4, 5])
),
'[1, 2, 3, 4, 5].copyWithin(0, 1, -Infinity) -> [1, 2, 3, 4, 5]'
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3])).copyWithin(0, -2, -10),
convertToBigInt([0, 1, 2, 3])
),
'[0, 1, 2, 3].copyWithin(0, -2, -10) -> [0, 1, 2, 3]'
);
assert(
compareArray(
new TA(convertToBigInt([1, 2, 3, 4, 5])).copyWithin(0, -2, -Infinity),
convertToBigInt([1, 2, 3, 4, 5])
),
'[1, 2, 3, 4, 5].copyWithin(0, -2, -Infinity) -> [1, 2, 3, 4, 5]'
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3])).copyWithin(0, -9, -10),
convertToBigInt([0, 1, 2, 3])
),
'[0, 1, 2, 3].copyWithin(0, -9, -10) -> [0, 1, 2, 3]'
);
assert(
compareArray(
new TA(convertToBigInt([1, 2, 3, 4, 5])).copyWithin(0, -9, -Infinity),
convertToBigInt([1, 2, 3, 4, 5])
),
'[1, 2, 3, 4, 5].copyWithin(0, -9, -Infinity) -> [1, 2, 3, 4, 5]'
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3])).copyWithin(-3, -2, -10),
convertToBigInt([0, 1, 2, 3])
),
'[0, 1, 2, 3].copyWithin(-3, -2, -10) -> [0, 1, 2, 3]'
);
assert(
compareArray(
new TA(convertToBigInt([1, 2, 3, 4, 5])).copyWithin(-3, -2, -Infinity),
convertToBigInt([1, 2, 3, 4, 5])
),
'[1, 2, 3, 4, 5].copyWithin(-3, -2, -Infinity) -> [1, 2, 3, 4, 5]'
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3])).copyWithin(-7, -8, -9),
convertToBigInt([0, 1, 2, 3])
),
'[0, 1, 2, 3].copyWithin(-7, -8, -9) -> [0, 1, 2, 3]'
);
assert(
compareArray(
new TA(convertToBigInt([1, 2, 3, 4, 5])).copyWithin(-7, -8, -Infinity),
convertToBigInt([1, 2, 3, 4, 5])
),
'[1, 2, 3, 4, 5].copyWithin(-7, -8, -Infinity) -> [1, 2, 3, 4, 5]'
);
});

View File

@ -0,0 +1,93 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.copywithin
es6id: 22.2.3.5
description: >
Set values with out of bounds negative start argument.
info: |
22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
%TypedArray%.prototype.copyWithin is a distinct function that implements the
same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
that the this object's [[ArrayLength]] internal slot is accessed in place of
performing a [[Get]] of "length" and the actual copying of values in step 12
must be performed in a manner that preserves the bit-level encoding of the
source data.
...
22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
...
6. If relativeStart < 0, let from be max((len + relativeStart), 0); else let
from be min(relativeStart, len).
...
includes: [compareArray.js, testBigIntTypedArray.js]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3])).copyWithin(0, -10),
convertToBigInt([0, 1, 2, 3])
),
'[0, 1, 2, 3]).copyWithin(0, -10) -> [0, 1, 2, 3]'
);
assert(
compareArray(
new TA(convertToBigInt([1, 2, 3, 4, 5])).copyWithin(0, -Infinity),
convertToBigInt([1, 2, 3, 4, 5])
),
'[1, 2, 3, 4, 5]).copyWithin(0, -Infinity) -> [1, 2, 3, 4, 5]'
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3, 4])).copyWithin(2, -10),
convertToBigInt([0, 1, 0, 1, 2])
),
'[0, 1, 2, 3, 4]).copyWithin(2, -2) -> [0, 1, 0, 1, 2]'
);
assert(
compareArray(
new TA(convertToBigInt([1, 2, 3, 4, 5])).copyWithin(2, -Infinity),
convertToBigInt([1, 2, 1, 2, 3])
),
'[1, 2, 3, 4, 5]).copyWithin(2, -Infinity) -> [1, 2, 1, 2, 3]'
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3, 4])).copyWithin(10, -10),
convertToBigInt([0, 1, 2, 3, 4])
),
'[0, 1, 2, 3, 4]).copyWithin(10, -10) -> [0, 1, 2, 3, 4]'
);
assert(
compareArray(
new TA(convertToBigInt([1, 2, 3, 4, 5])).copyWithin(10, -Infinity),
convertToBigInt([1, 2, 3, 4, 5])
),
'[1, 2, 3, 4, 5]).copyWithin(10, -Infinity) -> [1, 2, 3, 4, 5]'
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3])).copyWithin(-9, -10),
convertToBigInt([0, 1, 2, 3])
),
'[0, 1, 2, 3].copyWithin(-9, -10) -> [0, 1, 2, 3]'
);
assert(
compareArray(
new TA(convertToBigInt([1, 2, 3, 4, 5])).copyWithin(-9, -Infinity),
convertToBigInt([1, 2, 3, 4, 5])
),
'[1, 2, 3, 4, 5].copyWithin(-9, -Infinity) -> [1, 2, 3, 4, 5]'
);
});

View File

@ -0,0 +1,61 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.copywithin
es6id: 22.2.3.5
description: >
Set values with out of bounds negative target argument.
info: |
22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
%TypedArray%.prototype.copyWithin is a distinct function that implements the
same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
that the this object's [[ArrayLength]] internal slot is accessed in place of
performing a [[Get]] of "length" and the actual copying of values in step 12
must be performed in a manner that preserves the bit-level encoding of the
source data.
...
22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
...
4. If relativeTarget < 0, let to be max((len + relativeTarget), 0); else let
to be min(relativeTarget, len).
...
includes: [compareArray.js, testBigIntTypedArray.js]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3])).copyWithin(-10, 0),
convertToBigInt([0, 1, 2, 3])
),
'[0, 1, 2, 3].copyWithin(-10, 0) -> [0, 1, 2, 3]'
);
assert(
compareArray(
new TA(convertToBigInt([1, 2, 3, 4, 5])).copyWithin(-Infinity, 0),
convertToBigInt([1, 2, 3, 4, 5])
),
'[1, 2, 3, 4, 5].copyWithin(-Infinity, 0) -> [1, 2, 3, 4, 5]'
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3, 4])).copyWithin(-10, 2),
convertToBigInt([2, 3, 4, 3, 4])
),
'[0, 1, 2, 3, 4].copyWithin(-10, 2) -> [2, 3, 4, 3, 4]'
);
assert(
compareArray(
new TA(convertToBigInt([1, 2, 3, 4, 5])).copyWithin(-Infinity, 2),
convertToBigInt([3, 4, 5, 4, 5])
),
'[1, 2, 3, 4, 5].copyWithin(-Infinity, 2) -> [3, 4, 5, 4, 5]'
);
});

View File

@ -0,0 +1,77 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.copywithin
es6id: 22.2.3.5
description: >
Set values with negative start argument.
info: |
22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
%TypedArray%.prototype.copyWithin is a distinct function that implements the
same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
that the this object's [[ArrayLength]] internal slot is accessed in place of
performing a [[Get]] of "length" and the actual copying of values in step 12
must be performed in a manner that preserves the bit-level encoding of the
source data.
...
22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
...
6. If relativeStart < 0, let from be max((len + relativeStart), 0); else let
from be min(relativeStart, len).
...
includes: [compareArray.js, testBigIntTypedArray.js]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3])).copyWithin(0, -1),
convertToBigInt([3, 1, 2, 3])
),
'[0, 1, 2, 3].copyWithin(0, -1) -> [3, 1, 2, 3]'
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3, 4])).copyWithin(2, -2),
convertToBigInt([0, 1, 3, 4, 4])
),
'[0, 1, 2, 3, 4].copyWithin(2, -2) -> [0, 1, 3, 4, 4]'
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3, 4])).copyWithin(1, -2),
convertToBigInt([0, 3, 4, 3, 4])
),
'[0, 1, 2, 3, 4].copyWithin(1, -2) -> [0, 3, 4, 3, 4]'
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3])).copyWithin(-1, -2),
convertToBigInt([0, 1, 2, 2])
),
'[0, 1, 2, 3].copyWithin(-1, -2) -> [ 0, 1, 2, 2 ]'
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3, 4])).copyWithin(-2, -3),
convertToBigInt([0, 1, 2, 2, 3])
),
'[0, 1, 2, 3, 4].copyWithin(-2, -3) -> [0, 1, 2, 2, 3]'
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3, 4])).copyWithin(-5, -2),
convertToBigInt([3, 4, 2, 3, 4])
),
'[0, 1, 2, 3, 4].copyWithin(-5, -2) -> [3, 4, 2, 3, 4]'
);
});

View File

@ -0,0 +1,53 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.copywithin
es6id: 22.2.3.5
description: >
Set values with negative target argument.
info: |
22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
%TypedArray%.prototype.copyWithin is a distinct function that implements the
same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
that the this object's [[ArrayLength]] internal slot is accessed in place of
performing a [[Get]] of "length" and the actual copying of values in step 12
must be performed in a manner that preserves the bit-level encoding of the
source data.
...
22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
...
4. If relativeTarget < 0, let to be max((len + relativeTarget), 0); else let
to be min(relativeTarget, len).
...
includes: [compareArray.js, testBigIntTypedArray.js]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3])).copyWithin(-1, 0),
convertToBigInt([0, 1, 2, 0])
),
'[0, 1, 2, 3].copyWithin(-1, 0) -> [0, 1, 2, 0]'
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3, 4])).copyWithin(-2, 2),
convertToBigInt([0, 1, 2, 2, 3])
),
'[0, 1, 2, 3, 4].copyWithin(-2, 2) -> [0, 1, 2, 2, 3]'
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3])).copyWithin(-1, 2),
convertToBigInt([0, 1, 2, 2])
),
'[0, 1, 2, 3].copyWithin(-1, 2) -> [0, 1, 2, 2]'
);
});

View File

@ -0,0 +1,54 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.copywithin
es6id: 22.2.3.5
description: >
Max value of end position is the this.length.
info: |
22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
%TypedArray%.prototype.copyWithin is a distinct function that implements the
same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
that the this object's [[ArrayLength]] internal slot is accessed in place of
performing a [[Get]] of "length" and the actual copying of values in step 12
must be performed in a manner that preserves the bit-level encoding of the
source data.
...
includes: [compareArray.js, testBigIntTypedArray.js]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3])).copyWithin(0, 1, 6),
convertToBigInt([1, 2, 3, 3])
),
'[0, 1, 2, 3].copyWithin(0, 1, 6) -> [1, 2, 3, 3]'
);
assert(
compareArray(
new TA(convertToBigInt([1, 2, 3, 4, 5])).copyWithin(0, 1, Infinity),
convertToBigInt([2, 3, 4, 5, 5])
),
'[1, 2, 3, 4, 5].copyWithin(0, 1, Infinity) -> [2, 3, 4, 5, 5]'
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3, 4, 5])).copyWithin(1, 3, 6),
convertToBigInt([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(convertToBigInt([1, 2, 3, 4, 5])).copyWithin(1, 3, Infinity),
convertToBigInt([1, 4, 5, 4, 5])
),
'[1, 2, 3, 4, 5].copyWithin(1, 3, Infinity) -> [1, 4, 5, 4, 5]'
);
});

View File

@ -0,0 +1,74 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.copywithin
es6id: 22.2.3.5
description: >
Max values of target and start positions are this.length.
info: |
22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
%TypedArray%.prototype.copyWithin is a distinct function that implements the
same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
that the this object's [[ArrayLength]] internal slot is accessed in place of
performing a [[Get]] of "length" and the actual copying of values in step 12
must be performed in a manner that preserves the bit-level encoding of the
source data.
...
includes: [compareArray.js, testBigIntTypedArray.js]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3, 4, 5])).copyWithin(6, 0),
convertToBigInt([0, 1, 2, 3, 4, 5])
)
);
assert(
compareArray(
new TA(convertToBigInt([1, 2, 3, 4, 5])).copyWithin(Infinity, 0),
convertToBigInt([1, 2, 3, 4, 5])
),
'[1, 2, 3, 4, 5].copyWithin(Infinity, 0) -> [1, 2, 3, 4, 5]'
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3, 4, 5])).copyWithin(0, 6),
convertToBigInt([0, 1, 2, 3, 4, 5])
)
);
assert(
compareArray(
new TA(convertToBigInt([1, 2, 3, 4, 5])).copyWithin(0, Infinity),
convertToBigInt([1, 2, 3, 4, 5])
),
'[1, 2, 3, 4, 5].copyWithin(0, Infinity) -> [1, 2, 3, 4, 5]'
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3, 4, 5])).copyWithin(6, 6),
convertToBigInt([0, 1, 2, 3, 4, 5])
)
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3, 4, 5])).copyWithin(10, 10),
convertToBigInt([0, 1, 2, 3, 4, 5])
)
);
assert(
compareArray(
new TA(convertToBigInt([1, 2, 3, 4, 5])).copyWithin(Infinity, Infinity),
convertToBigInt([1, 2, 3, 4, 5])
),
'[1, 2, 3, 4, 5].copyWithin(Infinity, Infinity) -> [1, 2, 3, 4, 5]'
);
});

View File

@ -0,0 +1,50 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.copywithin
es6id: 22.2.3.5
description: >
Copy values with non-negative target and start positions.
info: |
22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
%TypedArray%.prototype.copyWithin is a distinct function that implements the
same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
that the this object's [[ArrayLength]] internal slot is accessed in place of
performing a [[Get]] of "length" and the actual copying of values in step 12
must be performed in a manner that preserves the bit-level encoding of the
source data.
...
includes: [compareArray.js, testBigIntTypedArray.js]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
assert(
compareArray(
new TA(convertToBigInt([1, 2, 3, 4, 5, 6])).copyWithin(0, 0),
convertToBigInt([1, 2, 3, 4, 5, 6])
)
);
assert(
compareArray(
new TA(convertToBigInt([1, 2, 3, 4, 5, 6])).copyWithin(0, 2),
convertToBigInt([3, 4, 5, 6, 5, 6])
)
);
assert(
compareArray(
new TA(convertToBigInt([1, 2, 3, 4, 5, 6])).copyWithin(3, 0),
convertToBigInt([1, 2, 3, 1, 2, 3])
)
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3, 4, 5])).copyWithin(1, 4),
convertToBigInt([0, 4, 5, 3, 4, 5])
)
);
});

View File

@ -0,0 +1,73 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.copywithin
es6id: 22.2.3.5
description: >
Copy values with non-negative target, start and end positions.
info: |
22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
%TypedArray%.prototype.copyWithin is a distinct function that implements the
same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
that the this object's [[ArrayLength]] internal slot is accessed in place of
performing a [[Get]] of "length" and the actual copying of values in step 12
must be performed in a manner that preserves the bit-level encoding of the
source data.
...
includes: [compareArray.js, testBigIntTypedArray.js]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3])).copyWithin(0, 0, 0),
convertToBigInt([0, 1, 2, 3])
),
'[0, 1, 2, 3].copyWithin(0, 0, 0) -> [0, 1, 2, 3]'
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3])).copyWithin(0, 0, 2),
convertToBigInt([0, 1, 2, 3])
),
'[0, 1, 2, 3].copyWithin(0, 0, 2) -> [0, 1, 2, 3]'
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3])).copyWithin(0, 1, 2),
convertToBigInt([1, 1, 2, 3])
),
'[0, 1, 2, 3].copyWithin(0, 1, 2) -> [1, 1, 2, 3]'
);
/*
* 10. If from<to and to<from+count, then
* a. Let direction be - 1.
* b. Let from be from + count - 1.
* c. Let to be to + count - 1.
*
* 0 < 1, 1 < 0 + 2
* direction = -1
* from = 0 + 2 - 1
* to = 1 + 2 - 1
*/
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3])).copyWithin(1, 0, 2),
convertToBigInt([0, 0, 1, 3])
),
'[0, 1, 2, 3].copyWithin(1, 0, 2) -> [0, 0, 1, 3]'
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3, 4, 5])).copyWithin(1, 3, 5),
convertToBigInt([0, 3, 4, 3, 4, 5])
),
'[0, 1, 2, 3, 4, 5].copyWithin(1, 3, 5) -> [0, 3, 4, 3, 4, 5]'
);
});

View File

@ -0,0 +1,18 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.2.3.5
description: >
"copyWithin" property of TypedArrayPrototype
info: |
ES6 section 17: Every other data property described in clauses 18 through 26
and in Annex B.2 has the attributes { [[Writable]]: true,
[[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
includes: [propertyHelper.js, testBigIntTypedArray.js]
---*/
var TypedArrayPrototype = TypedArray.prototype;
verifyNotEnumerable(TypedArrayPrototype, 'copyWithin');
verifyWritable(TypedArrayPrototype, 'copyWithin');
verifyConfigurable(TypedArrayPrototype, 'copyWithin');

View File

@ -0,0 +1,37 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.copywithin
es6id: 22.2.3.5
description: >
Return abrupt if end is a Symbol.
info: |
22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
%TypedArray%.prototype.copyWithin is a distinct function that implements the
same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
that the this object's [[ArrayLength]] internal slot is accessed in place of
performing a [[Get]] of "length" and the actual copying of values in step 12
must be performed in a manner that preserves the bit-level encoding of the
source data.
...
22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
...
7. If end is undefined, let relativeEnd be len; else let relativeEnd be ?
ToInteger(end).
...
includes: [testBigIntTypedArray.js]
features: [BigInt, Symbol, TypedArray]
---*/
var s = Symbol(1);
testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA();
assert.throws(TypeError, function() {
sample.copyWithin(0, 0, s);
});
});

View File

@ -0,0 +1,40 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.copywithin
es6id: 22.2.3.5
description: >
Return abrupt from ToInteger(end).
info: |
22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
%TypedArray%.prototype.copyWithin is a distinct function that implements the
same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
that the this object's [[ArrayLength]] internal slot is accessed in place of
performing a [[Get]] of "length" and the actual copying of values in step 12
must be performed in a manner that preserves the bit-level encoding of the
source data.
...
22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
...
7. If end is undefined, let relativeEnd be len; else let relativeEnd be ?
ToInteger(end).
...
includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
var o1 = {
valueOf: function() {
throw new Test262Error();
}
};
var sample = new TA();
assert.throws(Test262Error, function() {
sample.copyWithin(0, 0, o1);
});
});

View File

@ -0,0 +1,36 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.copywithin
es6id: 22.2.3.5
description: >
Return abrupt if start is a Symbol.
info: |
22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
%TypedArray%.prototype.copyWithin is a distinct function that implements the
same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
that the this object's [[ArrayLength]] internal slot is accessed in place of
performing a [[Get]] of "length" and the actual copying of values in step 12
must be performed in a manner that preserves the bit-level encoding of the
source data.
...
22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
...
5. Let relativeStart be ? ToInteger(start).
...
includes: [testBigIntTypedArray.js]
features: [BigInt, Symbol, TypedArray]
---*/
var s = Symbol(1);
testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA();
assert.throws(TypeError, function() {
sample.copyWithin(0, s);
});
});

View File

@ -0,0 +1,46 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.copywithin
es6id: 22.2.3.5
description: >
Return abrupt from ToInteger(start).
info: |
22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
%TypedArray%.prototype.copyWithin is a distinct function that implements the
same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
that the this object's [[ArrayLength]] internal slot is accessed in place of
performing a [[Get]] of "length" and the actual copying of values in step 12
must be performed in a manner that preserves the bit-level encoding of the
source data.
...
22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
...
5. Let relativeStart be ? ToInteger(start).
...
includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray]
---*/
var o = {
valueOf: function() {
throw new Test262Error();
}
};
var err = {
valueOf: function() {
throw new Error("ToInteger(start) runs before ToInteger(end)");
}
};
testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA();
assert.throws(Test262Error, function() {
sample.copyWithin(0, o, err);
});
});

View File

@ -0,0 +1,36 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.copywithin
es6id: 22.2.3.5
description: >
Return abrupt if target is a Symbol.
info: |
22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
%TypedArray%.prototype.copyWithin is a distinct function that implements the
same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
that the this object's [[ArrayLength]] internal slot is accessed in place of
performing a [[Get]] of "length" and the actual copying of values in step 12
must be performed in a manner that preserves the bit-level encoding of the
source data.
...
22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
...
3. Let relativeTarget be ? ToInteger(target).
...
includes: [testBigIntTypedArray.js]
features: [BigInt, Symbol, TypedArray]
---*/
var s = Symbol(1);
testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA();
assert.throws(TypeError, function() {
sample.copyWithin(s, 0);
});
});

View File

@ -0,0 +1,40 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.copywithin
es6id: 22.2.3.5
description: >
Return abrupt from ToInteger(target).
info: |
22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
%TypedArray%.prototype.copyWithin is a distinct function that implements the
same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
that the this object's [[ArrayLength]] internal slot is accessed in place of
performing a [[Get]] of "length" and the actual copying of values in step 12
must be performed in a manner that preserves the bit-level encoding of the
source data.
...
22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
...
3. Let relativeTarget be ? ToInteger(target).
...
includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray]
---*/
var o = {
valueOf: function() {
throw new Test262Error();
}
};
testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA();
assert.throws(Test262Error, function() {
sample.copyWithin(o);
});
});

View File

@ -0,0 +1,37 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.copywithin
es6id: 22.2.3.5
description: >
Returns `this`.
info: |
22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
%TypedArray%.prototype.copyWithin is a distinct function that implements the
same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
that the this object's [[ArrayLength]] internal slot is accessed in place of
performing a [[Get]] of "length" and the actual copying of values in step 12
must be performed in a manner that preserves the bit-level encoding of the
source data.
...
22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
13. Return O.
includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
var sample1 = new TA();
var result1 = sample1.copyWithin(0, 0);
assert.sameValue(result1, sample1);
var sample2 = new TA(convertToBigInt([1, 2, 3]));
var result2 = sample2.copyWithin(1, 0);
assert.sameValue(result2, sample2);
});

View File

@ -0,0 +1,50 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.copywithin
description: Throws a TypeError exception when `this` is not Object
info: |
22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
This function is not generic. ValidateTypedArray is applied to the this value
prior to evaluating the algorithm. If its result is an abrupt completion that
exception is thrown instead of evaluating the algorithm.
22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
1. If Type(O) is not Object, throw a TypeError exception.
...
includes: [testBigIntTypedArray.js]
features: [BigInt, Symbol, TypedArray]
---*/
var copyWithin = TypedArray.prototype.copyWithin;
assert.throws(TypeError, function() {
copyWithin.call(undefined, 0, 0);
}, "this is undefined");
assert.throws(TypeError, function() {
copyWithin.call(null, 0, 0);
}, "this is null");
assert.throws(TypeError, function() {
copyWithin.call(42, 0, 0);
}, "this is 42");
assert.throws(TypeError, function() {
copyWithin.call("1", 0, 0);
}, "this is a string");
assert.throws(TypeError, function() {
copyWithin.call(true, 0, 0);
}, "this is true");
assert.throws(TypeError, function() {
copyWithin.call(false, 0, 0);
}, "this is false");
var s = Symbol("s");
assert.throws(TypeError, function() {
copyWithin.call(s, 0, 0);
}, "this is a Symbol");

View File

@ -0,0 +1,42 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.copywithin
description: >
Throws a TypeError exception when `this` is not a TypedArray instance
info: |
22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
This function is not generic. ValidateTypedArray is applied to the this value
prior to evaluating the algorithm. If its result is an abrupt completion that
exception is thrown instead of evaluating the algorithm.
22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
1. If Type(O) is not Object, throw a TypeError exception.
2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
exception.
...
includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray]
---*/
var copyWithin = TypedArray.prototype.copyWithin;
assert.throws(TypeError, function() {
copyWithin.call({}, 0, 0);
}, "this is an Object");
assert.throws(TypeError, function() {
copyWithin.call([], 0, 0);
}, "this is an Array");
var ab = new ArrayBuffer(8);
assert.throws(TypeError, function() {
copyWithin.call(ab, 0, 0);
}, "this is an ArrayBuffer instance");
var dv = new DataView(new ArrayBuffer(8), 0, 1);
assert.throws(TypeError, function() {
copyWithin.call(dv, 0, 0);
}, "this is a DataView instance");

View File

@ -0,0 +1,45 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.copywithin
es6id: 22.2.3.5
description: >
If `end` is undefined, set final position to `this.length`.
info: |
22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
%TypedArray%.prototype.copyWithin is a distinct function that implements the
same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
that the this object's [[ArrayLength]] internal slot is accessed in place of
performing a [[Get]] of "length" and the actual copying of values in step 12
must be performed in a manner that preserves the bit-level encoding of the
source data.
...
22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
...
7. If end is undefined, let relativeEnd be len; else let relativeEnd be ?
ToInteger(end).
...
includes: [compareArray.js, testBigIntTypedArray.js]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3])).copyWithin(0, 1, undefined),
convertToBigInt([1, 2, 3, 3])
),
'[0, 1, 2, 3].copyWithin(0, 1, undefined) -> [1, 2, 3]'
);
assert(
compareArray(
new TA(convertToBigInt([0, 1, 2, 3])).copyWithin(0, 1),
convertToBigInt([1, 2, 3, 3])
),
'[0, 1, 2, 3].copyWithin(0, 1) -> [1, 2, 3, 3]'
);
});

View File

@ -0,0 +1,27 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.entries
description: Throws a TypeError if this has a detached buffer
info: |
22.2.3.6 %TypedArray%.prototype.entries ( )
1. Let O be the this value.
2. Perform ? ValidateTypedArray(O).
22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
...
5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
...
includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
features: [BigInt, TypedArray]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA(1);
$DETACHBUFFER(sample.buffer);
assert.throws(TypeError, function() {
sample.entries();
});
});

View File

@ -0,0 +1,25 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.2.3.6
esid: sec-%typedarray%.prototype.entries
description: >
The prototype of the returned iterator is ArrayIteratorPrototype
info: |
22.2.3.6 %TypedArray%.prototype.entries ( )
...
3. Return CreateArrayIterator(O, "key+value").
includes: [testBigIntTypedArray.js]
features: [BigInt, Symbol.iterator, TypedArray]
---*/
var ArrayIteratorProto = Object.getPrototypeOf([][Symbol.iterator]());
testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA(convertToBigInt([0, 42, 64]));
var iter = sample.entries();
assert.sameValue(Object.getPrototypeOf(iter), ArrayIteratorProto);
});

View File

@ -0,0 +1,37 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.2.3.6
esid: sec-%typedarray%.prototype.entries
description: Return an iterator for the entries.
info: |
22.2.3.6 %TypedArray%.prototype.entries ( )
...
3. Return CreateArrayIterator(O, "key+value").
includes: [testBigIntTypedArray.js, compareArray.js]
features: [BigInt, TypedArray]
---*/
var sample = [0, 42, 64];
testWithBigIntTypedArrayConstructors(function(TA) {
var typedArray = new TA(convertToBigInt(sample));
var itor = typedArray.entries();
var next = itor.next();
assert(compareArray(next.value, [0, convertToBigInt(0)]));
assert.sameValue(next.done, false);
next = itor.next();
assert(compareArray(next.value, [1, convertToBigInt(42)]));
assert.sameValue(next.done, false);
next = itor.next();
assert(compareArray(next.value, [2, convertToBigInt(64)]));
assert.sameValue(next.done, false);
next = itor.next();
assert.sameValue(next.value, undefined);
assert.sameValue(next.done, true);
});

View File

@ -0,0 +1,56 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.every
description: >
thisArg does not affect callbackfn arguments
info: |
22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
%TypedArray%.prototype.every is a distinct function that implements the same
algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
object's [[ArrayLength]] internal slot is accessed in place of performing a
[[Get]] of "length".
22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
...
6. Repeat, while k < len
...
c. If kPresent is true, then
i. Let kValue be ? Get(O, Pk).
ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
...
includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA(convertToBigInt([42, 43, 44]));
var results = [];
var thisArg = ["test262", 0, "ecma262", 0];
sample.every(function() {
results.push(arguments);
return true;
}, thisArg);
assert.sameValue(results.length, 3, "results.length");
assert.sameValue(thisArg.length, 4, "thisArg.length");
assert.sameValue(results[0].length, 3, "results[0].length");
assert.sameValue(results[0][0], convertToBigInt(42), "results[0][0] - kValue");
assert.sameValue(results[0][1], 0, "results[0][1] - k");
assert.sameValue(results[0][2], sample, "results[0][2] - this");
assert.sameValue(results[1].length, 3, "results[1].length");
assert.sameValue(results[1][0], convertToBigInt(43), "results[1][0] - kValue");
assert.sameValue(results[1][1], 1, "results[1][1] - k");
assert.sameValue(results[1][2], sample, "results[1][2] - this");
assert.sameValue(results[2].length, 3, "results[2].length");
assert.sameValue(results[2][0], convertToBigInt(44), "results[2][0] - kValue");
assert.sameValue(results[2][1], 2, "results[2][1] - k");
assert.sameValue(results[2][2], sample, "results[2][2] - this");
});

View File

@ -0,0 +1,54 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.every
description: >
callbackfn arguments
info: |
22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
%TypedArray%.prototype.every is a distinct function that implements the same
algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
object's [[ArrayLength]] internal slot is accessed in place of performing a
[[Get]] of "length".
22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
...
6. Repeat, while k < len
...
c. If kPresent is true, then
i. Let kValue be ? Get(O, Pk).
ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
...
includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA(convertToBigInt([42, 43, 44]));
var results = [];
sample.every(function() {
results.push(arguments);
return true;
});
assert.sameValue(results.length, 3, "results.length");
assert.sameValue(results[0].length, 3, "results[0].length");
assert.sameValue(results[0][0], convertToBigInt(42), "results[0][0] - kValue");
assert.sameValue(results[0][1], 0, "results[0][1] - k");
assert.sameValue(results[0][2], sample, "results[0][2] - this");
assert.sameValue(results[1].length, 3, "results[1].length");
assert.sameValue(results[1][0], convertToBigInt(43), "results[1][0] - kValue");
assert.sameValue(results[1][1], 1, "results[1][1] - k");
assert.sameValue(results[1][2], sample, "results[1][2] - this");
assert.sameValue(results[2].length, 3, "results[2].length");
assert.sameValue(results[2][0], convertToBigInt(44), "results[2][0] - kValue");
assert.sameValue(results[2][1], 2, "results[2][1] - k");
assert.sameValue(results[2][2], sample, "results[2][2] - this");
});

View File

@ -0,0 +1,43 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.every
description: >
Instance buffer can be detached during loop
info: |
22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
%TypedArray%.prototype.every is a distinct function that implements the same
algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
object's [[ArrayLength]] internal slot is accessed in place of performing a
[[Get]] of "length".
22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
...
6. Repeat, while k < len
...
c. If kPresent is true, then
i. Let kValue be ? Get(O, Pk).
ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
...
includes: [detachArrayBuffer.js, testBigIntTypedArray.js]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
var loops = 0;
var sample = new TA(2);
assert.throws(TypeError, function() {
sample.every(function() {
if (loops === 1) {
throw new Test262Error("callbackfn called twice");
}
$DETACHBUFFER(sample.buffer);
loops++;
return true;
});
});
assert.sameValue(loops, 1);
});

View File

@ -0,0 +1,41 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.every
description: >
Does not interact over non-integer properties
info: |
22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
...
6. Repeat, while k < len
...
c. If kPresent is true, then
i. Let kValue be ? Get(O, Pk).
ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
...
includes: [testBigIntTypedArray.js]
features: [BigInt, Symbol, TypedArray]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA(convertToBigInt([7, 8]));
var results = [];
sample.foo = 42;
sample[Symbol("1")] = 43;
sample.every(function() {
results.push(arguments);
return true;
});
assert.sameValue(results.length, 2, "results.length");
assert.sameValue(results[0][1], 0, "results[0][1] - key");
assert.sameValue(results[1][1], 1, "results[1][1] - key");
assert.sameValue(results[0][0], convertToBigInt(7), "results[0][0] - value");
assert.sameValue(results[1][0], convertToBigInt(8), "results[1][0] - value");
});

View File

@ -0,0 +1,69 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.every
description: Throws a TypeError if callbackfn is not callable
info: |
22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
%TypedArray%.prototype.every is a distinct function that implements the same
algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
object's [[ArrayLength]] internal slot is accessed in place of performing a
[[Get]] of "length".
22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
...
3. If IsCallable(callbackfn) is false, throw a TypeError exception.
...
includes: [testBigIntTypedArray.js]
features: [BigInt, Symbol, TypedArray]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA(2);
assert.throws(TypeError, function() {
sample.every();
}, "no args");
assert.throws(TypeError, function() {
sample.every(null);
}, "null");
assert.throws(TypeError, function() {
sample.every(undefined);
}, "undefined");
assert.throws(TypeError, function() {
sample.every("abc");
}, "string");
assert.throws(TypeError, function() {
sample.every(1);
}, "number");
assert.throws(TypeError, function() {
sample.every(NaN);
}, "NaN");
assert.throws(TypeError, function() {
sample.every(false);
}, "false");
assert.throws(TypeError, function() {
sample.every(true);
}, "true");
assert.throws(TypeError, function() {
sample.every({});
}, "{}");
assert.throws(TypeError, function() {
sample.every(sample);
}, "same typedArray instance");
assert.throws(TypeError, function() {
sample.every(Symbol("1"));
}, "symbol");
});

View File

@ -0,0 +1,36 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.every
description: >
callbackfn is not called on empty instances
info: |
22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
%TypedArray%.prototype.every is a distinct function that implements the same
algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
object's [[ArrayLength]] internal slot is accessed in place of performing a
[[Get]] of "length".
22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
...
6. Repeat, while k < len
..
c. If kPresent is true, then
i. Let kValue be ? Get(O, Pk).
ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
...
includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
var called = 0;
new TA().every(function() {
called++;
});
assert.sameValue(called, 0);
});

View File

@ -0,0 +1,38 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.every
description: >
The callbackfn return does not change the instance
info: |
22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
%TypedArray%.prototype.every is a distinct function that implements the same
algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
object's [[ArrayLength]] internal slot is accessed in place of performing a
[[Get]] of "length".
22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
...
6. Repeat, while k < len
..
c. If kPresent is true, then
i. Let kValue be ? Get(O, Pk).
ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
...
includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA(convertToBigInt([40, 41, 42]));
sample.every(function() {
return 43;
});
assert.sameValue(sample[0], convertToBigInt(40), "[0] == 40");
assert.sameValue(sample[1], convertToBigInt(41), "[1] == 41");
assert.sameValue(sample[2], convertToBigInt(42), "[2] == 42");
});

View File

@ -0,0 +1,35 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.every
description: Returns abrupt from callbackfn
info: |
22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
%TypedArray%.prototype.every is a distinct function that implements the same
algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
object's [[ArrayLength]] internal slot is accessed in place of performing a
[[Get]] of "length".
22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
...
6. Repeat, while k < len
..
c. If kPresent is true, then
i. Let kValue be ? Get(O, Pk).
ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
...
includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA(3);
assert.throws(Test262Error, function() {
sample.every(function() {
throw new Test262Error();
});
});
});

View File

@ -0,0 +1,58 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.every
description: >
Integer indexed values changed during iteration
info: |
22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
%TypedArray%.prototype.every is a distinct function that implements the same
algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
object's [[ArrayLength]] internal slot is accessed in place of performing a
[[Get]] of "length".
22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
...
6. Repeat, while k < len
..
c. If kPresent is true, then
i. Let kValue be ? Get(O, Pk).
ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
...
includes: [testBigIntTypedArray.js]
features: [BigInt, Reflect.set, TypedArray]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA(convertToBigInt([42, 43, 44]));
var newVal = 0;
sample.every(function(val, i) {
if (i > 0) {
assert.sameValue(
sample[i - 1], convertToBigInt(newVal - 1),
"get the changed value during the loop"
);
assert.sameValue(
Reflect.set(sample, 0, convertToBigInt(7)),
true,
"re-set a value for sample[0]"
);
}
assert.sameValue(
Reflect.set(sample, i, convertToBigInt(newVal)),
true,
"set value during iteration"
);
newVal++;
return true;
});
assert.sameValue(sample[0], convertToBigInt(7), "changed values after iteration [0] == 7");
assert.sameValue(sample[1], convertToBigInt(1), "changed values after iteration [1] == 1");
assert.sameValue(sample[2], convertToBigInt(2), "changed values after iteration [2] == 2");
});

View File

@ -0,0 +1,59 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.every
description: >
callbackfn `this` value
info: |
22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
%TypedArray%.prototype.every is a distinct function that implements the same
algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
object's [[ArrayLength]] internal slot is accessed in place of performing a
[[Get]] of "length".
22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
...
4. If thisArg was supplied, let T be thisArg; else let T be undefined.
...
6. Repeat, while k < len
...
c. If kPresent is true, then
...
ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
...
includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray]
---*/
var expected = (function() { return this; })();
var thisArg = {};
testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA(3);
var results1 = [];
sample.every(function() {
results1.push(this);
return true;
});
assert.sameValue(results1.length, 3, "results1");
assert.sameValue(results1[0], expected, "without thisArg - [0]");
assert.sameValue(results1[1], expected, "without thisArg - [1]");
assert.sameValue(results1[2], expected, "without thisArg - [2]");
var results2 = [];
sample.every(function() {
results2.push(this);
return true;
}, thisArg);
assert.sameValue(results2.length, 3, "results2");
assert.sameValue(results2[0], thisArg, "using thisArg - [0]");
assert.sameValue(results2[1], thisArg, "using thisArg - [1]");
assert.sameValue(results2[2], thisArg, "using thisArg - [2]");
});

View File

@ -0,0 +1,32 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.every
description: Throws a TypeError if this has a detached buffer
info: |
22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
This function is not generic. ValidateTypedArray is applied to the this value
prior to evaluating the algorithm. If its result is an abrupt completion that
exception is thrown instead of evaluating the algorithm.
22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
...
5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
...
includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
features: [BigInt, TypedArray]
---*/
var callbackfn = function() {
throw new Test262Error();
};
testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA(1);
$DETACHBUFFER(sample.buffer);
assert.throws(TypeError, function() {
sample.every(callbackfn);
});
});

View File

@ -0,0 +1,47 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.every
description: Get "length" uses internal ArrayLength
info: |
22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
%TypedArray%.prototype.every is a distinct function that implements the same
algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
object's [[ArrayLength]] internal slot is accessed in place of performing a
[[Get]] of "length".
22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
1. Let O be ? ToObject(this value).
2. Let len be ? ToLength(? Get(O, "length")).
...
includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray]
---*/
var getCalls = 0;
var desc = {
get: function getLen() {
getCalls++;
return 0;
}
};
Object.defineProperty(TypedArray.prototype, "length", desc);
testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA(convertToBigInt([42, 43]));
var calls = 0;
Object.defineProperty(TA.prototype, "length", desc);
Object.defineProperty(sample, "length", desc);
sample.every(function() {
calls++;
return true;
});
assert.sameValue(getCalls, 0, "ignores length properties");
assert.sameValue(calls, 2, "iterations are not affected by custom length");
});

View File

@ -0,0 +1,29 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.2.3.7
description: Throws a TypeError exception when invoked as a function
info: |
22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
This function is not generic. ValidateTypedArray is applied to the this value
prior to evaluating the algorithm. If its result is an abrupt completion that
exception is thrown instead of evaluating the algorithm.
22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
1. If Type(O) is not Object, throw a TypeError exception.
2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
exception.
...
includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray]
---*/
var every = TypedArray.prototype.every;
assert.sameValue(typeof every, 'function');
assert.throws(TypeError, function() {
every();
});

View File

@ -0,0 +1,29 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.2.3.7
description: Requires a [[TypedArrayName]] internal slot.
info: |
22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
This function is not generic. ValidateTypedArray is applied to the this value
prior to evaluating the algorithm. If its result is an abrupt completion that
exception is thrown instead of evaluating the algorithm.
22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
1. If Type(O) is not Object, throw a TypeError exception.
2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
exception.
...
includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray]
---*/
var TypedArrayPrototype = TypedArray.prototype;
assert.sameValue(typeof TypedArrayPrototype.every, 'function');
assert.throws(TypeError, function() {
TypedArrayPrototype.every();
});

View File

@ -0,0 +1,29 @@
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.2.3.7
description: >
%TypedArray%.prototype.every.length is 1.
info: |
%TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
17 ECMAScript Standard Built-in Objects:
Every built-in Function object, including constructors, has a length
property whose value is an integer. Unless otherwise specified, this
value is equal to the largest number of named arguments shown in the
subclause headings for the function description, including optional
parameters. However, rest parameters shown using the form ...name
are not included in the default argument count.
Unless otherwise specified, the length property of a built-in Function
object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
[[Configurable]]: true }.
includes: [propertyHelper.js, testBigIntTypedArray.js]
---*/
assert.sameValue(TypedArray.prototype.every.length, 1);
verifyNotEnumerable(TypedArray.prototype.every, "length");
verifyNotWritable(TypedArray.prototype.every, "length");
verifyConfigurable(TypedArray.prototype.every, "length");

View File

@ -0,0 +1,26 @@
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.2.3.7
description: >
%TypedArray%.prototype.every.name is "every".
info: |
%TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
17 ECMAScript Standard Built-in Objects:
Every built-in Function object, including constructors, that is not
identified as an anonymous function has a name property whose value
is a String.
Unless otherwise specified, the name property of a built-in Function
object, if it exists, has the attributes { [[Writable]]: false,
[[Enumerable]]: false, [[Configurable]]: true }.
includes: [propertyHelper.js, testBigIntTypedArray.js]
---*/
assert.sameValue(TypedArray.prototype.every.name, "every");
verifyNotEnumerable(TypedArray.prototype.every, "name");
verifyNotWritable(TypedArray.prototype.every, "name");
verifyConfigurable(TypedArray.prototype.every, "name");

View File

@ -0,0 +1,18 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.2.3.7
description: >
"every" property of TypedArrayPrototype
info: |
ES6 section 17: Every other data property described in clauses 18 through 26
and in Annex B.2 has the attributes { [[Writable]]: true,
[[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
includes: [propertyHelper.js, testBigIntTypedArray.js]
---*/
var TypedArrayPrototype = TypedArray.prototype;
verifyNotEnumerable(TypedArrayPrototype, 'every');
verifyWritable(TypedArrayPrototype, 'every');
verifyConfigurable(TypedArrayPrototype, 'every');

View File

@ -0,0 +1,46 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.every
description: >
Returns false if any callbackfn call returns a coerced false.
info: |
22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
%TypedArray%.prototype.every is a distinct function that implements the same
algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
object's [[ArrayLength]] internal slot is accessed in place of performing a
[[Get]] of "length".
22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
...
7. Return true.
includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA(42);
[
false,
"",
0,
-0,
NaN,
undefined,
null
].forEach(function(val) {
var called = 0;
var result = sample.every(function() {
called++;
if (called === 1) {
return true;
}
return val;
});
assert.sameValue(called, 2, "callbackfn called until it returned " + val);
assert.sameValue(result, false, "result is false when it returned " + val);
});
});

View File

@ -0,0 +1,46 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.every
description: >
Returns true if every callbackfn returns a coerced true.
info: |
22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
%TypedArray%.prototype.every is a distinct function that implements the same
algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
object's [[ArrayLength]] internal slot is accessed in place of performing a
[[Get]] of "length".
22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
...
7. Return true.
includes: [testBigIntTypedArray.js]
features: [BigInt, Symbol, TypedArray]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
var called = 0;
var values = [
true,
1,
"test262",
Symbol("1"),
{},
[],
-1,
Infinity,
-Infinity,
0.1,
-0.1
];
var sample = new TA(values.length);
var result = sample.every(function() {
called++;
return values.unshift();
});
assert.sameValue(called, sample.length, "callbackfn called for each index");
assert.sameValue(result, true, "return is true");
});

View File

@ -0,0 +1,51 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.every
description: Throws a TypeError exception when `this` is not Object
info: |
22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
This function is not generic. ValidateTypedArray is applied to the this value
prior to evaluating the algorithm. If its result is an abrupt completion that
exception is thrown instead of evaluating the algorithm.
22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
1. If Type(O) is not Object, throw a TypeError exception.
...
includes: [testBigIntTypedArray.js]
features: [BigInt, Symbol, TypedArray]
---*/
var every = TypedArray.prototype.every;
var callbackfn = function() {};
assert.throws(TypeError, function() {
every.call(undefined, callbackfn);
}, "this is undefined");
assert.throws(TypeError, function() {
every.call(null, callbackfn);
}, "this is null");
assert.throws(TypeError, function() {
every.call(42, callbackfn);
}, "this is 42");
assert.throws(TypeError, function() {
every.call("1", callbackfn);
}, "this is a string");
assert.throws(TypeError, function() {
every.call(true, callbackfn);
}, "this is true");
assert.throws(TypeError, function() {
every.call(false, callbackfn);
}, "this is false");
var s = Symbol("s");
assert.throws(TypeError, function() {
every.call(s, callbackfn);
}, "this is a Symbol");

View File

@ -0,0 +1,43 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.every
description: >
Throws a TypeError exception when `this` is not a TypedArray instance
info: |
22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
This function is not generic. ValidateTypedArray is applied to the this value
prior to evaluating the algorithm. If its result is an abrupt completion that
exception is thrown instead of evaluating the algorithm.
22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
1. If Type(O) is not Object, throw a TypeError exception.
2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
exception.
...
includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray]
---*/
var every = TypedArray.prototype.every;
var callbackfn = function() {};
assert.throws(TypeError, function() {
every.call({}, callbackfn);
}, "this is an Object");
assert.throws(TypeError, function() {
every.call([], callbackfn);
}, "this is an Array");
var ab = new ArrayBuffer(8);
assert.throws(TypeError, function() {
every.call(ab, callbackfn);
}, "this is an ArrayBuffer instance");
var dv = new DataView(new ArrayBuffer(8), 0, 1);
assert.throws(TypeError, function() {
every.call(dv, callbackfn);
}, "this is a DataView instance");

View File

@ -0,0 +1,42 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.every
description: >
Integer indexed values are not cached before iteration
info: |
22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
%TypedArray%.prototype.every is a distinct function that implements the same
algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
object's [[ArrayLength]] internal slot is accessed in place of performing a
[[Get]] of "length".
22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
...
6. Repeat, while k < len
..
c. If kPresent is true, then
i. Let kValue be ? Get(O, Pk).
ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
...
includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA(convertToBigInt([42, 43, 44]));
sample.every(function(v, i) {
if (i < sample.length - 1) {
sample[i+1] = convertToBigInt(42);
}
assert.sameValue(
v, convertToBigInt(42), "method does not cache values before callbackfn calls"
);
return true;
});
});

View File

@ -0,0 +1,104 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.fill
es6id: 22.2.3.8
description: >
Fills elements from coerced to Integer `start` and `end` values
info: |
22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
%TypedArray%.prototype.fill is a distinct function that implements the same
algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this
object's [[ArrayLength]] internal slot is accessed in place of performing a
[[Get]] of "length". The implementation of the algorithm may be optimized with
the knowledge that the this value is an object that has a fixed length and
whose integer indexed properties are not sparse. However, such optimization
must not introduce any observable changes in the specified behaviour of the
algorithm.
...
22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
...
3. Let relativeStart be ? ToInteger(start).
4. If relativeStart < 0, let k be max((len + relativeStart), 0); else let k be
min(relativeStart, len).
5. If end is undefined, let relativeEnd be len; else let relativeEnd be ?
ToInteger(end).
...
includes: [compareArray.js, testBigIntTypedArray.js]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
assert(
compareArray(new TA(convertToBigInt([0, 0])).fill(convertToBigInt(1), undefined), convertToBigInt([1, 1])),
'`undefined` start coerced to 0'
);
assert(
compareArray(new TA(convertToBigInt([0, 0])).fill(convertToBigInt(1), 0, undefined), convertToBigInt([1, 1])),
'If end is undefined, let relativeEnd be len'
);
assert(
compareArray(new TA(convertToBigInt([0, 0])).fill(convertToBigInt(1), null), convertToBigInt([1, 1])),
'`null` start coerced to 0'
);
assert(
compareArray(new TA(convertToBigInt([0, 0])).fill(convertToBigInt(1), 0, null), convertToBigInt([0, 0])),
'`null` end coerced to 0'
);
assert(
compareArray(new TA(convertToBigInt([0, 0])).fill(convertToBigInt(1), true), convertToBigInt([0, 1])),
'`true` start coerced to 1'
);
assert(
compareArray(new TA(convertToBigInt([0, 0])).fill(convertToBigInt(1), 0, true), convertToBigInt([1, 0])),
'`true` end coerced to 1'
);
assert(
compareArray(new TA(convertToBigInt([0, 0])).fill(convertToBigInt(1), false), convertToBigInt([1, 1])),
'`false` start coerced to 0'
);
assert(
compareArray(new TA(convertToBigInt([0, 0])).fill(convertToBigInt(1), 0, false), convertToBigInt([0, 0])),
'`false` end coerced to 0'
);
assert(
compareArray(new TA(convertToBigInt([0, 0])).fill(convertToBigInt(1), NaN), convertToBigInt([1, 1])),
'`NaN` start coerced to 0'
);
assert(
compareArray(new TA(convertToBigInt([0, 0])).fill(convertToBigInt(1), 0, NaN), convertToBigInt([0, 0])),
'`NaN` end coerced to 0'
);
assert(
compareArray(new TA(convertToBigInt([0, 0])).fill(convertToBigInt(1), '1'), convertToBigInt([0, 1])),
'string start coerced'
);
assert(
compareArray(new TA(convertToBigInt([0, 0])).fill(convertToBigInt(1), 0, '1'), convertToBigInt([1, 0])),
'string end coerced'
);
assert(
compareArray(new TA(convertToBigInt([0, 0])).fill(convertToBigInt(1), 1.5), convertToBigInt([0, 1])),
'start as a float number coerced'
);
assert(
compareArray(new TA(convertToBigInt([0, 0])).fill(convertToBigInt(1), 0, 1.5), convertToBigInt([1, 0])),
'end as a float number coerced'
);
});

View File

@ -0,0 +1,34 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.fill
description: Throws a TypeError if this has a detached buffer
info: |
22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
This function is not generic. ValidateTypedArray is applied to the this value
prior to evaluating the algorithm. If its result is an abrupt completion that
exception is thrown instead of evaluating the algorithm.
22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
...
5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
...
includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
features: [BigInt, TypedArray]
---*/
var obj = {
valueOf: function() {
throw new Test262Error();
}
};
testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA(1);
$DETACHBUFFER(sample.buffer);
assert.throws(TypeError, function() {
sample.fill(obj);
});
});

View File

@ -0,0 +1,27 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.fill
description: >
Fills all the elements with non numeric values values.
info: |
22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
...
3. Let _value_ be ? ToNumber(_value_).
...
includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA(2);
var n = 1;
sample.fill({ valueOf() { return convertToBigInt(n++); } });
assert.sameValue(n, 2, "additional unexpected ToNumber() calls");
assert.sameValue(sample[0], convertToBigInt(1), "incorrect ToNumber result in index 0");
assert.sameValue(sample[1], convertToBigInt(1), "incorrect ToNumber result in index 1");
});

View File

@ -0,0 +1,70 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.fill
es6id: 22.2.3.8
description: Consistent canonicalization of NaN values
info: |
22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
%TypedArray%.prototype.fill is a distinct function that implements the same
algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this
object's [[ArrayLength]] internal slot is accessed in place of performing a
[[Get]] of "length". The implementation of the algorithm may be optimized with
the knowledge that the this value is an object that has a fixed length and
whose integer indexed properties are not sparse. However, such optimization
must not introduce any observable changes in the specified behaviour of the
algorithm.
...
22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
...
7. Repeat, while k < final
a. Let Pk be ! ToString(k).
b. Perform ? Set(O, Pk, value, true).
...
24.1.1.6 SetValueInBuffer ( arrayBuffer, byteIndex, type, value [ ,
isLittleEndian ] )
...
8. If type is "Float32", then
a. Set rawBytes to a List containing the 4 bytes that are the result
of converting value to IEEE 754-2008 binary32 format using Round to
nearest, ties to even rounding mode. If isLittleEndian is false, the
bytes are arranged in big endian order. Otherwise, the bytes are
arranged in little endian order. If value is NaN, rawValue may be set
to any implementation chosen IEEE 754-2008 binary64 format Not-a-Number
encoding. An implementation must always choose the same encoding for
each implementation distinguishable NaN value.
9. Else, if type is "Float64", then
a. Set rawBytes to a List containing the 8 bytes that are the IEEE
754-2008 binary64 format encoding of value. If isLittleEndian is false,
the bytes are arranged in big endian order. Otherwise, the bytes are
arranged in little endian order. If value is NaN, rawValue may be set
to any implementation chosen IEEE 754-2008 binary32 format Not-a-Number
encoding. An implementation must always choose the same encoding for
each implementation distinguishable NaN value.
...
includes: [nans.js, testBigIntTypedArray.js, compareArray.js]
---*/
function body(FloatArray) {
var sample = new FloatArray(3);
var control, idx, someNaN, sampleBytes, controlBytes;
for (idx = 0; idx < distinctNaNs.length; ++idx) {
someNaN = distinctNaNs[idx];
control = new FloatArray([someNaN, someNaN, someNaN]);
sample.fill(someNaN);
sampleBytes = new Uint8Array(sample.buffer);
controlBytes = new Uint8Array(control.buffer);
assert(compareArray(sampleBytes, controlBytes), 'NaN value #' + idx);
}
}
testWithBigIntTypedArrayConstructors(body, [Float32Array, Float64Array]);

View File

@ -0,0 +1,56 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.fill
es6id: 22.2.3.8
description: >
Fills all the elements with non numeric values values.
info: |
22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
%TypedArray%.prototype.fill is a distinct function that implements the same
algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this
object's [[ArrayLength]] internal slot is accessed in place of performing a
[[Get]] of "length". The implementation of the algorithm may be optimized with
the knowledge that the this value is an object that has a fixed length and
whose integer indexed properties are not sparse. However, such optimization
must not introduce any observable changes in the specified behaviour of the
algorithm.
...
22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
...
7. Repeat, while k < final
a. Let Pk be ! ToString(k).
b. Perform ? Set(O, Pk, value, true).
...
24.1.1.6 SetValueInBuffer ( arrayBuffer, byteIndex, type, value [ ,
isLittleEndian ] )
...
8. If type is "Float32", then
...
9. Else, if type is "Float64", then
...
10. Else,
...
b. Let convOp be the abstract operation named in the Conversion Operation
column in Table 50 for Element Type type.
c. Let intValue be convOp(value).
d. If intValue 0, then
...
e. Else,
...
includes: [byteConversionValues.js, testBigIntTypedArray.js]
---*/
testTypedArrayConversions(byteConversionValues, function(TA, value, expected, initial) {
var sample = new TA([initial]);
sample.fill(value);
assert.sameValue(sample[0], expected, value + " converts to " + expected);
});

View File

@ -0,0 +1,42 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.fill
es6id: 22.2.3.8
description: >
Fills all the elements from a with a custom start and end indexes.
info: |
22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
%TypedArray%.prototype.fill is a distinct function that implements the same
algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this
object's [[ArrayLength]] internal slot is accessed in place of performing a
[[Get]] of "length". The implementation of the algorithm may be optimized with
the knowledge that the this value is an object that has a fixed length and
whose integer indexed properties are not sparse. However, such optimization
must not introduce any observable changes in the specified behaviour of the
algorithm.
...
22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
...
3. Let relativeStart be ? ToInteger(start).
4. If relativeStart < 0, let k be max((len + relativeStart), 0); else let k be
min(relativeStart, len).
5. If end is undefined, let relativeEnd be len; else let relativeEnd be ?
ToInteger(end).
6. If relativeEnd < 0, let final be max((len + relativeEnd), 0); else let
final be min(relativeEnd, len).
...
includes: [compareArray.js, testBigIntTypedArray.js]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
assert(compareArray(new TA(convertToBigInt([0, 0, 0])).fill(convertToBigInt(8), 1, 2), convertToBigInt([0, 8, 0])));
assert(compareArray(new TA(convertToBigInt([0, 0, 0, 0, 0])).fill(convertToBigInt(8), -3, 4), convertToBigInt([0, 0, 8, 8, 0])));
assert(compareArray(new TA(convertToBigInt([0, 0, 0, 0, 0])).fill(convertToBigInt(8), -2, -1), convertToBigInt([0, 0, 0, 8, 0])));
assert(compareArray(new TA(convertToBigInt([0, 0, 0, 0, 0])).fill(convertToBigInt(8), -1, -3), convertToBigInt([0, 0, 0, 0, 0])));
assert(compareArray(new TA(convertToBigInt([0, 0, 0, 0, 0])).fill(convertToBigInt(8), 1, 3), convertToBigInt([0, 8, 8, 0, 0])));
});

View File

@ -0,0 +1,73 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.fill
es6id: 22.2.3.8
description: >
Fills all the elements with non numeric values values.
info: |
22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
%TypedArray%.prototype.fill is a distinct function that implements the same
algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this
object's [[ArrayLength]] internal slot is accessed in place of performing a
[[Get]] of "length". The implementation of the algorithm may be optimized with
the knowledge that the this value is an object that has a fixed length and
whose integer indexed properties are not sparse. However, such optimization
must not introduce any observable changes in the specified behaviour of the
algorithm.
...
22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
...
7. Repeat, while k < final
a. Let Pk be ! ToString(k).
b. Perform ? Set(O, Pk, value, true).
...
9.4.5.9 IntegerIndexedElementSet ( O, index, value )
...
3. Let numValue be ? ToNumber(value).
...
includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
var sample;
sample = new TA(convertToBigInt([42]));
sample.fill(false);
assert.sameValue(sample[0], convertToBigInt(0), "false => 0");
sample = new TA(convertToBigInt([42]));
sample.fill(true);
assert.sameValue(sample[0], convertToBigInt(1), "true => 1");
sample = new TA(convertToBigInt([42]));
sample.fill("7");
assert.sameValue(sample[0], convertToBigInt(7), "string conversion");
sample = new TA(convertToBigInt([42]));
sample.fill({
toString: function() {
return "1";
},
valueOf: function() {
return convertToBigInt(7);
}
});
assert.sameValue(sample[0], convertToBigInt(7), "object valueOf conversion before toString");
sample = new TA(convertToBigInt([42]));
sample.fill({
toString: function() {
return "7";
}
});
assert.sameValue(sample[0], convertToBigInt(7), "object toString when valueOf is absent");
});

View File

@ -0,0 +1,53 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.fill
es6id: 22.2.3.8
description: >
Fills all the elements from a with a custom end index.
info: |
22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
%TypedArray%.prototype.fill is a distinct function that implements the same
algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this
object's [[ArrayLength]] internal slot is accessed in place of performing a
[[Get]] of "length". The implementation of the algorithm may be optimized with
the knowledge that the this value is an object that has a fixed length and
whose integer indexed properties are not sparse. However, such optimization
must not introduce any observable changes in the specified behaviour of the
algorithm.
...
22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
...
5. If end is undefined, let relativeEnd be len; else let relativeEnd be ?
ToInteger(end).
6. If relativeEnd < 0, let final be max((len + relativeEnd), 0); else let
final be min(relativeEnd, len).
...
includes: [compareArray.js, testBigIntTypedArray.js]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
assert(
compareArray(new TA(convertToBigInt([0, 0, 0])).fill(convertToBigInt(8), 0, 1), convertToBigInt([8, 0, 0])),
"Fill elements from custom end position"
);
assert(
compareArray(new TA(convertToBigInt([0, 0, 0])).fill(convertToBigInt(8), 0, -1), convertToBigInt([8, 8, 0])),
"negative end sets final position to max((length + relativeEnd), 0)"
);
assert(
compareArray(new TA(convertToBigInt([0, 0, 0])).fill(convertToBigInt(8), 0, 5), convertToBigInt([8, 8, 8])),
"end position is never higher than of length"
);
assert(
compareArray(new TA(convertToBigInt([0, 0, 0])).fill(convertToBigInt(8), 0, -4), convertToBigInt([0, 0, 0])),
"end position is 0 when (len + relativeEnd) < 0"
);
});

View File

@ -0,0 +1,51 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.fill
es6id: 22.2.3.8
description: >
Fills all the elements from a with a custom start index.
info: |
22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
%TypedArray%.prototype.fill is a distinct function that implements the same
algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this
object's [[ArrayLength]] internal slot is accessed in place of performing a
[[Get]] of "length". The implementation of the algorithm may be optimized with
the knowledge that the this value is an object that has a fixed length and
whose integer indexed properties are not sparse. However, such optimization
must not introduce any observable changes in the specified behaviour of the
algorithm.
...
22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
...
4. If relativeStart < 0, let k be max((len + relativeStart), 0); else let k be
min(relativeStart, len).
...
includes: [compareArray.js, testBigIntTypedArray.js]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
assert(
compareArray(new TA(convertToBigInt([0, 0, 0])).fill(convertToBigInt(8), 1), convertToBigInt([0, 8, 8])),
"Fill elements from custom start position"
);
assert(
compareArray(new TA(convertToBigInt([0, 0, 0])).fill(convertToBigInt(8), 4), convertToBigInt([0, 0, 0])),
"start position is never higher than length"
);
assert(
compareArray(new TA(convertToBigInt([0, 0, 0])).fill(convertToBigInt(8), -1), convertToBigInt([0, 0, 8])),
"start < 0 sets initial position to max((len + relativeStart), 0)"
);
assert(
compareArray(new TA(convertToBigInt([0, 0, 0])).fill(convertToBigInt(8), -5), convertToBigInt([8, 8, 8])),
"start position is 0 when (len + relativeStart) < 0"
);
});

View File

@ -0,0 +1,48 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.fill
es6id: 22.2.3.8
description: >
Throws a TypeError if value is a Symbol
info: |
22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
%TypedArray%.prototype.fill is a distinct function that implements the same
algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this
object's [[ArrayLength]] internal slot is accessed in place of performing a
[[Get]] of "length". The implementation of the algorithm may be optimized with
the knowledge that the this value is an object that has a fixed length and
whose integer indexed properties are not sparse. However, such optimization
must not introduce any observable changes in the specified behaviour of the
algorithm.
...
22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
...
7. Repeat, while k < final
a. Let Pk be ! ToString(k).
b. Perform ? Set(O, Pk, value, true).
...
9.4.5.9 IntegerIndexedElementSet ( O, index, value )
...
3. Let numValue be ? ToNumber(value).
...
includes: [testBigIntTypedArray.js]
features: [BigInt, Symbol, TypedArray]
---*/
var s = Symbol('1');
testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA(1);
assert.throws(TypeError, function() {
sample.fill(s);
});
});

View File

@ -0,0 +1,44 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.fill
es6id: 22.2.3.8
description: >
Fills all the elements with `value` from a default start and index.
info: |
22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
%TypedArray%.prototype.fill is a distinct function that implements the same
algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this
object's [[ArrayLength]] internal slot is accessed in place of performing a
[[Get]] of "length". The implementation of the algorithm may be optimized with
the knowledge that the this value is an object that has a fixed length and
whose integer indexed properties are not sparse. However, such optimization
must not introduce any observable changes in the specified behaviour of the
algorithm.
...
22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
...
7. Repeat, while k < final
a. Let Pk be ! ToString(k).
b. Perform ? Set(O, Pk, value, true).
includes: [compareArray.js, testBigIntTypedArray.js]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
assert(
compareArray(
new TA().fill(convertToBigInt(8)),
[]
),
"does not fill an empty instance"
);
assert(
compareArray(new TA(convertToBigInt([0, 0, 0])).fill(convertToBigInt(8)), convertToBigInt([8, 8, 8])),
"Default start and end indexes are 0 and this.length"
);
});

View File

@ -0,0 +1,52 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.fill
es6id: 22.2.3.8
description: >
Unreachable abrupt from Get(O, "length") as [[ArrayLength]] is returned.
info: |
22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
%TypedArray%.prototype.fill is a distinct function that implements the same
algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this
object's [[ArrayLength]] internal slot is accessed in place of performing a
[[Get]] of "length". The implementation of the algorithm may be optimized with
the knowledge that the this value is an object that has a fixed length and
whose integer indexed properties are not sparse. However, such optimization
must not introduce any observable changes in the specified behaviour of the
algorithm.
...
22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
1. Let O be ? ToObject(this value).
2. Let len be ? ToLength(? Get(O, "length")).
...
includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray]
---*/
Object.defineProperty(TypedArray.prototype, "length", {
get: function() {
throw new Test262Error();
}
});
testWithBigIntTypedArrayConstructors(function(TA) {
Object.defineProperty(TA.prototype, "length", {
get: function() {
throw new Test262Error();
}
});
var sample = new TA(1);
Object.defineProperty(sample, "length", {
get: function() {
throw new Test262Error();
}
});
assert.sameValue(sample.fill(convertToBigInt(1), 0), sample);
});

View File

@ -0,0 +1,29 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.2.3.8
description: Throws a TypeError exception when invoked as a function
info: |
22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
This function is not generic. ValidateTypedArray is applied to the this value
prior to evaluating the algorithm. If its result is an abrupt completion that
exception is thrown instead of evaluating the algorithm.
22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
1. If Type(O) is not Object, throw a TypeError exception.
2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
exception.
...
includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray]
---*/
var fill = TypedArray.prototype.fill;
assert.sameValue(typeof fill, 'function');
assert.throws(TypeError, function() {
fill();
});

View File

@ -0,0 +1,29 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.2.3.8
description: Requires a [[TypedArrayName]] internal slot.
info: |
22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
This function is not generic. ValidateTypedArray is applied to the this value
prior to evaluating the algorithm. If its result is an abrupt completion that
exception is thrown instead of evaluating the algorithm.
22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
1. If Type(O) is not Object, throw a TypeError exception.
2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
exception.
...
includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray]
---*/
var TypedArrayPrototype = TypedArray.prototype;
assert.sameValue(typeof TypedArrayPrototype.fill, 'function');
assert.throws(TypeError, function() {
TypedArrayPrototype.fill();
});

View File

@ -0,0 +1,29 @@
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.2.3.8
description: >
%TypedArray%.prototype.fill.length is 1.
info: |
%TypedArray%.prototype.fill (value [ , start [ , end ] ] )
17 ECMAScript Standard Built-in Objects:
Every built-in Function object, including constructors, has a length
property whose value is an integer. Unless otherwise specified, this
value is equal to the largest number of named arguments shown in the
subclause headings for the function description, including optional
parameters. However, rest parameters shown using the form ...name
are not included in the default argument count.
Unless otherwise specified, the length property of a built-in Function
object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
[[Configurable]]: true }.
includes: [propertyHelper.js, testBigIntTypedArray.js]
---*/
assert.sameValue(TypedArray.prototype.fill.length, 1);
verifyNotEnumerable(TypedArray.prototype.fill, "length");
verifyNotWritable(TypedArray.prototype.fill, "length");
verifyConfigurable(TypedArray.prototype.fill, "length");

View File

@ -0,0 +1,26 @@
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.2.3.8
description: >
%TypedArray%.prototype.fill.name is "fill".
info: |
%TypedArray%.prototype.fill (value [ , start [ , end ] ] )
17 ECMAScript Standard Built-in Objects:
Every built-in Function object, including constructors, that is not
identified as an anonymous function has a name property whose value
is a String.
Unless otherwise specified, the name property of a built-in Function
object, if it exists, has the attributes { [[Writable]]: false,
[[Enumerable]]: false, [[Configurable]]: true }.
includes: [propertyHelper.js, testBigIntTypedArray.js]
---*/
assert.sameValue(TypedArray.prototype.fill.name, "fill");
verifyNotEnumerable(TypedArray.prototype.fill, "name");
verifyNotWritable(TypedArray.prototype.fill, "name");
verifyConfigurable(TypedArray.prototype.fill, "name");

View File

@ -0,0 +1,18 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.2.3.8
description: >
"fill" property of TypedArrayPrototype
info: |
ES6 section 17: Every other data property described in clauses 18 through 26
and in Annex B.2 has the attributes { [[Writable]]: true,
[[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
includes: [propertyHelper.js, testBigIntTypedArray.js]
---*/
var TypedArrayPrototype = TypedArray.prototype;
verifyNotEnumerable(TypedArrayPrototype, 'fill');
verifyWritable(TypedArrayPrototype, 'fill');
verifyConfigurable(TypedArrayPrototype, 'fill');

View File

@ -0,0 +1,39 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.fill
es6id: 22.2.3.8
description: >
Return abrupt if end is a Symbol.
info: |
22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
%TypedArray%.prototype.fill is a distinct function that implements the same
algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this
object's [[ArrayLength]] internal slot is accessed in place of performing a
[[Get]] of "length". The implementation of the algorithm may be optimized with
the knowledge that the this value is an object that has a fixed length and
whose integer indexed properties are not sparse. However, such optimization
must not introduce any observable changes in the specified behaviour of the
algorithm.
...
22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
...
5. If end is undefined, let relativeEnd be len; else let relativeEnd be ?
ToInteger(end).
...
includes: [testBigIntTypedArray.js]
features: [BigInt, Symbol, TypedArray]
---*/
var end = Symbol(1);
testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA();
assert.throws(TypeError, function() {
sample.fill(1, 0, end);
});
});

View File

@ -0,0 +1,43 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.fill
es6id: 22.2.3.8
description: >
Return abrupt from ToInteger(end).
info: |
22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
%TypedArray%.prototype.fill is a distinct function that implements the same
algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this
object's [[ArrayLength]] internal slot is accessed in place of performing a
[[Get]] of "length". The implementation of the algorithm may be optimized with
the knowledge that the this value is an object that has a fixed length and
whose integer indexed properties are not sparse. However, such optimization
must not introduce any observable changes in the specified behaviour of the
algorithm.
...
22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
...
5. If end is undefined, let relativeEnd be len; else let relativeEnd be ?
ToInteger(end).
...
includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray]
---*/
var end = {
valueOf: function() {
throw new Test262Error();
}
};
testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA();
assert.throws(Test262Error, function() {
sample.fill(convertToBigInt(1), 0, end);
});
});

View File

@ -0,0 +1,51 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.fill
es6id: 22.2.3.8
description: >
Returns abrupt from value set
info: |
22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
%TypedArray%.prototype.fill is a distinct function that implements the same
algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this
object's [[ArrayLength]] internal slot is accessed in place of performing a
[[Get]] of "length". The implementation of the algorithm may be optimized with
the knowledge that the this value is an object that has a fixed length and
whose integer indexed properties are not sparse. However, such optimization
must not introduce any observable changes in the specified behaviour of the
algorithm.
...
22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
...
7. Repeat, while k < final
a. Let Pk be ! ToString(k).
b. Perform ? Set(O, Pk, value, true).
...
9.4.5.9 IntegerIndexedElementSet ( O, index, value )
...
3. Let numValue be ? ToNumber(value).
...
includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA(convertToBigInt([42]));
var obj = {
valueOf: function() {
throw new Test262Error();
}
};
assert.throws(Test262Error, function() {
sample.fill(obj);
});
});

View File

@ -0,0 +1,38 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.fill
es6id: 22.2.3.8
description: >
Return abrupt from ToInteger(start) as a Symbol.
info: |
22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
%TypedArray%.prototype.fill is a distinct function that implements the same
algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this
object's [[ArrayLength]] internal slot is accessed in place of performing a
[[Get]] of "length". The implementation of the algorithm may be optimized with
the knowledge that the this value is an object that has a fixed length and
whose integer indexed properties are not sparse. However, such optimization
must not introduce any observable changes in the specified behaviour of the
algorithm.
...
22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
...
3. Let relativeStart be ? ToInteger(start).
...
includes: [testBigIntTypedArray.js]
features: [BigInt, Symbol, TypedArray]
---*/
var start = Symbol(1);
testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA();
assert.throws(TypeError, function() {
sample.fill(1, start);
});
});

View File

@ -0,0 +1,42 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.fill
es6id: 22.2.3.8
description: >
Return abrupt from ToInteger(start).
info: |
22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
%TypedArray%.prototype.fill is a distinct function that implements the same
algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this
object's [[ArrayLength]] internal slot is accessed in place of performing a
[[Get]] of "length". The implementation of the algorithm may be optimized with
the knowledge that the this value is an object that has a fixed length and
whose integer indexed properties are not sparse. However, such optimization
must not introduce any observable changes in the specified behaviour of the
algorithm.
...
22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
...
3. Let relativeStart be ? ToInteger(start).
...
includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray]
---*/
var start = {
valueOf: function() {
throw new Test262Error();
}
};
testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA();
assert.throws(Test262Error, function() {
sample.fill(convertToBigInt(1), start);
});
});

View File

@ -0,0 +1,21 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.fill
es6id: 22.2.3.8
description: >
Returns `this`.
includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
var sample1 = new TA();
var result1 = sample1.fill(convertToBigInt(1));
assert.sameValue(result1, sample1);
var sample2 = new TA(42);
var result2 = sample2.fill(convertToBigInt(7));
assert.sameValue(result2, sample2);
});

View File

@ -0,0 +1,50 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.fill
description: Throws a TypeError exception when `this` is not Object
info: |
22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
This function is not generic. ValidateTypedArray is applied to the this value
prior to evaluating the algorithm. If its result is an abrupt completion that
exception is thrown instead of evaluating the algorithm.
22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
1. If Type(O) is not Object, throw a TypeError exception.
...
includes: [testBigIntTypedArray.js]
features: [BigInt, Symbol, TypedArray]
---*/
var fill = TypedArray.prototype.fill;
assert.throws(TypeError, function() {
fill.call(undefined, 0);
}, "this is undefined");
assert.throws(TypeError, function() {
fill.call(null, 0);
}, "this is null");
assert.throws(TypeError, function() {
fill.call(42, 0);
}, "this is 42");
assert.throws(TypeError, function() {
fill.call("1", 0);
}, "this is a string");
assert.throws(TypeError, function() {
fill.call(true, 0);
}, "this is true");
assert.throws(TypeError, function() {
fill.call(false, 0);
}, "this is false");
var s = Symbol("s");
assert.throws(TypeError, function() {
fill.call(s, 0);
}, "this is a Symbol");

View File

@ -0,0 +1,42 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.fill
description: >
Throws a TypeError exception when `this` is not a TypedArray instance
info: |
22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
This function is not generic. ValidateTypedArray is applied to the this value
prior to evaluating the algorithm. If its result is an abrupt completion that
exception is thrown instead of evaluating the algorithm.
22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
1. If Type(O) is not Object, throw a TypeError exception.
2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
exception.
...
includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray]
---*/
var fill = TypedArray.prototype.fill;
assert.throws(TypeError, function() {
fill.call({}, 0);
}, "this is an Object");
assert.throws(TypeError, function() {
fill.call([], 0);
}, "this is an Array");
var ab = new ArrayBuffer(8);
assert.throws(TypeError, function() {
fill.call(ab, 0);
}, "this is an ArrayBuffer instance");
var dv = new DataView(new ArrayBuffer(8), 0, 1);
assert.throws(TypeError, function() {
fill.call(dv, 0);
}, "this is a DataView instance");

View File

@ -40,11 +40,9 @@ features: [TypedArray]
testWithTypedArrayConstructors(function(TA, N) {
var sample;
if (numericTypedArrayConstructors.includes(TA)) {
sample = new TA(N([42]));
sample.fill(null);
assert.sameValue(sample[0], 0, "null => 0");
}
sample = new TA(N([42]));
sample.fill(null);
assert.sameValue(sample[0], 0, "null => 0");
sample = new TA(N([42]));
sample.fill(false);

View File

@ -0,0 +1,39 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.filter
description: Uses internal ArrayLength instead of length property
info: |
22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
...
3. Let len be the value of O's [[ArrayLength]] internal slot.
...
includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray]
---*/
var getCalls = 0;
var desc = {
get: function getLen() {
getCalls++;
return 0;
}
};
Object.defineProperty(TypedArray.prototype, "length", desc);
testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA(4);
var calls = 0;
Object.defineProperty(TA.prototype, "length", desc);
Object.defineProperty(sample, "length", desc);
sample.filter(function() {
calls++;
});
assert.sameValue(getCalls, 0, "ignores length properties");
assert.sameValue(calls, 4, "interactions are not affected by custom length");
});

View File

@ -0,0 +1,46 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.filter
description: >
thisArg does not affect callbackfn arguments
info: |
22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
...
9. Repeat, while k < len
...
c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
...
includes: [testBigIntTypedArray.js]
features: [BigInt, TypedArray]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA(convertToBigInt([42, 43, 44]));
var results = [];
var thisArg = ["test262", 0, "ecma262", 0];
sample.filter(function() {
results.push(arguments);
}, thisArg);
assert.sameValue(results.length, 3, "results.length");
assert.sameValue(thisArg.length, 4, "thisArg.length");
assert.sameValue(results[0].length, 3, "results[0].length");
assert.sameValue(results[0][0], convertToBigInt(42), "results[0][0] - kValue");
assert.sameValue(results[0][1], 0, "results[0][1] - k");
assert.sameValue(results[0][2], sample, "results[0][2] - this");
assert.sameValue(results[1].length, 3, "results[1].length");
assert.sameValue(results[1][0], convertToBigInt(43), "results[1][0] - kValue");
assert.sameValue(results[1][1], 1, "results[1][1] - k");
assert.sameValue(results[1][2], sample, "results[1][2] - this");
assert.sameValue(results[2].length, 3, "results[2].length");
assert.sameValue(results[2][0], convertToBigInt(44), "results[2][0] - kValue");
assert.sameValue(results[2][1], 2, "results[2][1] - k");
assert.sameValue(results[2][2], sample, "results[2][2] - this");
});

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