summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg')
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/as-array-returns.js28
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/as-generator-iterable-returns.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/bigint-tobigint64.js106
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/bigint-tobiguint64.js106
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/boolean-tobigint.js64
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/custom-proto-access-throws.js50
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/iterating-throws.js33
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/iterator-not-callable-throws.js41
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/iterator-throws.js36
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/length-excessive-throws.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/length-is-symbol-throws.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/length-throws.js36
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/new-instance-extensibility.js45
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/null-tobigint.js65
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/number-tobigint.js93
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/proto-from-ctor-realm.js39
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/shell.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/string-nan-tobigint.js72
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/string-tobigint.js88
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/symbol-tobigint.js71
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/throws-from-property.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/throws-setting-obj-to-primitive-typeerror.js88
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/throws-setting-obj-to-primitive.js86
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/throws-setting-obj-tostring.js99
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/throws-setting-obj-valueof-typeerror.js100
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/throws-setting-obj-valueof.js93
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/throws-setting-property.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/throws-setting-symbol-property.js36
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/undefined-newtarget-throws.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/undefined-tobigint.js65
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/use-custom-proto-if-object.js49
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/use-default-proto-if-custom-proto-is-not-object.js49
33 files changed, 1892 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/as-array-returns.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/as-array-returns.js
new file mode 100644
index 0000000000..0387477cfc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/as-array-returns.js
@@ -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.
+/*---
+esid: sec-typedarray-object
+description: >
+ Return typedArray from array argument
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var typedArray = new TA([7n, 42n]);
+ assert.sameValue(typedArray.length, 2);
+ assert.sameValue(typedArray[0], 7n);
+ assert.sameValue(typedArray[1], 42n);
+ assert.sameValue(typedArray.constructor, TA);
+ assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/as-generator-iterable-returns.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/as-generator-iterable-returns.js
new file mode 100644
index 0000000000..22f9358687
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/as-generator-iterable-returns.js
@@ -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-object
+description: >
+ Return typedArray from iterable argument
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var obj = (function *() {
+ yield 7n; yield 42n;
+ })();
+
+ var typedArray = new TA(obj);
+ assert.sameValue(typedArray.length, 2);
+ assert.sameValue(typedArray[0], 7n);
+ assert.sameValue(typedArray[1], 42n);
+ assert.sameValue(typedArray.constructor, TA);
+ assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/bigint-tobigint64.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/bigint-tobigint64.js
new file mode 100644
index 0000000000..b69f3f7759
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/bigint-tobigint64.js
@@ -0,0 +1,106 @@
+// Copyright (C) 2018 Valerie Young. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-object
+description: >
+ Behavior for input array of BigInts
+info: |
+ TypedArray ( object )
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+ ...
+ 8. Repeat, while k < len
+ ...
+ b. Let kValue be ? Get(arrayLike, Pk).
+ c. Perform ? Set(O, Pk, kValue, true).
+ ...
+
+ [[Set]] ( P, V, Receiver)
+ ...
+ 2. If Type(P) is String and if SameValue(O, Receiver) is true, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ i. Perform ? IntegerIndexedElementSet(O, numericIndex, V).
+ ii. Return true.
+ ...
+
+ IntegerIndexedElementSet ( O, index, value )
+
+ Assert: O is an Integer-Indexed exotic object.
+ If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value).
+ Otherwise, let numValue be ? ToNumber(value).
+ Let buffer be O.[[ViewedArrayBuffer]].
+ If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then
+ Let offset be O.[[ByteOffset]].
+ Let arrayTypeName be the String value of O.[[TypedArrayName]].
+ Let elementSize be the Element Size value specified in Table 62 for arrayTypeName.
+ Let indexedPosition be (ℝ(index) × elementSize) + offset.
+ Let elementType be the Element Type value in Table 62 for arrayTypeName.
+ Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue, true, Unordered).
+ Return NormalCompletion(undefined).
+
+ SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )
+ ...
+ 8. Let rawBytes be NumberToRawBytes(type, value, isLittleEndian).
+ ...
+
+ NumberToRawBytes( type, value, isLittleEndian )
+ ...
+ 3. Else,
+ a. Let n be the Number value of the Element Size specified in Table
+ [The TypedArray Constructors] for Element Type type.
+ b. Let convOp be the abstract operation named in the Conversion Operation
+ column in Table 9 for Element Type type.
+
+ The TypedArray Constructors
+ Element Type: BigInt64
+ Conversion Operation: ToBigInt64
+
+ ToBigInt64 ( argument )
+ The abstract operation ToBigInt64 converts argument to one of 264 integer
+ values in the range -2^63 through 2^63-1, inclusive.
+ This abstract operation functions as follows:
+ 1. Let n be ? ToBigInt(argument).
+ 2. Let int64bit be n modulo 2^64.
+ 3. If int64bit ≥ 2^63, return int64bit - 2^64; otherwise return int64bit.
+
+features: [BigInt, TypedArray]
+---*/
+
+var vals = [
+ 18446744073709551618n, // 2n ** 64n + 2n
+ 9223372036854775810n, // 2n ** 63n + 2n
+ 2n,
+ 0n,
+ -2n,
+ -9223372036854775810n, // -(2n ** 63n) - 2n
+ -18446744073709551618n, // -(2n ** 64n) - 2n
+];
+
+var typedArray = new BigInt64Array(vals);
+
+assert.sameValue(typedArray[0], 2n,
+ "ToBigInt64(2n ** 64n + 2n) => 2n");
+
+assert.sameValue(typedArray[1], -9223372036854775806n, // 2n - 2n ** 63n
+ "ToBigInt64(2n ** 63n + 2n) => -9223372036854775806n");
+
+assert.sameValue(typedArray[2], 2n,
+ "ToBigInt64(2n) => 2n");
+
+assert.sameValue(typedArray[3], 0n,
+ "ToBigInt64(0n) => 0n");
+
+assert.sameValue(typedArray[4], -2n,
+ "ToBigInt64( -2n) => -2n");
+
+assert.sameValue(typedArray[5], 9223372036854775806n, // 2n ** 63n - 2
+ "ToBigInt64( -(2n ** 64n) - 2n) => 9223372036854775806n");
+
+assert.sameValue(typedArray[6], -2n,
+ "ToBigInt64( -(2n ** 64n) - 2n) => -2n");
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/bigint-tobiguint64.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/bigint-tobiguint64.js
new file mode 100644
index 0000000000..4d7dca6050
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/bigint-tobiguint64.js
@@ -0,0 +1,106 @@
+// Copyright (C) 2018 Valerie Young. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-object
+description: >
+ Behavior for input array of BigInts
+info: |
+ TypedArray ( object )
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+ ...
+ 8. Repeat, while k < len
+ ...
+ b. Let kValue be ? Get(arrayLike, Pk).
+ c. Perform ? Set(O, Pk, kValue, true).
+ ...
+
+ [[Set]] ( P, V, Receiver)
+ ...
+ 2. If Type(P) is String and if SameValue(O, Receiver) is true, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ i. Perform ? IntegerIndexedElementSet(O, numericIndex, V).
+ ii. Return true.
+ ...
+
+ IntegerIndexedElementSet ( O, index, value )
+
+ Assert: O is an Integer-Indexed exotic object.
+ If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value).
+ Otherwise, let numValue be ? ToNumber(value).
+ Let buffer be O.[[ViewedArrayBuffer]].
+ If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then
+ Let offset be O.[[ByteOffset]].
+ Let arrayTypeName be the String value of O.[[TypedArrayName]].
+ Let elementSize be the Element Size value specified in Table 62 for arrayTypeName.
+ Let indexedPosition be (ℝ(index) × elementSize) + offset.
+ Let elementType be the Element Type value in Table 62 for arrayTypeName.
+ Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue, true, Unordered).
+ Return NormalCompletion(undefined).
+
+ SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )
+ ...
+ 8. Let rawBytes be NumberToRawBytes(type, value, isLittleEndian).
+ ...
+
+ NumberToRawBytes( type, value, isLittleEndian )
+ ...
+ 3. Else,
+ a. Let n be the Number value of the Element Size specified in Table
+ [The TypedArray Constructors] for Element Type type.
+ b. Let convOp be the abstract operation named in the Conversion Operation
+ column in Table 9 for Element Type type.
+
+ The TypedArray Constructors
+ Element Type: BigUint64
+ Conversion Operation: ToBigUint64
+
+ ToBigUint64 ( argument )
+ The abstract operation ToBigInt64 converts argument to one of 264 integer
+ values in the range -2^63 through 2^63-1, inclusive.
+ This abstract operation functions as follows:
+ 1. Let n be ? ToBigInt(argument).
+ 2. Let int64bit be n modulo 2^64.
+ 3. Return int64bit.
+
+features: [BigInt, TypedArray]
+---*/
+
+var vals = [
+ 18446744073709551618n, // 2n ** 64n + 2n
+ 9223372036854775810n, // 2n ** 63n + 2n
+ 2n,
+ 0n,
+ -2n,
+ -9223372036854775810n, // -(2n ** 63n) - 2n
+ -18446744073709551618n, // -(2n ** 64n) - 2n
+];
+
+var typedArray = new BigUint64Array(vals);
+
+
+assert.sameValue(typedArray[0], 2n,
+ "ToBigUint64(2n ** 64n + 2n) => 2n");
+
+assert.sameValue(typedArray[1], 9223372036854775810n, // 2n ** 63n + 2n
+ "ToBigUint64(2n ** 63n + 2n) => 9223372036854775810");
+
+assert.sameValue(typedArray[2], 2n,
+ "ToBigUint64(2n) => 2n");
+
+assert.sameValue(typedArray[3], 0n,
+ "ToBigUint64(0n) => 0n");
+
+assert.sameValue(typedArray[4], 18446744073709551614n, // 2n ** 64n - 2n
+ "ToBigUint64( -2n) => 18446744073709551614n");
+
+assert.sameValue(typedArray[5], 9223372036854775806n, // 2n ** 63n - 2n
+ "ToBigUint64( -(2n ** 63n) - 2n) => 9223372036854775806n");
+
+assert.sameValue(typedArray[6], 18446744073709551614n, // 2n ** 64n - 2n
+ "ToBigUint64( -(2n ** 64n) - 2n) => 18446744073709551614n");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/boolean-tobigint.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/boolean-tobigint.js
new file mode 100644
index 0000000000..a3ed66ff5c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/boolean-tobigint.js
@@ -0,0 +1,64 @@
+// Copyright (C) 2018 Valerie Young. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-object
+description: >
+ Behavior for input array of Booleans
+info: |
+ TypedArray ( object )
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+ ...
+ 8. Repeat, while k < len
+ ...
+ b. Let kValue be ? Get(arrayLike, Pk).
+ c. Perform ? Set(O, Pk, kValue, true).
+ ...
+
+ [[Set]] ( P, V, Receiver)
+ ...
+ 2. If Type(P) is String and if SameValue(O, Receiver) is true, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ i. Perform ? IntegerIndexedElementSet(O, numericIndex, V).
+ ii. Return true.
+ ...
+
+ IntegerIndexedElementSet ( O, index, value )
+
+ Assert: O is an Integer-Indexed exotic object.
+ If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value).
+ Otherwise, let numValue be ? ToNumber(value).
+ Let buffer be O.[[ViewedArrayBuffer]].
+ If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then
+ Let offset be O.[[ByteOffset]].
+ Let arrayTypeName be the String value of O.[[TypedArrayName]].
+ Let elementSize be the Element Size value specified in Table 62 for arrayTypeName.
+ Let indexedPosition be (ℝ(index) × elementSize) + offset.
+ Let elementType be the Element Type value in Table 62 for arrayTypeName.
+ Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue, true, Unordered).
+ Return NormalCompletion(undefined).
+
+ ToBigInt ( argument )
+ Object, Apply the following steps:
+ 1. Let prim be ? ToPrimitive(argument, hint Number).
+ 2. Return the value that prim corresponds to in Table [BigInt Conversions]
+
+ BigInt Conversions
+ Argument Type: Boolean
+ Result: Return 1n if prim is true and 0n if prim is false.
+
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var typedArray = new TA([false, true]);
+
+ assert.sameValue(typedArray[0], 0n);
+ assert.sameValue(typedArray[1], 1n);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/browser.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/custom-proto-access-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/custom-proto-access-throws.js
new file mode 100644
index 0000000000..78ec0dcf6b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/custom-proto-access-throws.js
@@ -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-object
+description: >
+ Return abrupt completion getting newTarget's prototype
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 3. Let O be ? AllocateTypedArray(TypedArray.[[TypedArrayConstructorName]],
+ NewTarget, "%TypedArrayPrototype%").
+ ...
+
+ 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget,
+ defaultProto [ , length ])
+
+ 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto).
+ ...
+
+ 9.1.15 GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto )
+
+ ...
+ 3. Let proto be ? Get(constructor, "prototype").
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Reflect, TypedArray]
+---*/
+
+var newTarget = function() {}.bind(null);
+Object.defineProperty(newTarget, "prototype", {
+ get() {
+ throw new Test262Error();
+ }
+});
+
+var o = {};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ assert.throws(Test262Error, function() {
+ Reflect.construct(TA, [o], newTarget);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/iterating-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/iterating-throws.js
new file mode 100644
index 0000000000..c043d54876
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/iterating-throws.js
@@ -0,0 +1,33 @@
+// 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-object
+description: >
+ Return abrupt from iterating object argument
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 4. Let arrayLike be ? IterableToArrayLike(object).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var obj = (function *() {
+ yield 0;
+ throw new Test262Error();
+ })();
+
+ assert.throws(Test262Error, function() {
+ new TA(obj);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/iterator-not-callable-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/iterator-not-callable-throws.js
new file mode 100644
index 0000000000..fd884b5656
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/iterator-not-callable-throws.js
@@ -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-object
+description: >
+ Return abrupt when object @@iterator is not callable
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 4. Let arrayLike be ? IterableToArrayLike(object).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.iterator, TypedArray]
+---*/
+
+var obj = function () {};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ obj[Symbol.iterator] = {};
+ assert.throws(TypeError, function() {
+ new TA(obj);
+ });
+
+ obj[Symbol.iterator] = true;
+ assert.throws(TypeError, function() {
+ new TA(obj);
+ });
+
+ obj[Symbol.iterator] = 42;
+ assert.throws(TypeError, function() {
+ new TA(obj);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/iterator-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/iterator-throws.js
new file mode 100644
index 0000000000..613de71ced
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/iterator-throws.js
@@ -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-object
+description: >
+ Return abrupt from getting object @@iterator
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 4. Let arrayLike be ? IterableToArrayLike(object).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.iterator, TypedArray]
+---*/
+
+var obj = function () {};
+
+Object.defineProperty(obj, Symbol.iterator, {
+ get() {
+ throw new Test262Error();
+ }
+});
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ assert.throws(Test262Error, function() {
+ new TA(obj);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/length-excessive-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/length-excessive-throws.js
new file mode 100644
index 0000000000..3492481689
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/length-excessive-throws.js
@@ -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-object
+description: >
+ Return abrupt from allocating array buffer with excessive length
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 6. Perform ? AllocateTypedArrayBuffer(O, len).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var obj = {
+ length: Math.pow(2, 53)
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ assert.throws(RangeError, function() {
+ new TA(obj);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/length-is-symbol-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/length-is-symbol-throws.js
new file mode 100644
index 0000000000..b12e29585f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/length-is-symbol-throws.js
@@ -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-object
+description: >
+ Return abrupt from length property as a Symbol on the object argument
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 5. Let len be ? ToLength(? Get(arrayLike, "length")).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+var obj = {
+ length: Symbol("1")
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ assert.throws(TypeError, function() {
+ new TA(obj);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/length-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/length-throws.js
new file mode 100644
index 0000000000..2c670d66d4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/length-throws.js
@@ -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-object
+description: >
+ Return abrupt from getting length property on the object argument
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 5. Let len be ? ToLength(? Get(arrayLike, "length")).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var obj = {};
+
+Object.defineProperty(obj, "length", {
+ get() {
+ throw new Test262Error();
+ }
+});
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ assert.throws(Test262Error, function() {
+ new TA(obj);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/new-instance-extensibility.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/new-instance-extensibility.js
new file mode 100644
index 0000000000..8bec71adf4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/new-instance-extensibility.js
@@ -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-object
+description: >
+ The new typedArray instance from an object argument is extensible
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ ...
+ 4. Let O be ? AllocateTypedArray(constructorName, NewTarget,
+ "%TypedArrayPrototype%").
+ ...
+
+ 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget,
+ defaultProto [ , length ])
+
+ ...
+ 2. Let obj be IntegerIndexedObjectCreate(proto, « [[ViewedArrayBuffer]],
+ [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]] »).
+ ...
+
+ 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList)
+
+ ...
+ 11. Set the [[Extensible]] internal slot of A to true.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var obj = {
+ "0": 0n,
+ "1": 1n,
+ "2": 2n,
+ length: 3
+ };
+
+ var sample = new TA(obj);
+
+ assert(Object.isExtensible(sample));
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/null-tobigint.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/null-tobigint.js
new file mode 100644
index 0000000000..78a81a68fd
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/null-tobigint.js
@@ -0,0 +1,65 @@
+// Copyright (C) 2018 Valerie Young. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-object
+description: >
+ Return abrupt on null
+info: |
+ TypedArray ( object )
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+ ...
+ 8. Repeat, while k < len
+ ...
+ b. Let kValue be ? Get(arrayLike, Pk).
+ c. Perform ? Set(O, Pk, kValue, true).
+ ...
+
+ [[Set]] ( P, V, Receiver)
+ ...
+ 2. If Type(P) is String and if SameValue(O, Receiver) is true, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ i. Perform ? IntegerIndexedElementSet(O, numericIndex, V).
+ ii. Return true.
+ ...
+
+ IntegerIndexedElementSet ( O, index, value )
+
+ Assert: O is an Integer-Indexed exotic object.
+ If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value).
+ Otherwise, let numValue be ? ToNumber(value).
+ Let buffer be O.[[ViewedArrayBuffer]].
+ If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then
+ Let offset be O.[[ByteOffset]].
+ Let arrayTypeName be the String value of O.[[TypedArrayName]].
+ Let elementSize be the Element Size value specified in Table 62 for arrayTypeName.
+ Let indexedPosition be (ℝ(index) × elementSize) + offset.
+ Let elementType be the Element Type value in Table 62 for arrayTypeName.
+ Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue, true, Unordered).
+ Return NormalCompletion(undefined).
+
+ ToBigInt ( argument )
+ Object, Apply the following steps:
+ 1. Let prim be ? ToPrimitive(argument, hint Number).
+ 2. Return the value that prim corresponds to in Table [BigInt Conversions]
+
+ BigInt Conversions
+ Argument Type: Null
+ Result: Throw a TypeError exception.
+
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+
+ assert.throws(TypeError, function() {
+ new TA([null]);
+ }, "abrupt completion from Null");
+
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/number-tobigint.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/number-tobigint.js
new file mode 100644
index 0000000000..caedd3ca5d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/number-tobigint.js
@@ -0,0 +1,93 @@
+// Copyright (C) 2018 Valerie Young. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-object
+description: >
+ Return abrupt on Number
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ b. Let kValue be ? Get(arrayLike, Pk).
+ c. Perform ? Set(O, Pk, kValue, true).
+ ...
+
+ 9.4.5.5 [[Set]] ( P, V, Receiver)
+
+ ...
+ 2. If Type(P) is String and if SameValue(O, Receiver) is true, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ i. Perform ? IntegerIndexedElementSet(O, numericIndex, V).
+ ii. Return true.
+ ...
+
+ IntegerIndexedElementSet ( O, index, value )
+
+ Assert: O is an Integer-Indexed exotic object.
+ If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value).
+ Otherwise, let numValue be ? ToNumber(value).
+ Let buffer be O.[[ViewedArrayBuffer]].
+ If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then
+ Let offset be O.[[ByteOffset]].
+ Let arrayTypeName be the String value of O.[[TypedArrayName]].
+ Let elementSize be the Element Size value specified in Table 62 for arrayTypeName.
+ Let indexedPosition be (ℝ(index) × elementSize) + offset.
+ Let elementType be the Element Type value in Table 62 for arrayTypeName.
+ Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue, true, Unordered).
+ Return NormalCompletion(undefined).
+
+ ToBigInt ( argument )
+
+ Object, Apply the following steps:
+ 1. Let prim be ? ToPrimitive(argument, hint Number).
+ 2. Return the value that prim corresponds to in Table [BigInt Conversions]
+
+ BigInt Conversions
+ Argument Type: Number
+ Result: Throw a TypeError exception.
+
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+
+ assert.throws(TypeError, function() {
+ new TA([1]);
+ }, "abrupt completion from Number: 1");
+
+ assert.throws(TypeError, function() {
+ new TA([Math.pow(2, 63)]);
+ }, "abrupt completion from Number: 2**63");
+
+ assert.throws(TypeError, function() {
+ new TA([+0]);
+ }, "abrupt completion from Number: +0");
+
+ assert.throws(TypeError, function() {
+ new TA([-0]);
+ }, "abrupt completion from Number: -0");
+
+ assert.throws(TypeError, function() {
+ new TA([Infinity]);
+ }, "abrupt completion from Number: Infinity");
+
+ assert.throws(TypeError, function() {
+ new TA([-Infinity]);
+ }, "abrupt completion from Number: -Infinity");
+
+ assert.throws(TypeError, function() {
+ new TA([NaN]);
+ }, "abrupt completion from Number: NaN");
+
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/proto-from-ctor-realm.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/proto-from-ctor-realm.js
new file mode 100644
index 0000000000..36c1419438
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/proto-from-ctor-realm.js
@@ -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-object
+description: Default [[Prototype]] value derived from realm of the newTarget
+info: |
+ [...]
+ 4. Let O be ? AllocateTypedArray(constructorName, NewTarget,
+ "%TypedArrayPrototype%").
+ [...]
+
+ 22.2.4.2.1 Runtime Semantics: AllocateTypedArray
+
+ 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto).
+ [...]
+
+ 9.1.14 GetPrototypeFromConstructor
+
+ [...]
+ 3. Let proto be ? Get(constructor, "prototype").
+ 4. If Type(proto) is not Object, then
+ a. Let realm be ? GetFunctionRealm(constructor).
+ b. Let proto be realm's intrinsic object named intrinsicDefaultProto.
+ 5. Return proto.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, cross-realm, Reflect, TypedArray]
+---*/
+
+var other = $262.createRealm().global;
+var C = new other.Function();
+C.prototype = null;
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var ta = Reflect.construct(TA, [{}], C);
+
+ assert.sameValue(Object.getPrototypeOf(ta), other[TA.name].prototype);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/shell.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/shell.js
new file mode 100644
index 0000000000..90ee9c114d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/shell.js
@@ -0,0 +1,42 @@
+// GENERATED, DO NOT EDIT
+// file: testBigIntTypedArray.js
+// 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.
+defines:
+ - TypedArray
+ - testWithBigIntTypedArrayConstructors
+---*/
+
+/**
+ * The %TypedArray% intrinsic constructor function.
+ */
+var TypedArray = Object.getPrototypeOf(Int8Array);
+
+/**
+ * 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) {
+ /**
+ * Array containing every BigInt typed array constructor.
+ */
+ var constructors = selected || [
+ BigInt64Array,
+ BigUint64Array
+ ];
+
+ 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;
+ }
+ }
+}
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/string-nan-tobigint.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/string-nan-tobigint.js
new file mode 100644
index 0000000000..f117b1c110
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/string-nan-tobigint.js
@@ -0,0 +1,72 @@
+// Copyright (C) 2018 Valerie Young. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-object
+description: >
+ Return abrupt String, when StringToBigInt returns NaN
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ b. Let kValue be ? Get(arrayLike, Pk).
+ c. Perform ? Set(O, Pk, kValue, true).
+ ...
+
+ 9.4.5.5 [[Set]] ( P, V, Receiver)
+
+ ...
+ 2. If Type(P) is String and if SameValue(O, Receiver) is true, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ i. Perform ? IntegerIndexedElementSet(O, numericIndex, V).
+ ii. Return true.
+ ...
+
+ IntegerIndexedElementSet ( O, index, value )
+
+ Assert: O is an Integer-Indexed exotic object.
+ If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value).
+ Otherwise, let numValue be ? ToNumber(value).
+ Let buffer be O.[[ViewedArrayBuffer]].
+ If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then
+ Let offset be O.[[ByteOffset]].
+ Let arrayTypeName be the String value of O.[[TypedArrayName]].
+ Let elementSize be the Element Size value specified in Table 62 for arrayTypeName.
+ Let indexedPosition be (ℝ(index) × elementSize) + offset.
+ Let elementType be the Element Type value in Table 62 for arrayTypeName.
+ Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue, true, Unordered).
+ Return NormalCompletion(undefined).
+
+ ToBigInt ( argument )
+
+ Object, Apply the following steps:
+ 1. Let prim be ? ToPrimitive(argument, hint Number).
+ 2. Return the value that prim corresponds to in Table [BigInt Conversions]
+
+ BigInt Conversions
+ Argument Type: String
+ Result:
+ 1. Let n be StringToBigInt(prim).
+ 2. If n is NaN, throw a SyntaxError exception.
+ 3. Return n.
+
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+
+ assert.throws(SyntaxError, function() {
+ new TA(["definately not a number"]);
+ }, "StringToBigInt(prim) == NaN");
+
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/string-tobigint.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/string-tobigint.js
new file mode 100644
index 0000000000..631f126299
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/string-tobigint.js
@@ -0,0 +1,88 @@
+// Copyright (C) 2018 Valerie Young. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-object
+description: >
+ Behavior for input array of Strings, successful conversion
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ b. Let kValue be ? Get(arrayLike, Pk).
+ c. Perform ? Set(O, Pk, kValue, true).
+ ...
+
+ 9.4.5.5 [[Set]] ( P, V, Receiver)
+
+ ...
+ 2. If Type(P) is String and if SameValue(O, Receiver) is true, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ i. Perform ? IntegerIndexedElementSet(O, numericIndex, V).
+ ii. Return true.
+ ...
+
+ IntegerIndexedElementSet ( O, index, value )
+
+ Assert: O is an Integer-Indexed exotic object.
+ If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value).
+ Otherwise, let numValue be ? ToNumber(value).
+ Let buffer be O.[[ViewedArrayBuffer]].
+ If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then
+ Let offset be O.[[ByteOffset]].
+ Let arrayTypeName be the String value of O.[[TypedArrayName]].
+ Let elementSize be the Element Size value specified in Table 62 for arrayTypeName.
+ Let indexedPosition be (ℝ(index) × elementSize) + offset.
+ Let elementType be the Element Type value in Table 62 for arrayTypeName.
+ Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue, true, Unordered).
+ Return NormalCompletion(undefined).
+
+ ToBigInt ( argument )
+
+ Object, Apply the following steps:
+ 1. Let prim be ? ToPrimitive(argument, hint Number).
+ 2. Return the value that prim corresponds to in Table [BigInt Conversions]
+
+ BigInt Conversions
+ Argument Type: String
+ Result:
+ 1. Let n be StringToBigInt(prim).
+ 2. If n is NaN, throw a SyntaxError exception.
+ 3. Return n.
+
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var typedArray = new TA(['', '1']);
+
+ assert.sameValue(typedArray[0], 0n);
+ assert.sameValue(typedArray[1], 1n);
+
+ assert.throws(SyntaxError, function() {
+ new TA(["1n"]);
+ }, "A StringNumericLiteral may not include a BigIntLiteralSuffix.");
+
+ assert.throws(SyntaxError, function() {
+ new TA(["Infinity"]);
+ }, "Replace the StrUnsignedDecimalLiteral production with DecimalDigits to not allow Infinity..");
+
+ assert.throws(SyntaxError, function() {
+ new TA(["1.1"]);
+ }, "Replace the StrUnsignedDecimalLiteral production with DecimalDigits to not allow... decimal points...");
+
+ assert.throws(SyntaxError, function() {
+ new TA(["1e7"]);
+ }, "Replace the StrUnsignedDecimalLiteral production with DecimalDigits to not allow... exponents...");
+
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/symbol-tobigint.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/symbol-tobigint.js
new file mode 100644
index 0000000000..4315e69e0d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/symbol-tobigint.js
@@ -0,0 +1,71 @@
+// Copyright (C) 2018 Valerie Young. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-object
+description: >
+ Return abrupt on Symbol
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ b. Let kValue be ? Get(arrayLike, Pk).
+ c. Perform ? Set(O, Pk, kValue, true).
+ ...
+
+ 9.4.5.5 [[Set]] ( P, V, Receiver)
+
+ ...
+ 2. If Type(P) is String and if SameValue(O, Receiver) is true, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ i. Perform ? IntegerIndexedElementSet(O, numericIndex, V).
+ ii. Return true.
+ ...
+
+ IntegerIndexedElementSet ( O, index, value )
+
+ Assert: O is an Integer-Indexed exotic object.
+ If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value).
+ Otherwise, let numValue be ? ToNumber(value).
+ Let buffer be O.[[ViewedArrayBuffer]].
+ If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then
+ Let offset be O.[[ByteOffset]].
+ Let arrayTypeName be the String value of O.[[TypedArrayName]].
+ Let elementSize be the Element Size value specified in Table 62 for arrayTypeName.
+ Let indexedPosition be (ℝ(index) × elementSize) + offset.
+ Let elementType be the Element Type value in Table 62 for arrayTypeName.
+ Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue, true, Unordered).
+ Return NormalCompletion(undefined).
+
+ ToBigInt ( argument )
+
+ Object, Apply the following steps:
+ 1. Let prim be ? ToPrimitive(argument, hint Number).
+ 2. Return the value that prim corresponds to in Table [BigInt Conversions]
+
+ BigInt Conversions
+ Argument Type: Symbol
+ Result: Throw a TypeError exception.
+
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray, Symbol]
+---*/
+
+var s = Symbol()
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+
+ assert.throws(TypeError, function() {
+ new TA([s]);
+ }, "abrupt completion from Symbol");
+
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/throws-from-property.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/throws-from-property.js
new file mode 100644
index 0000000000..3b6564b2f5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/throws-from-property.js
@@ -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-object
+description: >
+ Return abrupt from getting object property
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ b. Let kValue be ? Get(arrayLike, Pk).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var obj = {
+ length: 4
+};
+
+Object.defineProperty(obj, "2", {
+ get() {
+ throw new Test262Error();
+ }
+});
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ obj[0] = 0n;
+ obj[1] = 0n;
+ assert.throws(Test262Error, function() {
+ new TA(obj);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/throws-setting-obj-to-primitive-typeerror.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/throws-setting-obj-to-primitive-typeerror.js
new file mode 100644
index 0000000000..a2b1f6c1f7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/throws-setting-obj-to-primitive-typeerror.js
@@ -0,0 +1,88 @@
+// 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-object
+description: >
+ Throw TypeError from @@toPrimitive returning an Object when setting a property
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ b. Let kValue be ? Get(arrayLike, Pk).
+ c. Perform ? Set(O, Pk, kValue, true).
+ ...
+
+ 9.4.5.5 [[Set]] ( P, V, Receiver)
+
+ ...
+ 2. If Type(P) is String and if SameValue(O, Receiver) is true, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ i. Perform ? IntegerIndexedElementSet(O, numericIndex, V).
+ ii. Return true.
+ ...
+
+ IntegerIndexedElementSet ( O, index, value )
+
+ Assert: O is an Integer-Indexed exotic object.
+ If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value).
+ Otherwise, let numValue be ? ToNumber(value).
+ Let buffer be O.[[ViewedArrayBuffer]].
+ If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then
+ Let offset be O.[[ByteOffset]].
+ Let arrayTypeName be the String value of O.[[TypedArrayName]].
+ Let elementSize be the Element Size value specified in Table 62 for arrayTypeName.
+ Let indexedPosition be (ℝ(index) × elementSize) + offset.
+ Let elementType be the Element Type value in Table 62 for arrayTypeName.
+ Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue, true, Unordered).
+ Return NormalCompletion(undefined).
+
+ ToBigInt ( argument )
+
+ Object, Apply the following steps:
+ 1. Let prim be ? ToPrimitive(argument, hint Number).
+ 2. Return the value that prim corresponds to in Table 10.
+
+ 7.1.1 ToPrimitive ( input [ , PreferredType ] )
+
+ ...
+ 4. Let exoticToPrim be ? GetMethod(input, @@toPrimitive).
+ 5. If exoticToPrim is not undefined, then
+ a. Let result be ? Call(exoticToPrim, input, « hint »).
+ b. If Type(result) is not Object, return result.
+ c. Throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.toPrimitive, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new Int8Array(1);
+ var toPrimitive = 0;
+ var valueOf = 0;
+
+ sample[Symbol.toPrimitive] = function() {
+ toPrimitive++;
+ return {};
+ };
+
+ sample.valueOf = function() {
+ valueOf++;
+ };
+
+ assert.throws(TypeError, function() {
+ new TA([8n, sample]);
+ }, "abrupt completion from sample @@toPrimitive");
+
+ assert.sameValue(toPrimitive, 1, "toPrimitive was called once");
+ assert.sameValue(valueOf, 0, "sample.valueOf is not called");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/throws-setting-obj-to-primitive.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/throws-setting-obj-to-primitive.js
new file mode 100644
index 0000000000..1a6627e153
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/throws-setting-obj-to-primitive.js
@@ -0,0 +1,86 @@
+// 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-object
+description: >
+ Return abrupt from @@toPrimitive when setting a property
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ b. Let kValue be ? Get(arrayLike, Pk).
+ c. Perform ? Set(O, Pk, kValue, true).
+ ...
+
+ 9.4.5.5 [[Set]] ( P, V, Receiver)
+
+ ...
+ 2. If Type(P) is String and if SameValue(O, Receiver) is true, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ i. Perform ? IntegerIndexedElementSet(O, numericIndex, V).
+ ii. Return true.
+ ...
+
+ IntegerIndexedElementSet ( O, index, value )
+
+ Assert: O is an Integer-Indexed exotic object.
+ If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value).
+ Otherwise, let numValue be ? ToNumber(value).
+ Let buffer be O.[[ViewedArrayBuffer]].
+ If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then
+ Let offset be O.[[ByteOffset]].
+ Let arrayTypeName be the String value of O.[[TypedArrayName]].
+ Let elementSize be the Element Size value specified in Table 62 for arrayTypeName.
+ Let indexedPosition be (ℝ(index) × elementSize) + offset.
+ Let elementType be the Element Type value in Table 62 for arrayTypeName.
+ Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue, true, Unordered).
+ Return NormalCompletion(undefined).
+
+ ToBigInt ( argument )
+
+ Object, Apply the following steps:
+ 1. Let prim be ? ToPrimitive(argument, hint Number).
+ 2. Return the value that prim corresponds to in Table 10.
+
+ 7.1.1 ToPrimitive ( input [ , PreferredType ] )
+
+ ...
+ 4. Let exoticToPrim be ? GetMethod(input, @@toPrimitive).
+ 5. If exoticToPrim is not undefined, then
+ a. Let result be ? Call(exoticToPrim, input, « hint »).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.toPrimitive, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new Int8Array(1);
+ var toPrimitive = 0;
+ var valueOf = 0;
+
+ sample[Symbol.toPrimitive] = function() {
+ toPrimitive++;
+ throw new Test262Error();
+ };
+
+ sample.valueOf = function() {
+ valueOf++;
+ };
+
+ assert.throws(Test262Error, function() {
+ new TA([8n, sample]);
+ }, "abrupt completion from sample @@toPrimitive");
+
+ assert.sameValue(toPrimitive, 1, "toPrimitive was called once");
+ assert.sameValue(valueOf, 0, "it does not call sample.valueOf");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/throws-setting-obj-tostring.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/throws-setting-obj-tostring.js
new file mode 100644
index 0000000000..dee658572f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/throws-setting-obj-tostring.js
@@ -0,0 +1,99 @@
+// 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-object
+description: >
+ Return abrupt from toString() when setting a property
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ b. Let kValue be ? Get(arrayLike, Pk).
+ c. Perform ? Set(O, Pk, kValue, true).
+ ...
+
+ 9.4.5.5 [[Set]] ( P, V, Receiver)
+
+ ...
+ 2. If Type(P) is String and if SameValue(O, Receiver) is true, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ i. Perform ? IntegerIndexedElementSet(O, numericIndex, V).
+ ii. Return true.
+ ...
+
+ IntegerIndexedElementSet ( O, index, value )
+
+ Assert: O is an Integer-Indexed exotic object.
+ If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value).
+ Otherwise, let numValue be ? ToNumber(value).
+ Let buffer be O.[[ViewedArrayBuffer]].
+ If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then
+ Let offset be O.[[ByteOffset]].
+ Let arrayTypeName be the String value of O.[[TypedArrayName]].
+ Let elementSize be the Element Size value specified in Table 62 for arrayTypeName.
+ Let indexedPosition be (ℝ(index) × elementSize) + offset.
+ Let elementType be the Element Type value in Table 62 for arrayTypeName.
+ Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue, true, Unordered).
+ Return NormalCompletion(undefined).
+
+ ToBigInt ( argument )
+
+ Object, Apply the following steps:
+ 1. Let prim be ? ToPrimitive(argument, hint Number).
+ 2. Return the value that prim corresponds to in Table 10.
+
+ 7.1.1 ToPrimitive ( input [ , PreferredType ] )
+
+ ...
+ 4. Let exoticToPrim be ? GetMethod(input, @@toPrimitive).
+ 5. If exoticToPrim is not undefined, then
+ a. Let result be ? Call(exoticToPrim, input, « hint »).
+ b. If Type(result) is not Object, return result.
+ c. Throw a TypeError exception.
+ ...
+ 7. Return ? OrdinaryToPrimitive(input, hint).
+
+ OrdinaryToPrimitive
+
+ ...
+ 5. For each name in methodNames in List order, do
+ a. Let method be ? Get(O, name).
+ b. If IsCallable(method) is true, then
+ i. Let result be ? Call(method, O).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new Int8Array(1);
+ var valueOf = 0;
+ var toString = 0;
+
+ sample.valueOf = function() {
+ valueOf++;
+ return {};
+ };
+
+ sample.toString = function() {
+ toString++;
+ throw new Test262Error();
+ };
+
+ assert.throws(Test262Error, function() {
+ new TA([8n, sample]);
+ }, "abrupt completion from ToBigInt(sample)");
+
+ assert.sameValue(valueOf, 1, "valueOf called once");
+ assert.sameValue(toString, 1, "toString called once");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/throws-setting-obj-valueof-typeerror.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/throws-setting-obj-valueof-typeerror.js
new file mode 100644
index 0000000000..b0bae2c1bb
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/throws-setting-obj-valueof-typeerror.js
@@ -0,0 +1,100 @@
+// 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-object
+description: >
+ Throw TypeError from OrdinaryToPrimitive when setting a property
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ b. Let kValue be ? Get(arrayLike, Pk).
+ c. Perform ? Set(O, Pk, kValue, true).
+ ...
+
+ 9.4.5.5 [[Set]] ( P, V, Receiver)
+
+ ...
+ 2. If Type(P) is String and if SameValue(O, Receiver) is true, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ i. Perform ? IntegerIndexedElementSet(O, numericIndex, V).
+ ii. Return true.
+ ...
+
+ IntegerIndexedElementSet ( O, index, value )
+
+ Assert: O is an Integer-Indexed exotic object.
+ If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value).
+ Otherwise, let numValue be ? ToNumber(value).
+ Let buffer be O.[[ViewedArrayBuffer]].
+ If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then
+ Let offset be O.[[ByteOffset]].
+ Let arrayTypeName be the String value of O.[[TypedArrayName]].
+ Let elementSize be the Element Size value specified in Table 62 for arrayTypeName.
+ Let indexedPosition be (ℝ(index) × elementSize) + offset.
+ Let elementType be the Element Type value in Table 62 for arrayTypeName.
+ Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue, true, Unordered).
+ Return NormalCompletion(undefined).
+
+ ToBigInt ( argument )
+
+ Object, Apply the following steps:
+ 1. Let prim be ? ToPrimitive(argument, hint Number).
+ 2. Return the value that prim corresponds to in Table 10.
+
+ 7.1.1 ToPrimitive ( input [ , PreferredType ] )
+
+ ...
+ 4. Let exoticToPrim be ? GetMethod(input, @@toPrimitive).
+ 5. If exoticToPrim is not undefined, then
+ a. Let result be ? Call(exoticToPrim, input, « hint »).
+ b. If Type(result) is not Object, return result.
+ c. Throw a TypeError exception.
+ ...
+ 7. Return ? OrdinaryToPrimitive(input, hint).
+
+ OrdinaryToPrimitive
+
+ ...
+ 5. For each name in methodNames in List order, do
+ a. Let method be ? Get(O, name).
+ b. If IsCallable(method) is true, then
+ i. Let result be ? Call(method, O).
+ ii. If Type(result) is not Object, return result.
+ 6. Throw a TypeError exception.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new Int8Array(1);
+ var valueOf = 0;
+ var toString = 0;
+
+ sample.valueOf = function() {
+ valueOf++;
+ return {};
+ };
+
+ sample.toString = function() {
+ toString++;
+ return {};
+ };
+
+ assert.throws(TypeError, function() {
+ new TA([8n, sample]);
+ }, "abrupt completion from ToBigInt(sample)");
+
+ assert.sameValue(valueOf, 1, "valueOf called once");
+ assert.sameValue(toString, 1, "toString called once");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/throws-setting-obj-valueof.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/throws-setting-obj-valueof.js
new file mode 100644
index 0000000000..b2eaa9904d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/throws-setting-obj-valueof.js
@@ -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-object
+description: >
+ Return abrupt from valueOf() when setting a property
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ b. Let kValue be ? Get(arrayLike, Pk).
+ c. Perform ? Set(O, Pk, kValue, true).
+ ...
+
+ 9.4.5.5 [[Set]] ( P, V, Receiver)
+
+ ...
+ 2. If Type(P) is String and if SameValue(O, Receiver) is true, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ i. Perform ? IntegerIndexedElementSet(O, numericIndex, V).
+ ii. Return true.
+ ...
+
+ IntegerIndexedElementSet ( O, index, value )
+
+ Assert: O is an Integer-Indexed exotic object.
+ If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value).
+ Otherwise, let numValue be ? ToNumber(value).
+ Let buffer be O.[[ViewedArrayBuffer]].
+ If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then
+ Let offset be O.[[ByteOffset]].
+ Let arrayTypeName be the String value of O.[[TypedArrayName]].
+ Let elementSize be the Element Size value specified in Table 62 for arrayTypeName.
+ Let indexedPosition be (ℝ(index) × elementSize) + offset.
+ Let elementType be the Element Type value in Table 62 for arrayTypeName.
+ Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue, true, Unordered).
+ Return NormalCompletion(undefined).
+
+ ToBigInt ( argument )
+
+ Object, Apply the following steps:
+ 1. Let prim be ? ToPrimitive(argument, hint Number).
+ 2. Return the value that prim corresponds to in Table 10.
+
+ 7.1.1 ToPrimitive ( input [ , PreferredType ] )
+
+ ...
+ 4. Let exoticToPrim be ? GetMethod(input, @@toPrimitive).
+ 5. If exoticToPrim is not undefined, then
+ a. Let result be ? Call(exoticToPrim, input, « hint »).
+ b. If Type(result) is not Object, return result.
+ c. Throw a TypeError exception.
+ ...
+ 7. Return ? OrdinaryToPrimitive(input, hint).
+
+ OrdinaryToPrimitive
+
+ ...
+ 5. For each name in methodNames in List order, do
+ a. Let method be ? Get(O, name).
+ b. If IsCallable(method) is true, then
+ i. Let result be ? Call(method, O).
+ ii. If Type(result) is not Object, return result.
+ 6. Throw a TypeError exception.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new Int8Array(1);
+ var valueOf = 0;
+
+ sample.valueOf = function() {
+ valueOf++;
+ throw new Test262Error();
+ };
+
+ assert.throws(Test262Error, function() {
+ new TA([8n, sample]);
+ }, "abrupt completion from ToBigInt(sample)");
+
+ assert.sameValue(valueOf, 1, "valueOf called once");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/throws-setting-property.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/throws-setting-property.js
new file mode 100644
index 0000000000..e56a95c7f5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/throws-setting-property.js
@@ -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-object
+description: >
+ Return abrupt from setting property
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ b. Let kValue be ? Get(arrayLike, Pk).
+ c. Perform ? Set(O, Pk, kValue, true).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var obj = {
+ "2": {
+ valueOf() {
+ throw new Test262Error();
+ }
+ },
+ length: 4
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ obj[0] = 0n;
+ obj[1] = 0n;
+ assert.throws(Test262Error, function() {
+ new TA(obj);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/throws-setting-symbol-property.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/throws-setting-symbol-property.js
new file mode 100644
index 0000000000..7094f1b416
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/throws-setting-symbol-property.js
@@ -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-object
+description: >
+ Return abrupt from setting property
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ b. Let kValue be ? Get(arrayLike, Pk).
+ c. Perform ? Set(O, Pk, kValue, true).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+var obj = {
+ "2": Symbol("1"),
+ length: 4
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ assert.throws(TypeError, function() {
+ new TA(obj);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/undefined-newtarget-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/undefined-newtarget-throws.js
new file mode 100644
index 0000000000..9e8d92fb0f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/undefined-newtarget-throws.js
@@ -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-object
+description: >
+ Throws a TypeError if NewTarget is undefined.
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 2. If NewTarget is undefined, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ assert.throws(TypeError, function() {
+ TA({});
+ });
+
+ assert.throws(TypeError, function() {
+ TA([]);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/undefined-tobigint.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/undefined-tobigint.js
new file mode 100644
index 0000000000..5ae317141e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/undefined-tobigint.js
@@ -0,0 +1,65 @@
+// Copyright (C) 2018 Valerie Young. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-object
+description: >
+ Return abrupt on undefined
+info: |
+ TypedArray ( object )
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+ ...
+ 8. Repeat, while k < len
+ ...
+ b. Let kValue be ? Get(arrayLike, Pk).
+ c. Perform ? Set(O, Pk, kValue, true).
+ ...
+
+ [[Set]] ( P, V, Receiver)
+ ...
+ 2. If Type(P) is String and if SameValue(O, Receiver) is true, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ i. Perform ? IntegerIndexedElementSet(O, numericIndex, V).
+ ii. Return true.
+ ...
+
+ IntegerIndexedElementSet ( O, index, value )
+
+ Assert: O is an Integer-Indexed exotic object.
+ If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value).
+ Otherwise, let numValue be ? ToNumber(value).
+ Let buffer be O.[[ViewedArrayBuffer]].
+ If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then
+ Let offset be O.[[ByteOffset]].
+ Let arrayTypeName be the String value of O.[[TypedArrayName]].
+ Let elementSize be the Element Size value specified in Table 62 for arrayTypeName.
+ Let indexedPosition be (ℝ(index) × elementSize) + offset.
+ Let elementType be the Element Type value in Table 62 for arrayTypeName.
+ Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue, true, Unordered).
+ Return NormalCompletion(undefined).
+
+ ToBigInt ( argument )
+ Object, Apply the following steps:
+ 1. Let prim be ? ToPrimitive(argument, hint Number).
+ 2. Return the value that prim corresponds to in Table [BigInt Conversions]
+
+ BigInt Conversions
+ Argument Type: Undefined
+ Result: Throw a TypeError exception.
+
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+
+ assert.throws(TypeError, function() {
+ new TA([undefined]);
+ }, "abrupt completion from undefined");
+
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/use-custom-proto-if-object.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/use-custom-proto-if-object.js
new file mode 100644
index 0000000000..ee60d97474
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/use-custom-proto-if-object.js
@@ -0,0 +1,49 @@
+// 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-object
+description: >
+ Use prototype from new target if it's an Object
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 3. Let O be ? AllocateTypedArray(TypedArray.[[TypedArrayConstructorName]],
+ NewTarget, "%TypedArrayPrototype%").
+ ...
+
+ 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget,
+ defaultProto [ , length ])
+
+ 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto).
+ 2. Let obj be IntegerIndexedObjectCreate (proto, «[[ViewedArrayBuffer]],
+ [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]]» ).
+ ...
+
+ 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList)
+
+ ...
+ 10. Set the [[Prototype]] internal slot of A to prototype.
+ ...
+ 12. Return A.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Reflect, TypedArray]
+---*/
+
+function newTarget() {}
+var proto = {};
+newTarget.prototype = proto;
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var ta = Reflect.construct(TA, [], newTarget);
+
+ assert.sameValue(ta.constructor, Object);
+ assert.sameValue(Object.getPrototypeOf(ta), proto);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/use-default-proto-if-custom-proto-is-not-object.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/use-default-proto-if-custom-proto-is-not-object.js
new file mode 100644
index 0000000000..4855ab6159
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/ctors-bigint/object-arg/use-default-proto-if-custom-proto-is-not-object.js
@@ -0,0 +1,49 @@
+// 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-object
+description: >
+ Use prototype from %TypedArray% if newTarget's prototype is not an Object
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 3. Let O be ? AllocateTypedArray(TypedArray.[[TypedArrayConstructorName]],
+ NewTarget, "%TypedArrayPrototype%").
+ ...
+
+ 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget,
+ defaultProto [ , length ])
+
+ 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto).
+ 2. Let obj be IntegerIndexedObjectCreate (proto, «[[ViewedArrayBuffer]],
+ [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]]» ).
+ ...
+
+ 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList)
+
+ ...
+ 10. Set the [[Prototype]] internal slot of A to prototype.
+ ...
+ 12. Return A.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+function newTarget() {}
+newTarget.prototype = null;
+var o = [];
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var ta = Reflect.construct(TA, [o], newTarget);
+
+ assert.sameValue(ta.constructor, TA);
+ assert.sameValue(Object.getPrototypeOf(ta), TA.prototype);
+});
+
+reportCompare(0, 0);