summaryrefslogtreecommitdiff
path: root/test/built-ins/TypedArrays/ctors-bigint/buffer-arg
diff options
context:
space:
mode:
Diffstat (limited to 'test/built-ins/TypedArrays/ctors-bigint/buffer-arg')
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/bufferbyteoffset-throws-from-modulo-element-size-sab.js38
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/bufferbyteoffset-throws-from-modulo-element-size.js37
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/byteoffset-is-negative-throws-sab.js32
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/byteoffset-is-negative-throws.js31
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/byteoffset-is-negative-zero-sab.js23
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/byteoffset-is-negative-zero.js23
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/byteoffset-is-symbol-throws-sab.js29
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/byteoffset-is-symbol-throws.js28
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/byteoffset-throws-from-modulo-element-size-sab.js33
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/byteoffset-throws-from-modulo-element-size.js32
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/byteoffset-to-number-detachbuffer.js21
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/byteoffset-to-number-throws-sab.js33
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/byteoffset-to-number-throws.js32
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/custom-proto-access-throws-sab.js48
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/custom-proto-access-throws.js47
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/defined-length-and-offset-sab.js33
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/defined-length-and-offset.js32
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/defined-length-sab.js35
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/defined-length.js34
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/defined-negative-length-sab.js29
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/defined-negative-length.js28
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/defined-offset-sab.js33
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/defined-offset.js32
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/detachedbuffer.js21
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/excessive-length-throws-sab.js32
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/excessive-length-throws.js31
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/excessive-offset-throws-sab.js36
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/excessive-offset-throws.js35
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/invoked-with-undefined-newtarget-sab.js27
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/invoked-with-undefined-newtarget.js26
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/is-referenced-sab.js33
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/is-referenced.js32
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/length-access-throws-sab.js34
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/length-access-throws.js33
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/length-is-symbol-throws-sab.js30
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/length-is-symbol-throws.js29
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/length-to-number-detachbuffer.js21
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/new-instance-extensibility-sab.js38
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/new-instance-extensibility.js37
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/proto-from-ctor-realm-sab.js38
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/proto-from-ctor-realm.js37
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/returns-new-instance-sab.js34
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/returns-new-instance.js33
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/toindex-bytelength-sab.js73
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/toindex-bytelength.js72
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/toindex-byteoffset-sab.js87
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/toindex-byteoffset.js86
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/typedarray-backed-by-sharedarraybuffer.js23
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/use-custom-proto-if-object-sab.js49
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/use-custom-proto-if-object.js48
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/use-default-proto-if-custom-proto-is-not-object-sab.js48
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/buffer-arg/use-default-proto-if-custom-proto-is-not-object.js47
52 files changed, 1913 insertions, 0 deletions
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/bufferbyteoffset-throws-from-modulo-element-size-sab.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/bufferbyteoffset-throws-from-modulo-element-size-sab.js
new file mode 100644
index 000000000..2f86cd9c2
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/bufferbyteoffset-throws-from-modulo-element-size-sab.js
@@ -0,0 +1,38 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-buffer-byteoffset-length
+description: >
+ Throws a RangeError if bufferByteLength modulo elementSize ≠ 0
+info: |
+ 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
+
+ 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 has an [[ArrayBufferData]] internal slot.
+
+ ...
+ 13. If length is undefined, then
+ a. If bufferByteLength modulo elementSize ≠ 0, throw a RangeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, SharedArrayBuffer, TypedArray]
+---*/
+
+var buffer = new SharedArrayBuffer(1);
+
+testWithTypedArrayConstructors(function(TA) {
+ if (TA.BYTES_PER_ELEMENT === 1) {
+ // Impossible to trigger this step here.
+ return;
+ }
+
+ assert.throws(RangeError, function() {
+ new TA(buffer);
+ });
+
+ assert.throws(RangeError, function() {
+ new TA(buffer, 0, undefined);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/bufferbyteoffset-throws-from-modulo-element-size.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/bufferbyteoffset-throws-from-modulo-element-size.js
new file mode 100644
index 000000000..67f3f8871
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/bufferbyteoffset-throws-from-modulo-element-size.js
@@ -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-buffer-byteoffset-length
+description: >
+ Throws a RangeError if bufferByteLength modulo elementSize ≠ 0
+info: |
+ 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
+
+ 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 has an [[ArrayBufferData]] internal slot.
+
+ ...
+ 13. If length is undefined, then
+ a. If bufferByteLength modulo elementSize ≠ 0, throw a RangeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var buffer = new ArrayBuffer(1);
+
+testWithTypedArrayConstructors(function(TA) {
+ if (TA.BYTES_PER_ELEMENT === 1) {
+ // Impossible to trigger this step here.
+ return;
+ }
+
+ assert.throws(RangeError, function() {
+ new TA(buffer);
+ });
+
+ assert.throws(RangeError, function() {
+ new TA(buffer, 0, undefined);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/byteoffset-is-negative-throws-sab.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/byteoffset-is-negative-throws-sab.js
new file mode 100644
index 000000000..9c590f859
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/byteoffset-is-negative-throws-sab.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-buffer-byteoffset-length
+description: >
+ Throws a RangeError if ToInteger(byteOffset) is < 0
+info: |
+ 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
+
+ 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 has an [[ArrayBufferData]] internal slot.
+
+ ...
+ 7. Let offset be ? ToInteger(byteOffset).
+ 8. If offset < 0, throw a RangeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, SharedArrayBuffer, TypedArray]
+---*/
+
+var buffer = new SharedArrayBuffer(8);
+
+testWithTypedArrayConstructors(function(TA) {
+ assert.throws(RangeError, function() {
+ new TA(buffer, -1);
+ });
+ assert.throws(RangeError, function() {
+ new TA(buffer, -Infinity);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/byteoffset-is-negative-throws.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/byteoffset-is-negative-throws.js
new file mode 100644
index 000000000..d0c70d669
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/byteoffset-is-negative-throws.js
@@ -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.
+/*---
+esid: sec-typedarray-buffer-byteoffset-length
+description: >
+ Throws a RangeError if ToInteger(byteOffset) is < 0
+info: |
+ 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
+
+ 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 has an [[ArrayBufferData]] internal slot.
+
+ ...
+ 7. Let offset be ? ToInteger(byteOffset).
+ 8. If offset < 0, throw a RangeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var buffer = new ArrayBuffer(8);
+
+testWithTypedArrayConstructors(function(TA) {
+ assert.throws(RangeError, function() {
+ new TA(buffer, -1);
+ });
+ assert.throws(RangeError, function() {
+ new TA(buffer, -Infinity);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/byteoffset-is-negative-zero-sab.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/byteoffset-is-negative-zero-sab.js
new file mode 100644
index 000000000..bfae5fa4c
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/byteoffset-is-negative-zero-sab.js
@@ -0,0 +1,23 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: pending
+description: >
+ TypedArray's [[ByteOffset]] internal slot is always a positive number, test with negative zero.
+info: |
+ %TypedArray% ( buffer [ , byteOffset [ , length ] ] )
+
+ ...
+ 6. Let offset be ? ToInteger(byteOffset).
+ 7. If offset < 0, throw a RangeError exception.
+ 8. If offset is -0, let offset be +0.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, SharedArrayBuffer, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TAConstructor) {
+ var typedArray = new TAConstructor(new SharedArrayBuffer(8), -0);
+ assert.sameValue(typedArray.byteOffset, +0);
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/byteoffset-is-negative-zero.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/byteoffset-is-negative-zero.js
new file mode 100644
index 000000000..14cca2584
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/byteoffset-is-negative-zero.js
@@ -0,0 +1,23 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: pending
+description: >
+ TypedArray's [[ByteOffset]] internal slot is always a positive number, test with negative zero.
+info: |
+ %TypedArray% ( buffer [ , byteOffset [ , length ] ] )
+
+ ...
+ 6. Let offset be ? ToInteger(byteOffset).
+ 7. If offset < 0, throw a RangeError exception.
+ 8. If offset is -0, let offset be +0.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TAConstructor) {
+ var typedArray = new TAConstructor(new ArrayBuffer(8), -0);
+ assert.sameValue(typedArray.byteOffset, +0);
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/byteoffset-is-symbol-throws-sab.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/byteoffset-is-symbol-throws-sab.js
new file mode 100644
index 000000000..cef10b698
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/byteoffset-is-symbol-throws-sab.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-buffer-byteoffset-length
+description: >
+ Return abrupt from parsing integer value from byteOffset as a symbol
+info: |
+ 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
+
+ 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 has an [[ArrayBufferData]] internal slot.
+
+ ...
+ 7. Let offset be ? ToInteger(byteOffset).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, SharedArrayBuffer, TypedArray]
+---*/
+
+var byteOffset = Symbol("1");
+var buffer = new SharedArrayBuffer(8);
+
+testWithTypedArrayConstructors(function(TA) {
+ assert.throws(TypeError, function() {
+ new TA(buffer, byteOffset);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/byteoffset-is-symbol-throws.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/byteoffset-is-symbol-throws.js
new file mode 100644
index 000000000..a3c12fd01
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/byteoffset-is-symbol-throws.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-buffer-byteoffset-length
+description: >
+ Return abrupt from parsing integer value from byteOffset as a symbol
+info: |
+ 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
+
+ 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 has an [[ArrayBufferData]] internal slot.
+
+ ...
+ 7. Let offset be ? ToInteger(byteOffset).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+var byteOffset = Symbol("1");
+var buffer = new ArrayBuffer(8);
+
+testWithTypedArrayConstructors(function(TA) {
+ assert.throws(TypeError, function() {
+ new TA(buffer, byteOffset);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/byteoffset-throws-from-modulo-element-size-sab.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/byteoffset-throws-from-modulo-element-size-sab.js
new file mode 100644
index 000000000..b70167e3b
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/byteoffset-throws-from-modulo-element-size-sab.js
@@ -0,0 +1,33 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-buffer-byteoffset-length
+description: >
+ Throws a RangeError if ToInteger(byteOffset) modulo elementSize is not 0
+info: |
+ 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
+
+ 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 has an [[ArrayBufferData]] internal slot.
+
+ ...
+ 10. If offset modulo elementSize ≠ 0, throw a RangeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, SharedArrayBuffer, TypedArray]
+---*/
+
+var buffer = new SharedArrayBuffer(8);
+
+testWithTypedArrayConstructors(function(TA) {
+ if (TA.BYTES_PER_ELEMENT === 1) {
+ // Impossible to trigger this step here.
+ return;
+ }
+
+ assert.throws(RangeError, function() {
+ new TA(buffer, 7);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/byteoffset-throws-from-modulo-element-size.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/byteoffset-throws-from-modulo-element-size.js
new file mode 100644
index 000000000..2a3a79303
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/byteoffset-throws-from-modulo-element-size.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-buffer-byteoffset-length
+description: >
+ Throws a RangeError if ToInteger(byteOffset) modulo elementSize is not 0
+info: |
+ 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
+
+ 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 has an [[ArrayBufferData]] internal slot.
+
+ ...
+ 10. If offset modulo elementSize ≠ 0, throw a RangeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var buffer = new ArrayBuffer(8);
+
+testWithTypedArrayConstructors(function(TA) {
+ if (TA.BYTES_PER_ELEMENT === 1) {
+ // Impossible to trigger this step here.
+ return;
+ }
+
+ assert.throws(RangeError, function() {
+ new TA(buffer, 7);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/byteoffset-to-number-detachbuffer.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/byteoffset-to-number-detachbuffer.js
new file mode 100644
index 000000000..89430e6ab
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/byteoffset-to-number-detachbuffer.js
@@ -0,0 +1,21 @@
+// 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-buffer-byteoffset-length
+description: If TypedArray() is passed a detached buffer, throw
+info: |
+ 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
+
+ ...
+ 9. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var offset = TA.BYTES_PER_ELEMENT;
+ var buffer = new ArrayBuffer(3 * offset);
+ var byteOffset = { valueOf() { $DETACHBUFFER(buffer); return offset; } };
+ assert.throws(TypeError, () => new TA(buffer, byteOffset));
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/byteoffset-to-number-throws-sab.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/byteoffset-to-number-throws-sab.js
new file mode 100644
index 000000000..a80143c26
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/byteoffset-to-number-throws-sab.js
@@ -0,0 +1,33 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-buffer-byteoffset-length
+description: >
+ Return abrupt from parsing integer value from byteOffset
+info: |
+ 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
+
+ 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 has an [[ArrayBufferData]] internal slot.
+
+ ...
+ 7. Let offset be ? ToInteger(byteOffset).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, SharedArrayBuffer, TypedArray]
+---*/
+
+var buffer = new SharedArrayBuffer(8);
+var byteOffset = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ assert.throws(Test262Error, function() {
+ new TA(buffer, byteOffset);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/byteoffset-to-number-throws.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/byteoffset-to-number-throws.js
new file mode 100644
index 000000000..f30cc2584
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/byteoffset-to-number-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-buffer-byteoffset-length
+description: >
+ Return abrupt from parsing integer value from byteOffset
+info: |
+ 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
+
+ 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 has an [[ArrayBufferData]] internal slot.
+
+ ...
+ 7. Let offset be ? ToInteger(byteOffset).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var buffer = new ArrayBuffer(8);
+var byteOffset = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ assert.throws(Test262Error, function() {
+ new TA(buffer, byteOffset);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/custom-proto-access-throws-sab.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/custom-proto-access-throws-sab.js
new file mode 100644
index 000000000..fbb038d25
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/custom-proto-access-throws-sab.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-buffer-byteoffset-length
+description: >
+ Return abrupt completion getting newTarget's prototype
+info: |
+ 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
+
+ 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 has an [[ArrayBufferData]] internal slot.
+
+ ...
+ 4. Let O be ? AllocateTypedArray(constructorName, 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, SharedArrayBuffer, TypedArray]
+---*/
+
+var buffer = new SharedArrayBuffer(8);
+
+var newTarget = function() {}.bind(null);
+Object.defineProperty(newTarget, "prototype", {
+ get() {
+ throw new Test262Error();
+ }
+});
+
+testWithTypedArrayConstructors(function(TA) {
+ assert.throws(Test262Error, function() {
+ Reflect.construct(TA, [buffer], newTarget);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/custom-proto-access-throws.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/custom-proto-access-throws.js
new file mode 100644
index 000000000..88c98eebf
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/custom-proto-access-throws.js
@@ -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-buffer-byteoffset-length
+description: >
+ Return abrupt completion getting newTarget's prototype
+info: |
+ 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
+
+ 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 has an [[ArrayBufferData]] internal slot.
+
+ ...
+ 4. Let O be ? AllocateTypedArray(constructorName, 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 buffer = new ArrayBuffer(8);
+
+var newTarget = function() {}.bind(null);
+Object.defineProperty(newTarget, "prototype", {
+ get() {
+ throw new Test262Error();
+ }
+});
+
+testWithTypedArrayConstructors(function(TA) {
+ assert.throws(Test262Error, function() {
+ Reflect.construct(TA, [buffer], newTarget);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/defined-length-and-offset-sab.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/defined-length-and-offset-sab.js
new file mode 100644
index 000000000..2f153de63
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/defined-length-and-offset-sab.js
@@ -0,0 +1,33 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-buffer-byteoffset-length
+description: >
+ Return new typedArray from defined length and offset
+info: |
+ 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
+
+ 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 has an [[ArrayBufferData]] internal slot.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, SharedArrayBuffer, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var offset = TA.BYTES_PER_ELEMENT;
+ var buffer = new SharedArrayBuffer(3 * offset);
+
+ var ta1 = new TA(buffer, offset, 2);
+ assert.sameValue(ta1.length, 2, "ta1.length");
+ assert.sameValue(ta1.buffer, buffer, "ta1.buffer");
+ assert.sameValue(ta1.constructor, TA);
+ assert.sameValue(Object.getPrototypeOf(ta1), TA.prototype);
+
+ var ta2 = new TA(buffer, offset, 0);
+ assert.sameValue(ta2.length, 0, "ta2.length");
+ assert.sameValue(ta2.buffer, buffer, "ta2.buffer");
+ assert.sameValue(ta2.constructor, TA);
+ assert.sameValue(Object.getPrototypeOf(ta2), TA.prototype);
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/defined-length-and-offset.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/defined-length-and-offset.js
new file mode 100644
index 000000000..7e27248f8
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/defined-length-and-offset.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-buffer-byteoffset-length
+description: >
+ Return new typedArray from defined length and offset
+info: |
+ 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
+
+ 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 has an [[ArrayBufferData]] internal slot.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var offset = TA.BYTES_PER_ELEMENT;
+ var buffer = new ArrayBuffer(3 * offset);
+
+ var ta1 = new TA(buffer, offset, 2);
+ assert.sameValue(ta1.length, 2, "ta1.length");
+ assert.sameValue(ta1.buffer, buffer, "ta1.buffer");
+ assert.sameValue(ta1.constructor, TA);
+ assert.sameValue(Object.getPrototypeOf(ta1), TA.prototype);
+
+ var ta2 = new TA(buffer, offset, 0);
+ assert.sameValue(ta2.length, 0, "ta2.length");
+ assert.sameValue(ta2.buffer, buffer, "ta2.buffer");
+ assert.sameValue(ta2.constructor, TA);
+ assert.sameValue(Object.getPrototypeOf(ta2), TA.prototype);
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/defined-length-sab.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/defined-length-sab.js
new file mode 100644
index 000000000..916858939
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/defined-length-sab.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-buffer-byteoffset-length
+description: >
+ Return new typedArray from defined length
+info: |
+ 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
+
+ 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 has an [[ArrayBufferData]] internal slot.
+
+includes: [testBigIntTypedArray.js]
+features: [BigInt, SharedArrayBuffer, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var bpe = TA.BYTES_PER_ELEMENT;
+ var length = 4;
+ var buffer = new SharedArrayBuffer(bpe * length * 4);
+
+ var ta1 = new TA(buffer, 0, length);
+ assert.sameValue(ta1.length, length);
+ assert.sameValue(ta1.buffer, buffer);
+ assert.sameValue(ta1.constructor, TA);
+ assert.sameValue(Object.getPrototypeOf(ta1), TA.prototype);
+
+ var ta2 = new TA(buffer, 0, 0);
+ assert.sameValue(ta2.length, 0);
+ assert.sameValue(ta2.buffer, buffer);
+ assert.sameValue(ta2.constructor, TA);
+ assert.sameValue(Object.getPrototypeOf(ta2), TA.prototype);
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/defined-length.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/defined-length.js
new file mode 100644
index 000000000..711aeb53a
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/defined-length.js
@@ -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-buffer-byteoffset-length
+description: >
+ Return new typedArray from defined length
+info: |
+ 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
+
+ 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 has an [[ArrayBufferData]] internal slot.
+
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var bpe = TA.BYTES_PER_ELEMENT;
+ var length = 4;
+ var buffer = new ArrayBuffer(bpe * length * 4);
+
+ var ta1 = new TA(buffer, 0, length);
+ assert.sameValue(ta1.length, length);
+ assert.sameValue(ta1.buffer, buffer);
+ assert.sameValue(ta1.constructor, TA);
+ assert.sameValue(Object.getPrototypeOf(ta1), TA.prototype);
+
+ var ta2 = new TA(buffer, 0, 0);
+ assert.sameValue(ta2.length, 0);
+ assert.sameValue(ta2.buffer, buffer);
+ assert.sameValue(ta2.constructor, TA);
+ assert.sameValue(Object.getPrototypeOf(ta2), TA.prototype);
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/defined-negative-length-sab.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/defined-negative-length-sab.js
new file mode 100644
index 000000000..2138f4a81
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/defined-negative-length-sab.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-buffer-byteoffset-length
+description: >
+ Throws RangeError for negative ToInteger(length)
+info: |
+ 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
+
+ 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 has an [[ArrayBufferData]] internal slot.
+
+includes: [testBigIntTypedArray.js]
+features: [BigInt, SharedArrayBuffer, TypedArray]
+---*/
+
+var buffer = new SharedArrayBuffer(16);
+
+testWithTypedArrayConstructors(function(TA) {
+ assert.throws(RangeError, function() {
+ new TA(buffer, 0, -1);
+ });
+
+ assert.throws(RangeError, function() {
+ new TA(buffer, 0, -Infinity);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/defined-negative-length.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/defined-negative-length.js
new file mode 100644
index 000000000..f422a54d5
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/defined-negative-length.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-buffer-byteoffset-length
+description: >
+ Throws RangeError for negative ToInteger(length)
+info: |
+ 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
+
+ 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 has an [[ArrayBufferData]] internal slot.
+
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var buffer = new ArrayBuffer(16);
+
+testWithTypedArrayConstructors(function(TA) {
+ assert.throws(RangeError, function() {
+ new TA(buffer, 0, -1);
+ });
+
+ assert.throws(RangeError, function() {
+ new TA(buffer, 0, -Infinity);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/defined-offset-sab.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/defined-offset-sab.js
new file mode 100644
index 000000000..8cf9c14fe
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/defined-offset-sab.js
@@ -0,0 +1,33 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-buffer-byteoffset-length
+description: >
+ Return new typedArray from defined offset
+info: |
+ 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
+
+ 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 has an [[ArrayBufferData]] internal slot.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, SharedArrayBuffer, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var bpe = TA.BYTES_PER_ELEMENT;
+ var buffer = new SharedArrayBuffer(bpe * 4);
+
+ var ta1 = new TA(buffer, bpe * 2);
+ assert.sameValue(ta1.length, 2);
+ assert.sameValue(ta1.buffer, buffer);
+ assert.sameValue(ta1.constructor, TA);
+ assert.sameValue(Object.getPrototypeOf(ta1), TA.prototype);
+
+ var ta2 = new TA(buffer, 0);
+ assert.sameValue(ta2.length, 4);
+ assert.sameValue(ta2.buffer, buffer);
+ assert.sameValue(ta2.constructor, TA);
+ assert.sameValue(Object.getPrototypeOf(ta2), TA.prototype);
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/defined-offset.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/defined-offset.js
new file mode 100644
index 000000000..a8005eb0b
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/defined-offset.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-buffer-byteoffset-length
+description: >
+ Return new typedArray from defined offset
+info: |
+ 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
+
+ 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 has an [[ArrayBufferData]] internal slot.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var bpe = TA.BYTES_PER_ELEMENT;
+ var buffer = new ArrayBuffer(bpe * 4);
+
+ var ta1 = new TA(buffer, bpe * 2);
+ assert.sameValue(ta1.length, 2);
+ assert.sameValue(ta1.buffer, buffer);
+ assert.sameValue(ta1.constructor, TA);
+ assert.sameValue(Object.getPrototypeOf(ta1), TA.prototype);
+
+ var ta2 = new TA(buffer, 0);
+ assert.sameValue(ta2.length, 4);
+ assert.sameValue(ta2.buffer, buffer);
+ assert.sameValue(ta2.constructor, TA);
+ assert.sameValue(Object.getPrototypeOf(ta2), TA.prototype);
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/detachedbuffer.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/detachedbuffer.js
new file mode 100644
index 000000000..26cf08ae9
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/detachedbuffer.js
@@ -0,0 +1,21 @@
+// 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-buffer-byteoffset-length
+description: If TypedArray() is passed a detached buffer, throw
+info: |
+ 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
+
+ ...
+ 9. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var offset = TA.BYTES_PER_ELEMENT;
+ var buffer = new ArrayBuffer(3 * offset);
+ $DETACHBUFFER(buffer);
+ assert.throws(TypeError, () => new TA(buffer));
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/excessive-length-throws-sab.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/excessive-length-throws-sab.js
new file mode 100644
index 000000000..64d726466
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/excessive-length-throws-sab.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-buffer-byteoffset-length
+description: >
+ If offset + newByteLength > bufferByteLength, throw a RangeError exception.
+info: |
+ 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
+
+ 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 has an [[ArrayBufferData]] internal slot.
+
+ ...
+ 14. Else,
+ a. Let newLength be ? ToLength(length).
+ b. Let newByteLength be newLength × elementSize.
+ c. If offset+newByteLength > bufferByteLength, throw a RangeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, SharedArrayBuffer, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var bpe = TA.BYTES_PER_ELEMENT;
+ var buffer = new SharedArrayBuffer(bpe);
+
+ assert.throws(RangeError, function() {
+ new TA(buffer, 0, bpe * 2);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/excessive-length-throws.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/excessive-length-throws.js
new file mode 100644
index 000000000..1f2378625
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/excessive-length-throws.js
@@ -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.
+/*---
+esid: sec-typedarray-buffer-byteoffset-length
+description: >
+ If offset + newByteLength > bufferByteLength, throw a RangeError exception.
+info: |
+ 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
+
+ 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 has an [[ArrayBufferData]] internal slot.
+
+ ...
+ 14. Else,
+ a. Let newLength be ? ToLength(length).
+ b. Let newByteLength be newLength × elementSize.
+ c. If offset+newByteLength > bufferByteLength, throw a RangeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var bpe = TA.BYTES_PER_ELEMENT;
+ var buffer = new ArrayBuffer(bpe);
+
+ assert.throws(RangeError, function() {
+ new TA(buffer, 0, bpe * 2);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/excessive-offset-throws-sab.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/excessive-offset-throws-sab.js
new file mode 100644
index 000000000..2b78d7926
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/excessive-offset-throws-sab.js
@@ -0,0 +1,36 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-buffer-byteoffset-length
+description: >
+ Throws a RangeError if bufferByteLength - ToInteger(byteOffset) < 0
+info: |
+ 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
+
+ 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 has an [[ArrayBufferData]] internal slot.
+
+ ...
+ 13. If length is undefined, then
+ a. If bufferByteLength modulo elementSize ≠ 0, throw a RangeError exception.
+ b. Let newByteLength be bufferByteLength - offset.
+ c. If newByteLength < 0, throw a RangeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, SharedArrayBuffer, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var bpe = TA.BYTES_PER_ELEMENT;
+ var buffer = new SharedArrayBuffer(bpe);
+
+ assert.throws(RangeError, function() {
+ new TA(buffer, bpe * 2);
+ });
+
+ assert.throws(RangeError, function() {
+ new TA(buffer, bpe * 2, undefined);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/excessive-offset-throws.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/excessive-offset-throws.js
new file mode 100644
index 000000000..81454fba7
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/excessive-offset-throws.js
@@ -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-buffer-byteoffset-length
+description: >
+ Throws a RangeError if bufferByteLength - ToInteger(byteOffset) < 0
+info: |
+ 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
+
+ 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 has an [[ArrayBufferData]] internal slot.
+
+ ...
+ 13. If length is undefined, then
+ a. If bufferByteLength modulo elementSize ≠ 0, throw a RangeError exception.
+ b. Let newByteLength be bufferByteLength - offset.
+ c. If newByteLength < 0, throw a RangeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var bpe = TA.BYTES_PER_ELEMENT;
+ var buffer = new ArrayBuffer(bpe);
+
+ assert.throws(RangeError, function() {
+ new TA(buffer, bpe * 2);
+ });
+
+ assert.throws(RangeError, function() {
+ new TA(buffer, bpe * 2, undefined);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/invoked-with-undefined-newtarget-sab.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/invoked-with-undefined-newtarget-sab.js
new file mode 100644
index 000000000..7b3b9c9e2
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/invoked-with-undefined-newtarget-sab.js
@@ -0,0 +1,27 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-buffer-byteoffset-length
+description: >
+ Throws a TypeError if NewTarget is undefined.
+info: |
+ 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
+
+ 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 has an [[ArrayBufferData]] internal slot.
+
+ ...
+ 2. If NewTarget is undefined, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, SharedArrayBuffer, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var buffer = new SharedArrayBuffer(4);
+ assert.throws(TypeError, function() {
+ TA(buffer);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/invoked-with-undefined-newtarget.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/invoked-with-undefined-newtarget.js
new file mode 100644
index 000000000..0301136c0
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/invoked-with-undefined-newtarget.js
@@ -0,0 +1,26 @@
+// 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-buffer-byteoffset-length
+description: >
+ Throws a TypeError if NewTarget is undefined.
+info: |
+ 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
+
+ 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 has an [[ArrayBufferData]] internal slot.
+
+ ...
+ 2. If NewTarget is undefined, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var buffer = new ArrayBuffer(4);
+ assert.throws(TypeError, function() {
+ TA(buffer);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/is-referenced-sab.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/is-referenced-sab.js
new file mode 100644
index 000000000..bdff85d02
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/is-referenced-sab.js
@@ -0,0 +1,33 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-buffer-byteoffset-length
+description: >
+ Reuse buffer argument instead of making a new clone
+info: |
+ 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
+
+ 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 has an [[ArrayBufferData]] internal slot.
+
+ ...
+ 15. Set O's [[ViewedArrayBuffer]] internal slot to buffer.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, SharedArrayBuffer, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var bpe = TA.BYTES_PER_ELEMENT;
+
+ var buffer = new SharedArrayBuffer(bpe);
+
+ var ta1 = new TA(buffer);
+ var ta2 = new TA(buffer);
+
+ assert.sameValue(ta1.buffer, buffer);
+ assert.sameValue(ta2.buffer, buffer);
+ assert.sameValue(ta1.buffer, ta2.buffer);
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/is-referenced.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/is-referenced.js
new file mode 100644
index 000000000..1b609117f
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/is-referenced.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-buffer-byteoffset-length
+description: >
+ Reuse buffer argument instead of making a new clone
+info: |
+ 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
+
+ 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 has an [[ArrayBufferData]] internal slot.
+
+ ...
+ 15. Set O's [[ViewedArrayBuffer]] internal slot to buffer.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var bpe = TA.BYTES_PER_ELEMENT;
+
+ var buffer = new ArrayBuffer(bpe);
+
+ var ta1 = new TA(buffer);
+ var ta2 = new TA(buffer);
+
+ assert.sameValue(ta1.buffer, buffer);
+ assert.sameValue(ta2.buffer, buffer);
+ assert.sameValue(ta1.buffer, ta2.buffer);
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/length-access-throws-sab.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/length-access-throws-sab.js
new file mode 100644
index 000000000..792101566
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/length-access-throws-sab.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-buffer-byteoffset-length
+description: >
+ Returns abrupt from ToLength(length)
+info: |
+ 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
+
+ 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 has an [[ArrayBufferData]] internal slot.
+
+ ...
+ 14. Else,
+ a. Let newLength be ? ToLength(length).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, SharedArrayBuffer, TypedArray]
+---*/
+
+var buffer = new SharedArrayBuffer(8);
+var len = {
+ valueOf() {
+ throw new Test262Error();
+ }
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ assert.throws(Test262Error, function() {
+ new TA(buffer, 0, len);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/length-access-throws.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/length-access-throws.js
new file mode 100644
index 000000000..373311d0c
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/length-access-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-buffer-byteoffset-length
+description: >
+ Returns abrupt from ToLength(length)
+info: |
+ 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
+
+ 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 has an [[ArrayBufferData]] internal slot.
+
+ ...
+ 14. Else,
+ a. Let newLength be ? ToLength(length).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var buffer = new ArrayBuffer(8);
+var len = {
+ valueOf() {
+ throw new Test262Error();
+ }
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ assert.throws(Test262Error, function() {
+ new TA(buffer, 0, len);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/length-is-symbol-throws-sab.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/length-is-symbol-throws-sab.js
new file mode 100644
index 000000000..d0619a3f8
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/length-is-symbol-throws-sab.js
@@ -0,0 +1,30 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-buffer-byteoffset-length
+description: >
+ Throws a TypeError if length is a Symbol
+info: |
+ 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
+
+ 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 has an [[ArrayBufferData]] internal slot.
+
+ ...
+ 14. Else,
+ a. Let newLength be ? ToLength(length).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, SharedArrayBuffer, TypedArray]
+---*/
+
+var buffer = new SharedArrayBuffer(8);
+var s = Symbol("1");
+
+testWithTypedArrayConstructors(function(TA) {
+ assert.throws(TypeError, function() {
+ new TA(buffer, 0, s);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/length-is-symbol-throws.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/length-is-symbol-throws.js
new file mode 100644
index 000000000..978e01e7d
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/length-is-symbol-throws.js
@@ -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-typedarray-buffer-byteoffset-length
+description: >
+ Throws a TypeError if length is a Symbol
+info: |
+ 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
+
+ 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 has an [[ArrayBufferData]] internal slot.
+
+ ...
+ 14. Else,
+ a. Let newLength be ? ToLength(length).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+var buffer = new ArrayBuffer(8);
+var s = Symbol("1");
+
+testWithTypedArrayConstructors(function(TA) {
+ assert.throws(TypeError, function() {
+ new TA(buffer, 0, s);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/length-to-number-detachbuffer.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/length-to-number-detachbuffer.js
new file mode 100644
index 000000000..9bf8105f0
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/length-to-number-detachbuffer.js
@@ -0,0 +1,21 @@
+// 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-buffer-byteoffset-length
+description: If TypedArray() is passed a detached buffer, throw
+info: |
+ 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
+
+ ...
+ 9. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var offset = TA.BYTES_PER_ELEMENT;
+ var buffer = new ArrayBuffer(3 * offset);
+ var length = { valueOf() { $DETACHBUFFER(buffer); return 1; } };
+ assert.throws(TypeError, () => new TA(buffer, 0, length));
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/new-instance-extensibility-sab.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/new-instance-extensibility-sab.js
new file mode 100644
index 000000000..5d5976424
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/new-instance-extensibility-sab.js
@@ -0,0 +1,38 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-buffer-byteoffset-length
+description: >
+ The new typedArray instance from a buffer argument is extensible
+info: |
+ 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
+
+ ...
+ 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, SharedArrayBuffer, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var buffer = new SharedArrayBuffer(8);
+ var sample = new TA(buffer);
+
+ assert(Object.isExtensible(sample));
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/new-instance-extensibility.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/new-instance-extensibility.js
new file mode 100644
index 000000000..6f7c8b7f4
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/new-instance-extensibility.js
@@ -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-buffer-byteoffset-length
+description: >
+ The new typedArray instance from a buffer argument is extensible
+info: |
+ 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
+
+ ...
+ 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]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var buffer = new ArrayBuffer(8);
+ var sample = new TA(buffer);
+
+ assert(Object.isExtensible(sample));
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/proto-from-ctor-realm-sab.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/proto-from-ctor-realm-sab.js
new file mode 100644
index 000000000..86374357e
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/proto-from-ctor-realm-sab.js
@@ -0,0 +1,38 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-buffer-byteoffset-length
+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, SharedArrayBuffer, Reflect, TypedArray]
+---*/
+
+var other = $262.createRealm().global;
+var C = new other.Function();
+C.prototype = null;
+
+testWithTypedArrayConstructors(function(TA) {
+ var ta = Reflect.construct(TA, [new SharedArrayBuffer(8)], C);
+
+ assert.sameValue(Object.getPrototypeOf(ta), other[TA.name].prototype);
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/proto-from-ctor-realm.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/proto-from-ctor-realm.js
new file mode 100644
index 000000000..8e5f4b12f
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/proto-from-ctor-realm.js
@@ -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-buffer-byteoffset-length
+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;
+
+testWithTypedArrayConstructors(function(TA) {
+ var ta = Reflect.construct(TA, [new ArrayBuffer(8)], C);
+
+ assert.sameValue(Object.getPrototypeOf(ta), other[TA.name].prototype);
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/returns-new-instance-sab.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/returns-new-instance-sab.js
new file mode 100644
index 000000000..4067b836f
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/returns-new-instance-sab.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-buffer-byteoffset-length
+description: >
+ Return new typedArray from undefined offset and length
+info: |
+ 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
+
+ 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 has an [[ArrayBufferData]] internal slot.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, SharedArrayBuffer, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var bpe = TA.BYTES_PER_ELEMENT;
+
+ var buffer1 = new SharedArrayBuffer(bpe * 4);
+ var ta1 = new TA(buffer1);
+ assert.sameValue(ta1.length, 4);
+ assert.sameValue(ta1.buffer, buffer1);
+ assert.sameValue(ta1.constructor, TA);
+ assert.sameValue(Object.getPrototypeOf(ta1), TA.prototype);
+
+ var buffer2 = new SharedArrayBuffer(0);
+ var ta2 = new TA(buffer2);
+ assert.sameValue(ta2.length, 0);
+ assert.sameValue(ta2.buffer, buffer2);
+ assert.sameValue(ta2.constructor, TA);
+ assert.sameValue(Object.getPrototypeOf(ta2), TA.prototype);
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/returns-new-instance.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/returns-new-instance.js
new file mode 100644
index 000000000..d6fb802b9
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/returns-new-instance.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-buffer-byteoffset-length
+description: >
+ Return new typedArray from undefined offset and length
+info: |
+ 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
+
+ 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 has an [[ArrayBufferData]] internal slot.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var bpe = TA.BYTES_PER_ELEMENT;
+
+ var buffer1 = new ArrayBuffer(bpe * 4);
+ var ta1 = new TA(buffer1);
+ assert.sameValue(ta1.length, 4);
+ assert.sameValue(ta1.buffer, buffer1);
+ assert.sameValue(ta1.constructor, TA);
+ assert.sameValue(Object.getPrototypeOf(ta1), TA.prototype);
+
+ var buffer2 = new ArrayBuffer(0);
+ var ta2 = new TA(buffer2);
+ assert.sameValue(ta2.length, 0);
+ assert.sameValue(ta2.buffer, buffer2);
+ assert.sameValue(ta2.constructor, TA);
+ assert.sameValue(Object.getPrototypeOf(ta2), TA.prototype);
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/toindex-bytelength-sab.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/toindex-bytelength-sab.js
new file mode 100644
index 000000000..3a9d2490e
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/toindex-bytelength-sab.js
@@ -0,0 +1,73 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-buffer-byteoffset-length
+description: >
+ ToIndex(length) operations
+info: |
+ 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
+
+ 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 has an [[ArrayBufferData]] internal slot.
+
+ ...
+ 11. If length is either not present or undefined, then
+ ...
+ 12. Else,
+ a. Let newLength be ? ToIndex(length).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, SharedArrayBuffer, TypedArray]
+---*/
+
+var buffer = new SharedArrayBuffer(16);
+
+var obj1 = {
+ valueOf: function() {
+ return 1;
+ }
+};
+
+var obj2 = {
+ toString: function() {
+ return 1;
+ }
+};
+
+var items = [
+ [-0, 0, "-0"],
+ [obj1, 1, "object's valueOf"],
+ [obj2, 1, "object's toString"],
+ ["", 0, "the Empty string"],
+ ["0", 0, "string '0'"],
+ ["1", 1, "string '1'"],
+ [false, 0, "false"],
+ [true, 1, "true"],
+ [NaN, 0, "NaN"],
+ [null, 0, "null"],
+ [0.1, 0, "0.1"],
+ [0.9, 0, "0.9"],
+ [1.1, 1, "1.1"],
+ [1.9, 1, "1.9"],
+ [-0.1, 0, "-0.1"],
+ [-0.99999, 0, "-0.99999"]
+];
+
+testWithTypedArrayConstructors(function(TA) {
+ items.forEach(function(item) {
+ var len = item[0];
+ var expected = item[1];
+ var name = item[2];
+
+ var typedArray = new TA(buffer, 0, len);
+ assert.sameValue(typedArray.length, expected, name + " length");
+ assert.sameValue(typedArray.constructor, TA, name + " constructor");
+ assert.sameValue(
+ Object.getPrototypeOf(typedArray),
+ TA.prototype,
+ name + " prototype"
+ );
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/toindex-bytelength.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/toindex-bytelength.js
new file mode 100644
index 000000000..8155a4479
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/toindex-bytelength.js
@@ -0,0 +1,72 @@
+// 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-buffer-byteoffset-length
+description: >
+ ToIndex(length) operations
+info: |
+ 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
+
+ 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 has an [[ArrayBufferData]] internal slot.
+
+ ...
+ 11. If length is either not present or undefined, then
+ ...
+ 12. Else,
+ a. Let newLength be ? ToIndex(length).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var buffer = new ArrayBuffer(16);
+
+var obj1 = {
+ valueOf: function() {
+ return 1;
+ }
+};
+
+var obj2 = {
+ toString: function() {
+ return 1;
+ }
+};
+
+var items = [
+ [-0, 0, "-0"],
+ [obj1, 1, "object's valueOf"],
+ [obj2, 1, "object's toString"],
+ ["", 0, "the Empty string"],
+ ["0", 0, "string '0'"],
+ ["1", 1, "string '1'"],
+ [false, 0, "false"],
+ [true, 1, "true"],
+ [NaN, 0, "NaN"],
+ [null, 0, "null"],
+ [0.1, 0, "0.1"],
+ [0.9, 0, "0.9"],
+ [1.1, 1, "1.1"],
+ [1.9, 1, "1.9"],
+ [-0.1, 0, "-0.1"],
+ [-0.99999, 0, "-0.99999"]
+];
+
+testWithTypedArrayConstructors(function(TA) {
+ items.forEach(function(item) {
+ var len = item[0];
+ var expected = item[1];
+ var name = item[2];
+
+ var typedArray = new TA(buffer, 0, len);
+ assert.sameValue(typedArray.length, expected, name + " length");
+ assert.sameValue(typedArray.constructor, TA, name + " constructor");
+ assert.sameValue(
+ Object.getPrototypeOf(typedArray),
+ TA.prototype,
+ name + " prototype"
+ );
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/toindex-byteoffset-sab.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/toindex-byteoffset-sab.js
new file mode 100644
index 000000000..e6085da48
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/toindex-byteoffset-sab.js
@@ -0,0 +1,87 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-buffer-byteoffset-length
+description: >
+ ToIndex(byteOffset) operations
+info: |
+ 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
+
+ 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 has an [[ArrayBufferData]] internal slot.
+
+ ...
+ 7. Let offset be ? ToIndex(byteOffset).
+ 8. If offset modulo elementSize ≠ 0, throw a RangeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, SharedArrayBuffer, TypedArray]
+---*/
+
+var buffer = new SharedArrayBuffer(16);
+
+var obj1 = {
+ valueOf: function() {
+ return 8;
+ }
+};
+
+var obj2 = {
+ toString: function() {
+ return 8;
+ }
+};
+
+var items = [
+ [-0, 0, "-0"],
+ [obj1, 8, "object's valueOf"],
+ [obj2, 8, "object's toString"],
+ ["", 0, "the Empty string"],
+ ["0", 0, "string '0'"],
+ ["8", 8, "string '8'"],
+ [false, 0, "false"],
+ [NaN, 0, "NaN"],
+ [null, 0, "null"],
+ [undefined, 0, "undefined"],
+ [0.1, 0, "0.1"],
+ [0.9, 0, "0.9"],
+ [8.1, 8, "8.1"],
+ [8.9, 8, "8.9"],
+ [-0.1, 0, "-0.1"],
+ [-0.99999, 0, "-0.99999"]
+];
+
+testWithTypedArrayConstructors(function(TA) {
+ items.forEach(function(item) {
+ var offset = item[0];
+ var expected = item[1];
+ var name = item[2];
+
+ var typedArray = new TA(buffer, offset);
+ assert.sameValue(typedArray.byteOffset, expected, name + " byteOffset");
+ assert.sameValue(typedArray.constructor, TA, name + " constructor");
+ assert.sameValue(
+ Object.getPrototypeOf(typedArray),
+ TA.prototype,
+ name + " prototype"
+ );
+ });
+
+ // Testing `true`. See step 8
+ if (TA.BYTES_PER_ELEMENT === 1) {
+ var typedArray = new TA(buffer, true);
+ assert.sameValue(typedArray.byteOffset, 1, "true => 1 byteOffset");
+ assert.sameValue(typedArray.constructor, TA, "true => 1 constructor");
+ assert.sameValue(
+ Object.getPrototypeOf(typedArray),
+ TA.prototype,
+ "true => 1 prototype"
+ );
+ } else {
+ assert.throws(RangeError, function() {
+ new TA(buffer, true);
+ }, "1 modulo elementSize ≠ 0, throws a RangeError");
+ }
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/toindex-byteoffset.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/toindex-byteoffset.js
new file mode 100644
index 000000000..216f9cfdb
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/toindex-byteoffset.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-buffer-byteoffset-length
+description: >
+ ToIndex(byteOffset) operations
+info: |
+ 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
+
+ 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 has an [[ArrayBufferData]] internal slot.
+
+ ...
+ 7. Let offset be ? ToIndex(byteOffset).
+ 8. If offset modulo elementSize ≠ 0, throw a RangeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var buffer = new ArrayBuffer(16);
+
+var obj1 = {
+ valueOf: function() {
+ return 8;
+ }
+};
+
+var obj2 = {
+ toString: function() {
+ return 8;
+ }
+};
+
+var items = [
+ [-0, 0, "-0"],
+ [obj1, 8, "object's valueOf"],
+ [obj2, 8, "object's toString"],
+ ["", 0, "the Empty string"],
+ ["0", 0, "string '0'"],
+ ["8", 8, "string '8'"],
+ [false, 0, "false"],
+ [NaN, 0, "NaN"],
+ [null, 0, "null"],
+ [undefined, 0, "undefined"],
+ [0.1, 0, "0.1"],
+ [0.9, 0, "0.9"],
+ [8.1, 8, "8.1"],
+ [8.9, 8, "8.9"],
+ [-0.1, 0, "-0.1"],
+ [-0.99999, 0, "-0.99999"]
+];
+
+testWithTypedArrayConstructors(function(TA) {
+ items.forEach(function(item) {
+ var offset = item[0];
+ var expected = item[1];
+ var name = item[2];
+
+ var typedArray = new TA(buffer, offset);
+ assert.sameValue(typedArray.byteOffset, expected, name + " byteOffset");
+ assert.sameValue(typedArray.constructor, TA, name + " constructor");
+ assert.sameValue(
+ Object.getPrototypeOf(typedArray),
+ TA.prototype,
+ name + " prototype"
+ );
+ });
+
+ // Testing `true`. See step 8
+ if (TA.BYTES_PER_ELEMENT === 1) {
+ var typedArray = new TA(buffer, true);
+ assert.sameValue(typedArray.byteOffset, 1, "true => 1 byteOffset");
+ assert.sameValue(typedArray.constructor, TA, "true => 1 constructor");
+ assert.sameValue(
+ Object.getPrototypeOf(typedArray),
+ TA.prototype,
+ "true => 1 prototype"
+ );
+ } else {
+ assert.throws(RangeError, function() {
+ new TA(buffer, true);
+ }, "1 modulo elementSize ≠ 0, throws a RangeError");
+ }
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/typedarray-backed-by-sharedarraybuffer.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/typedarray-backed-by-sharedarraybuffer.js
new file mode 100644
index 000000000..6a25a0aa9
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/typedarray-backed-by-sharedarraybuffer.js
@@ -0,0 +1,23 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-typedarray-typedarray
+description: >
+ Passing a SharedArrayBuffer-backed TypedArray to a TypedArray constructor
+ produces an ArrayBuffer-backed TypedArray.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, SharedArrayBuffer, TypedArray]
+---*/
+
+var sab = new SharedArrayBuffer(4);
+var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
+
+testWithTypedArrayConstructors(function(View1) {
+ var ta1 = new View1(sab);
+ testWithTypedArrayConstructors(function(View2) {
+ var ta2 = new View2(ta1);
+ assert.sameValue(ta2.buffer.constructor, ArrayBuffer,
+ "TypedArray of SharedArrayBuffer-backed TypedArray is ArrayBuffer-backed");
+ }, int_views);
+}, int_views);
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/use-custom-proto-if-object-sab.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/use-custom-proto-if-object-sab.js
new file mode 100644
index 000000000..b14fd3c4f
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/use-custom-proto-if-object-sab.js
@@ -0,0 +1,49 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-buffer-byteoffset-length
+description: >
+ Use prototype from new target if it's an Object
+info: |
+ 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
+
+ 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 has an [[ArrayBufferData]] internal slot.
+
+ ...
+ 4. Let O be ? AllocateTypedArray(constructorName, 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, SharedArrayBuffer, Reflect, TypedArray]
+---*/
+
+var buffer = new SharedArrayBuffer(8);
+
+function newTarget() {}
+var proto = {};
+newTarget.prototype = proto;
+
+testWithTypedArrayConstructors(function(TA) {
+ var ta = Reflect.construct(TA, [buffer], newTarget);
+
+ assert.sameValue(ta.constructor, Object);
+ assert.sameValue(Object.getPrototypeOf(ta), proto);
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/use-custom-proto-if-object.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/use-custom-proto-if-object.js
new file mode 100644
index 000000000..0cbbb87f6
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/use-custom-proto-if-object.js
@@ -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-buffer-byteoffset-length
+description: >
+ Use prototype from new target if it's an Object
+info: |
+ 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
+
+ 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 has an [[ArrayBufferData]] internal slot.
+
+ ...
+ 4. Let O be ? AllocateTypedArray(constructorName, 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]
+---*/
+
+var buffer = new ArrayBuffer(8);
+
+function newTarget() {}
+var proto = {};
+newTarget.prototype = proto;
+
+testWithTypedArrayConstructors(function(TA) {
+ var ta = Reflect.construct(TA, [buffer], newTarget);
+
+ assert.sameValue(ta.constructor, Object);
+ assert.sameValue(Object.getPrototypeOf(ta), proto);
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/use-default-proto-if-custom-proto-is-not-object-sab.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/use-default-proto-if-custom-proto-is-not-object-sab.js
new file mode 100644
index 000000000..9e7a51901
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/use-default-proto-if-custom-proto-is-not-object-sab.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-buffer-byteoffset-length
+description: >
+ Use prototype from %TypedArray% if newTarget's prototype is not an Object
+info: |
+ 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
+
+ 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 has an [[ArrayBufferData]] internal slot.
+
+ ...
+ 4. Let O be ? AllocateTypedArray(constructorName, 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, SharedArrayBuffer, TypedArray]
+---*/
+
+var buffer = new SharedArrayBuffer(8);
+
+function newTarget() {}
+newTarget.prototype = null;
+
+testWithTypedArrayConstructors(function(TA) {
+ var ta = Reflect.construct(TA, [buffer], newTarget);
+
+ assert.sameValue(ta.constructor, TA);
+ assert.sameValue(Object.getPrototypeOf(ta), TA.prototype);
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/use-default-proto-if-custom-proto-is-not-object.js b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/use-default-proto-if-custom-proto-is-not-object.js
new file mode 100644
index 000000000..7e8a5770a
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/buffer-arg/use-default-proto-if-custom-proto-is-not-object.js
@@ -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-buffer-byteoffset-length
+description: >
+ Use prototype from %TypedArray% if newTarget's prototype is not an Object
+info: |
+ 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
+
+ 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 has an [[ArrayBufferData]] internal slot.
+
+ ...
+ 4. Let O be ? AllocateTypedArray(constructorName, 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]
+---*/
+
+var buffer = new ArrayBuffer(8);
+
+function newTarget() {}
+newTarget.prototype = null;
+
+testWithTypedArrayConstructors(function(TA) {
+ var ta = Reflect.construct(TA, [buffer], newTarget);
+
+ assert.sameValue(ta.constructor, TA);
+ assert.sameValue(Object.getPrototypeOf(ta), TA.prototype);
+});