summaryrefslogtreecommitdiff
path: root/test/built-ins/TypedArrays/ctors-bigint/butter-arg
diff options
context:
space:
mode:
authorLeo Balter <leonardo.balter@gmail.com>2018-02-09 13:35:18 -0500
committerLeo Balter <leonardo.balter@gmail.com>2018-02-15 16:45:05 -0500
commit5722ac494b89135cdcc406ec9ca3362920129346 (patch)
treea1ca0c4998033ce89062e22bda13496d80f4e50c /test/built-ins/TypedArrays/ctors-bigint/butter-arg
parent9232d65b303620da18e2fe57945275cd3b29cb22 (diff)
downloadqtdeclarative-testsuites-5722ac494b89135cdcc406ec9ca3362920129346.tar.gz
Move TypedArray ctors tests to a bigint specific folder
Diffstat (limited to 'test/built-ins/TypedArrays/ctors-bigint/butter-arg')
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-bufferbyteoffset-throws-from-modulo-element-size-sab.js38
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-bufferbyteoffset-throws-from-modulo-element-size.js37
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-byteoffset-is-negative-throws-sab.js32
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-byteoffset-is-negative-throws.js31
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-byteoffset-is-negative-zero-sab.js23
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-byteoffset-is-negative-zero.js23
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-byteoffset-is-symbol-throws-sab.js29
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-byteoffset-is-symbol-throws.js28
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-byteoffset-throws-from-modulo-element-size-sab.js33
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-byteoffset-throws-from-modulo-element-size.js32
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-byteoffset-to-number-detachbuffer.js21
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-byteoffset-to-number-throws-sab.js33
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-byteoffset-to-number-throws.js32
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-custom-proto-access-throws-sab.js48
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-custom-proto-access-throws.js47
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-defined-length-and-offset-sab.js33
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-defined-length-and-offset.js32
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-defined-length-sab.js35
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-defined-length.js34
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-defined-negative-length-sab.js29
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-defined-negative-length.js28
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-defined-offset-sab.js33
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-defined-offset.js32
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-detachedbuffer.js21
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-excessive-length-throws-sab.js32
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-excessive-length-throws.js31
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-excessive-offset-throws-sab.js36
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-excessive-offset-throws.js35
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-invoked-with-undefined-newtarget-sab.js27
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-invoked-with-undefined-newtarget.js26
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-is-referenced-sab.js33
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-is-referenced.js32
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-length-access-throws-sab.js34
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-length-access-throws.js33
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-length-is-symbol-throws-sab.js30
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-length-is-symbol-throws.js29
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-length-to-number-detachbuffer.js21
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-new-instance-extensibility-sab.js38
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-new-instance-extensibility.js37
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-proto-from-ctor-realm-sab.js38
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-proto-from-ctor-realm.js37
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-returns-new-instance-sab.js34
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-returns-new-instance.js33
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-toindex-bytelength-sab.js73
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-toindex-bytelength.js72
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-toindex-byteoffset-sab.js87
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-toindex-byteoffset.js86
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-typedarray-backed-by-sharedarraybuffer.js23
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-use-custom-proto-if-object-sab.js49
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-use-custom-proto-if-object.js48
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-use-default-proto-if-custom-proto-is-not-object-sab.js48
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/butter-arg/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/butter-arg/buffer-arg-bufferbyteoffset-throws-from-modulo-element-size-sab.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-bufferbyteoffset-throws-from-modulo-element-size-sab.js
new file mode 100644
index 000000000..707aa00be
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js]
+features: [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/butter-arg/buffer-arg-bufferbyteoffset-throws-from-modulo-element-size.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-bufferbyteoffset-throws-from-modulo-element-size.js
new file mode 100644
index 000000000..a886e5afd
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js]
+features: [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/butter-arg/buffer-arg-byteoffset-is-negative-throws-sab.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-byteoffset-is-negative-throws-sab.js
new file mode 100644
index 000000000..89f58a1cd
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js]
+features: [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/butter-arg/buffer-arg-byteoffset-is-negative-throws.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-byteoffset-is-negative-throws.js
new file mode 100644
index 000000000..058892465
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js]
+features: [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/butter-arg/buffer-arg-byteoffset-is-negative-zero-sab.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-byteoffset-is-negative-zero-sab.js
new file mode 100644
index 000000000..1073b5af8
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js]
+features: [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/butter-arg/buffer-arg-byteoffset-is-negative-zero.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-byteoffset-is-negative-zero.js
new file mode 100644
index 000000000..13d0a3e14
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js]
+features: [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/butter-arg/buffer-arg-byteoffset-is-symbol-throws-sab.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-byteoffset-is-symbol-throws-sab.js
new file mode 100644
index 000000000..b5fc270c9
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js]
+features: [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/butter-arg/buffer-arg-byteoffset-is-symbol-throws.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-byteoffset-is-symbol-throws.js
new file mode 100644
index 000000000..60039a1f5
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js]
+features: [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/butter-arg/buffer-arg-byteoffset-throws-from-modulo-element-size-sab.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-byteoffset-throws-from-modulo-element-size-sab.js
new file mode 100644
index 000000000..79b398ccf
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js]
+features: [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/butter-arg/buffer-arg-byteoffset-throws-from-modulo-element-size.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-byteoffset-throws-from-modulo-element-size.js
new file mode 100644
index 000000000..479f0d5dc
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js]
+features: [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/butter-arg/buffer-arg-byteoffset-to-number-detachbuffer.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-byteoffset-to-number-detachbuffer.js
new file mode 100644
index 000000000..b8936e8cd
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js, detachArrayBuffer.js]
+features: [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/butter-arg/buffer-arg-byteoffset-to-number-throws-sab.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-byteoffset-to-number-throws-sab.js
new file mode 100644
index 000000000..e7b336c5e
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js]
+features: [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/butter-arg/buffer-arg-byteoffset-to-number-throws.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-byteoffset-to-number-throws.js
new file mode 100644
index 000000000..20cd4b796
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js]
+features: [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/butter-arg/buffer-arg-custom-proto-access-throws-sab.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-custom-proto-access-throws-sab.js
new file mode 100644
index 000000000..b3ff8c56e
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js]
+features: [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/butter-arg/buffer-arg-custom-proto-access-throws.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-custom-proto-access-throws.js
new file mode 100644
index 000000000..a1b823317
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js]
+features: [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/butter-arg/buffer-arg-defined-length-and-offset-sab.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-defined-length-and-offset-sab.js
new file mode 100644
index 000000000..2107146b1
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js]
+features: [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/butter-arg/buffer-arg-defined-length-and-offset.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-defined-length-and-offset.js
new file mode 100644
index 000000000..aefd48b55
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js]
+features: [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/butter-arg/buffer-arg-defined-length-sab.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-defined-length-sab.js
new file mode 100644
index 000000000..a06e530d0
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js]
+features: [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/butter-arg/buffer-arg-defined-length.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-defined-length.js
new file mode 100644
index 000000000..11fb1c4a4
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js]
+features: [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/butter-arg/buffer-arg-defined-negative-length-sab.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-defined-negative-length-sab.js
new file mode 100644
index 000000000..4d1b1d29c
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js]
+features: [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/butter-arg/buffer-arg-defined-negative-length.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-defined-negative-length.js
new file mode 100644
index 000000000..d57d466d9
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js]
+features: [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/butter-arg/buffer-arg-defined-offset-sab.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-defined-offset-sab.js
new file mode 100644
index 000000000..515d822c1
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js]
+features: [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/butter-arg/buffer-arg-defined-offset.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-defined-offset.js
new file mode 100644
index 000000000..89e290b52
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js]
+features: [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/butter-arg/buffer-arg-detachedbuffer.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-detachedbuffer.js
new file mode 100644
index 000000000..b015d4c34
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js, detachArrayBuffer.js]
+features: [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/butter-arg/buffer-arg-excessive-length-throws-sab.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-excessive-length-throws-sab.js
new file mode 100644
index 000000000..2549e93fd
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js]
+features: [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/butter-arg/buffer-arg-excessive-length-throws.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-excessive-length-throws.js
new file mode 100644
index 000000000..3ff3a6d61
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js]
+features: [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/butter-arg/buffer-arg-excessive-offset-throws-sab.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-excessive-offset-throws-sab.js
new file mode 100644
index 000000000..62cf41145
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js]
+features: [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/butter-arg/buffer-arg-excessive-offset-throws.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-excessive-offset-throws.js
new file mode 100644
index 000000000..5daf40ce7
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js]
+features: [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/butter-arg/buffer-arg-invoked-with-undefined-newtarget-sab.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-invoked-with-undefined-newtarget-sab.js
new file mode 100644
index 000000000..24061049a
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js]
+features: [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/butter-arg/buffer-arg-invoked-with-undefined-newtarget.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-invoked-with-undefined-newtarget.js
new file mode 100644
index 000000000..218b7c2c0
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var buffer = new ArrayBuffer(4);
+ assert.throws(TypeError, function() {
+ TA(buffer);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-is-referenced-sab.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-is-referenced-sab.js
new file mode 100644
index 000000000..44c29229c
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js]
+features: [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/butter-arg/buffer-arg-is-referenced.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-is-referenced.js
new file mode 100644
index 000000000..0154deaf4
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js]
+features: [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/butter-arg/buffer-arg-length-access-throws-sab.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-length-access-throws-sab.js
new file mode 100644
index 000000000..16872f860
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js]
+features: [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/butter-arg/buffer-arg-length-access-throws.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-length-access-throws.js
new file mode 100644
index 000000000..ea99b8b40
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js]
+features: [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/butter-arg/buffer-arg-length-is-symbol-throws-sab.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-length-is-symbol-throws-sab.js
new file mode 100644
index 000000000..8b77b806d
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js]
+features: [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/butter-arg/buffer-arg-length-is-symbol-throws.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-length-is-symbol-throws.js
new file mode 100644
index 000000000..db8ac8303
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js]
+features: [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/butter-arg/buffer-arg-length-to-number-detachbuffer.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-length-to-number-detachbuffer.js
new file mode 100644
index 000000000..c8c3eb34b
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js, detachArrayBuffer.js]
+features: [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/butter-arg/buffer-arg-new-instance-extensibility-sab.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-new-instance-extensibility-sab.js
new file mode 100644
index 000000000..2b765a78f
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js]
+features: [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/butter-arg/buffer-arg-new-instance-extensibility.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-new-instance-extensibility.js
new file mode 100644
index 000000000..74336215f
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js]
+features: [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/butter-arg/buffer-arg-proto-from-ctor-realm-sab.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-proto-from-ctor-realm-sab.js
new file mode 100644
index 000000000..9cab95b47
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js]
+features: [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/butter-arg/buffer-arg-proto-from-ctor-realm.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-proto-from-ctor-realm.js
new file mode 100644
index 000000000..d93538db4
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js]
+features: [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/butter-arg/buffer-arg-returns-new-instance-sab.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-returns-new-instance-sab.js
new file mode 100644
index 000000000..52de96252
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js]
+features: [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/butter-arg/buffer-arg-returns-new-instance.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-returns-new-instance.js
new file mode 100644
index 000000000..4723e75f9
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js]
+features: [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/butter-arg/buffer-arg-toindex-bytelength-sab.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-toindex-bytelength-sab.js
new file mode 100644
index 000000000..5fd87715f
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js]
+features: [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/butter-arg/buffer-arg-toindex-bytelength.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-toindex-bytelength.js
new file mode 100644
index 000000000..ae660b820
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js]
+features: [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/butter-arg/buffer-arg-toindex-byteoffset-sab.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-toindex-byteoffset-sab.js
new file mode 100644
index 000000000..43ae9f601
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js]
+features: [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/butter-arg/buffer-arg-toindex-byteoffset.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-toindex-byteoffset.js
new file mode 100644
index 000000000..35a087aaf
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js]
+features: [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/butter-arg/buffer-arg-typedarray-backed-by-sharedarraybuffer.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-typedarray-backed-by-sharedarraybuffer.js
new file mode 100644
index 000000000..739d1cdd2
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js]
+features: [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/butter-arg/buffer-arg-use-custom-proto-if-object-sab.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-use-custom-proto-if-object-sab.js
new file mode 100644
index 000000000..c963b6bb1
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js]
+features: [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/butter-arg/buffer-arg-use-custom-proto-if-object.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-use-custom-proto-if-object.js
new file mode 100644
index 000000000..9eefdf56d
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js]
+features: [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/butter-arg/buffer-arg-use-default-proto-if-custom-proto-is-not-object-sab.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-use-default-proto-if-custom-proto-is-not-object-sab.js
new file mode 100644
index 000000000..8c91aa84d
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js]
+features: [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/butter-arg/buffer-arg-use-default-proto-if-custom-proto-is-not-object.js b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/buffer-arg-use-default-proto-if-custom-proto-is-not-object.js
new file mode 100644
index 000000000..df4909dab
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/butter-arg/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: [testTypedArray.js]
+features: [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);
+});