summaryrefslogtreecommitdiff
path: root/test/built-ins/TypedArrays/ctors-bigint
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
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')
-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
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/length-arg/length-arg-custom-proto-access-throws.js43
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/length-arg/length-arg-init-zeros.js55
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/length-arg/length-arg-is-infinity-throws-rangeerror.js27
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/length-arg/length-arg-is-negative-integer-throws-rangeerror.js37
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/length-arg/length-arg-is-symbol-throws.js26
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/length-arg/length-arg-new-instance-extensibility.js38
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/length-arg/length-arg-proto-from-ctor-realm.js36
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/length-arg/length-arg-returns-object.js33
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/length-arg/length-arg-toindex-length.js53
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/length-arg/length-arg-undefined-newtarget-throws.js28
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/length-arg/length-arg-use-custom-proto-if-object.js44
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/length-arg/length-arg-use-default-proto-if-custom-proto-is-not-object.js43
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/no-args/no-args-custom-proto-access-throws.js43
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/no-args/no-args-new-instance-extensibility.js38
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/no-args/no-args-proto-from-ctor-realm.js36
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/no-args/no-args-returns-object.js32
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/no-args/no-args-undefined-newtarget-throws.js23
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/no-args/no-args-use-custom-proto-if-object.js44
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/no-args/no-args-use-default-proto-if-custom-proto-is-not-object.js43
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-as-array-returns.js28
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-as-generator-iterable-returns.js30
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-conversion-operation-consistent-nan.js60
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-conversion-operation.js52
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-custom-proto-access-throws.js48
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-iterating-throws.js31
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-iterator-not-callable-throws.js39
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-iterator-throws.js34
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-length-excessive-throws.js30
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-length-is-symbol-throws.js30
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-length-throws.js34
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-new-instance-extensibility.js43
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-proto-from-ctor-realm.js37
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-returns.js47
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-from-property.js40
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-obj-to-primitive-typeerror.js77
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-obj-to-primitive.js75
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-obj-tostring.js88
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-obj-valueof-typeerror.js89
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-obj-valueof.js82
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-property.js40
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-symbol-property.js34
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-undefined-newtarget-throws.js30
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-use-custom-proto-if-object.js47
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-use-default-proto-if-custom-proto-is-not-object.js47
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-custom-proto-access-throws.js47
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-detached-when-species-retrieved-different-type.js61
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-detached-when-species-retrieved-same-type.js64
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-new-instance-extensibility.js46
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-access-throws.js41
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-custom-species-proto-from-ctor-realm.js59
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-custom-species.js52
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-not-object-throws.js61
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-access-throws.js45
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-not-ctor-throws.js47
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-null.js44
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-prototype-throws.js59
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-undefined.js43
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-returns-new-typedarray.js32
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-proto-from-ctor-realm.js37
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-returns-new-instance.js31
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-access-throws.js46
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-custom-proto-from-ctor-realm.js68
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-custom.js60
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-not-ctor.js49
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-null.js49
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-prototype-throws.js62
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-throws.js49
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-undefined.js49
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-value-not-obj-throws.js65
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-returns-new-cloned-typedarray.js32
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-undefined-newtarget-throws.js27
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-use-custom-proto-if-object.js48
-rw-r--r--test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-use-default-proto-if-custom-proto-is-not-object.js47
125 files changed, 5247 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);
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/length-arg/length-arg-custom-proto-access-throws.js b/test/built-ins/TypedArrays/ctors-bigint/length-arg/length-arg-custom-proto-access-throws.js
new file mode 100644
index 000000000..6ad49fdab
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/length-arg/length-arg-custom-proto-access-throws.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-length
+description: >
+ Return abrupt completion getting newTarget's prototype
+info: |
+ 22.2.4.2 TypedArray ( length )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is not Object.
+
+ ...
+ 8. Return ? AllocateTypedArray(constructorName, NewTarget,
+ %TypedArrayPrototype%, elementLength).
+
+ 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 newTarget = function() {}.bind(null);
+Object.defineProperty(newTarget, "prototype", {
+ get() {
+ throw new Test262Error();
+ }
+});
+
+testWithTypedArrayConstructors(function(TA) {
+ assert.throws(Test262Error, function() {
+ Reflect.construct(TA, [1], newTarget);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/length-arg/length-arg-init-zeros.js b/test/built-ins/TypedArrays/ctors-bigint/length-arg/length-arg-init-zeros.js
new file mode 100644
index 000000000..384e2399b
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/length-arg/length-arg-init-zeros.js
@@ -0,0 +1,55 @@
+// 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-length
+description: All bytes are initialized to zero
+info: |
+ 22.2.4.2 TypedArray ( length )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is not Object.
+
+ ...
+ 8. Return ? AllocateTypedArray(constructorName, NewTarget,
+ %TypedArrayPrototype%, elementLength).
+
+ 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget,
+ defaultProto [ , length ])
+
+ 5. If length was not passed, then
+ ...
+ 6. Else,
+ a. Perform ? AllocateTypedArrayBuffer(obj, length).
+
+ 22.2.4.2.2 Runtime Semantics: AllocateTypedArrayBuffer
+
+ 7. Let data be ? AllocateArrayBuffer(%ArrayBuffer%, byteLength).
+
+ 24.1.1.1 AllocateArrayBuffer
+
+ 3. Let block be ? CreateByteDataBlock(byteLength).
+
+ 6.2.6.1 CreateByteDataBlock
+
+ 1. Assert: size≥0.
+ 2. Let db be a new Data Block value consisting of size bytes. If it is
+ impossible to create such a Data Block, throw a RangeError exception.
+ 3. Set all of the bytes of db to 0.
+ 4. Return db.
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA, N) {
+ var subject = new TA(9);
+
+ assert.sameValue(subject[0], N(0), 'index 0');
+ assert.sameValue(subject[1], N(0), 'index 1');
+ assert.sameValue(subject[2], N(0), 'index 2');
+ assert.sameValue(subject[3], N(0), 'index 3');
+ assert.sameValue(subject[4], N(0), 'index 4');
+ assert.sameValue(subject[5], N(0), 'index 5');
+ assert.sameValue(subject[6], N(0), 'index 6');
+ assert.sameValue(subject[7], N(0), 'index 7');
+ assert.sameValue(subject[8], N(0), 'index 8');
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/length-arg/length-arg-is-infinity-throws-rangeerror.js b/test/built-ins/TypedArrays/ctors-bigint/length-arg/length-arg-is-infinity-throws-rangeerror.js
new file mode 100644
index 000000000..0084d5d6a
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/length-arg/length-arg-is-infinity-throws-rangeerror.js
@@ -0,0 +1,27 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-length
+description: >
+ Throws a RangeError if length is a Infinity value
+info: |
+ 22.2.4.2 TypedArray ( length )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is not Object.
+
+ ...
+ 4. Let numberLength be ? ToNumber(length).
+ 5. Let elementLength be ToLength(numberLength).
+ 6. If SameValueZero(numberLength, elementLength) is false, throw a RangeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ assert.throws(RangeError, function() {
+ new TA(Infinity);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/length-arg/length-arg-is-negative-integer-throws-rangeerror.js b/test/built-ins/TypedArrays/ctors-bigint/length-arg/length-arg-is-negative-integer-throws-rangeerror.js
new file mode 100644
index 000000000..0ff5d5a3f
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/length-arg/length-arg-is-negative-integer-throws-rangeerror.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-length
+description: >
+ Throws a RangeError if ToInteger(length) is a negative value
+info: |
+ 22.2.4.2 TypedArray ( length )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is not Object.
+
+ ...
+ 3. Let elementLength be ? ToIndex(length).
+ ...
+
+ 7.1.17 ToIndex ( value )
+
+ 1. If value is undefined, then
+ ...
+ 2. Else,
+ a. Let integerIndex be ? ToInteger(value).
+ b. If integerIndex < 0, throw a RangeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ assert.throws(RangeError, function() {
+ new TA(-1);
+ });
+
+ assert.throws(RangeError, function() {
+ new TA(-Infinity);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/length-arg/length-arg-is-symbol-throws.js b/test/built-ins/TypedArrays/ctors-bigint/length-arg/length-arg-is-symbol-throws.js
new file mode 100644
index 000000000..797dd4922
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/length-arg/length-arg-is-symbol-throws.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-length
+description: >
+ If length is a Symbol, throw a TypeError exception.
+info: |
+ 22.2.4.2 TypedArray ( length )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is not Object.
+
+ ...
+ 4. Let numberLength be ? ToNumber(length).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var s = Symbol('1');
+
+testWithTypedArrayConstructors(function(TA) {
+ assert.throws(TypeError, function() {
+ new TA(s);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/length-arg/length-arg-new-instance-extensibility.js b/test/built-ins/TypedArrays/ctors-bigint/length-arg/length-arg-new-instance-extensibility.js
new file mode 100644
index 000000000..d9b03deca
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/length-arg/length-arg-new-instance-extensibility.js
@@ -0,0 +1,38 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-length
+description: >
+ The new typedArray instance from a length argument is extensible
+info: |
+ 22.2.4.2 TypedArray ( length )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is not Object.
+
+ ...
+ 8. Return ? AllocateTypedArray(constructorName, NewTarget,
+ %TypedArrayPrototype%, elementLength).
+
+ 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 sample = new TA(4);
+
+ assert(Object.isExtensible(sample));
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/length-arg/length-arg-proto-from-ctor-realm.js b/test/built-ins/TypedArrays/ctors-bigint/length-arg/length-arg-proto-from-ctor-realm.js
new file mode 100644
index 000000000..f4effc208
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/length-arg/length-arg-proto-from-ctor-realm.js
@@ -0,0 +1,36 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-length
+description: Default [[Prototype]] value derived from realm of the newTarget
+info: |
+ [...]
+ 8. Return ? AllocateTypedArray(constructorName, NewTarget,
+ "%TypedArrayPrototype%", elementLength).
+
+ 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, N) {
+ var ta = Reflect.construct(TA, [0], C);
+
+ assert.sameValue(Object.getPrototypeOf(ta), other[TA.name].prototype);
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/length-arg/length-arg-returns-object.js b/test/built-ins/TypedArrays/ctors-bigint/length-arg/length-arg-returns-object.js
new file mode 100644
index 000000000..8a9121d88
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/length-arg/length-arg-returns-object.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-length
+description: >
+ Return a TypedArray object
+info: |
+ 22.2.4.2 TypedArray ( length )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is not Object.
+
+ ...
+ 8. Return ? AllocateTypedArray(constructorName, NewTarget,
+ %TypedArrayPrototype%, elementLength).
+
+ 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget,
+ defaultProto [ , length ])
+
+ ...
+ 7. Return obj
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var typedArray = new TA(4);
+ var length = typedArray.length;
+
+ assert.sameValue(length, 4, "length");
+ assert.sameValue(typedArray.constructor, TA);
+ assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype);
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/length-arg/length-arg-toindex-length.js b/test/built-ins/TypedArrays/ctors-bigint/length-arg/length-arg-toindex-length.js
new file mode 100644
index 000000000..4d16ff711
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/length-arg/length-arg-toindex-length.js
@@ -0,0 +1,53 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-length
+description: >
+ ToIndex(length) operations
+info: |
+ 22.2.4.2 TypedArray ( length )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is not Object.
+
+ ...
+ 3. Let elementLength be ? ToIndex(length).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var items = [
+ [-0, 0, "-0"],
+ ["", 0, "the Empty string"],
+ ["0", 0, "string '0'"],
+ ["1", 1, "string '1'"],
+ [true, 1, "true"],
+ [false, 0, "false"],
+ [NaN, 0, "NaN"],
+ [null, 0, "null"],
+ [undefined, 0, "undefined"],
+ [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(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/length-arg/length-arg-undefined-newtarget-throws.js b/test/built-ins/TypedArrays/ctors-bigint/length-arg/length-arg-undefined-newtarget-throws.js
new file mode 100644
index 000000000..6a238255e
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/length-arg/length-arg-undefined-newtarget-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-length
+description: >
+ Throws a TypeError if NewTarget is undefined.
+info: |
+ 22.2.4.2 TypedArray ( length )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is not Object.
+
+ ...
+ 2. If NewTarget is undefined, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ assert.throws(TypeError, function() {
+ TA(0);
+ });
+
+ assert.throws(TypeError, function() {
+ TA(Infinity);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/length-arg/length-arg-use-custom-proto-if-object.js b/test/built-ins/TypedArrays/ctors-bigint/length-arg/length-arg-use-custom-proto-if-object.js
new file mode 100644
index 000000000..b36ff7014
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/length-arg/length-arg-use-custom-proto-if-object.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-length
+description: >
+ Use prototype from new target if it's an Object
+info: |
+ 22.2.4.2 TypedArray ( length )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is not Object.
+
+ ...
+ 8. Return ? AllocateTypedArray(constructorName, NewTarget,
+ %TypedArrayPrototype%, elementLength).
+
+ 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]
+---*/
+
+function newTarget() {}
+var proto = {};
+newTarget.prototype = proto;
+
+testWithTypedArrayConstructors(function(TA) {
+ var ta = Reflect.construct(TA, [1], newTarget);
+
+ assert.sameValue(ta.constructor, Object);
+ assert.sameValue(Object.getPrototypeOf(ta), proto);
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/length-arg/length-arg-use-default-proto-if-custom-proto-is-not-object.js b/test/built-ins/TypedArrays/ctors-bigint/length-arg/length-arg-use-default-proto-if-custom-proto-is-not-object.js
new file mode 100644
index 000000000..e5fc367c0
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/length-arg/length-arg-use-default-proto-if-custom-proto-is-not-object.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-length
+description: >
+ Use prototype from %TypedArray% if newTarget's prototype is not an Object
+info: |
+ 22.2.4.2 TypedArray ( length )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is not Object.
+
+ ...
+ 8. Return ? AllocateTypedArray(constructorName, NewTarget,
+ %TypedArrayPrototype%, elementLength).
+
+ 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]
+---*/
+
+function newTarget() {}
+newTarget.prototype = null;
+
+testWithTypedArrayConstructors(function(TA) {
+ var ta = Reflect.construct(TA, [1], newTarget);
+
+ assert.sameValue(ta.constructor, TA);
+ assert.sameValue(Object.getPrototypeOf(ta), TA.prototype);
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/no-args/no-args-custom-proto-access-throws.js b/test/built-ins/TypedArrays/ctors-bigint/no-args/no-args-custom-proto-access-throws.js
new file mode 100644
index 000000000..6b383e32e
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/no-args/no-args-custom-proto-access-throws.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray
+description: >
+ Return abrupt completion getting newTarget's prototype
+info: |
+ 22.2.4.1 TypedArray( )
+
+ This description applies only if the TypedArray function is called with no
+ arguments.
+
+ ...
+ 3. Return ? AllocateTypedArray(constructorName, NewTarget,
+ %TypedArrayPrototype%, 0).
+
+ 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 newTarget = function() {}.bind(null);
+Object.defineProperty(newTarget, "prototype", {
+ get() {
+ throw new Test262Error();
+ }
+});
+
+testWithTypedArrayConstructors(function(TA) {
+ assert.throws(Test262Error, function() {
+ Reflect.construct(TA, [], newTarget);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/no-args/no-args-new-instance-extensibility.js b/test/built-ins/TypedArrays/ctors-bigint/no-args/no-args-new-instance-extensibility.js
new file mode 100644
index 000000000..cced58d2e
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/no-args/no-args-new-instance-extensibility.js
@@ -0,0 +1,38 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray
+description: >
+ The new typedArray instance is extensible
+info: |
+ 22.2.4.1 TypedArray( )
+
+ This description applies only if the TypedArray function is called with no
+ arguments.
+
+ ...
+ 3. Return ? AllocateTypedArray(constructorName, NewTarget,
+ %TypedArrayPrototype%, 0).
+
+ 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 sample = new TA();
+
+ assert(Object.isExtensible(sample));
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/no-args/no-args-proto-from-ctor-realm.js b/test/built-ins/TypedArrays/ctors-bigint/no-args/no-args-proto-from-ctor-realm.js
new file mode 100644
index 000000000..c69922185
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/no-args/no-args-proto-from-ctor-realm.js
@@ -0,0 +1,36 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray
+description: Default [[Prototype]] value derived from realm of the newTarget
+info: |
+ [...]
+ 3. Return ? AllocateTypedArray(constructorName, NewTarget,
+ "%TypedArrayPrototype%", 0).
+
+ 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, [], C);
+
+ assert.sameValue(Object.getPrototypeOf(ta), other[TA.name].prototype);
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/no-args/no-args-returns-object.js b/test/built-ins/TypedArrays/ctors-bigint/no-args/no-args-returns-object.js
new file mode 100644
index 000000000..c7274e5f9
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/no-args/no-args-returns-object.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
+description: >
+ Return a TypedArray object
+info: |
+ 22.2.4.1 TypedArray( )
+
+ This description applies only if the TypedArray function is called with no
+ arguments.
+
+ ...
+ 3. Return ? AllocateTypedArray(constructorName, NewTarget,
+ %TypedArrayPrototype%, 0).
+
+ 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget,
+ defaultProto [ , length ])
+
+ ...
+ 7. Return obj
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var typedArray = new TA();
+
+ assert.sameValue(typedArray.length, 0);
+ assert.sameValue(typedArray.constructor, TA);
+ assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype);
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/no-args/no-args-undefined-newtarget-throws.js b/test/built-ins/TypedArrays/ctors-bigint/no-args/no-args-undefined-newtarget-throws.js
new file mode 100644
index 000000000..a06139865
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/no-args/no-args-undefined-newtarget-throws.js
@@ -0,0 +1,23 @@
+// 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
+description: >
+ Throws a TypeError if NewTarget is undefined.
+info: |
+ 22.2.4.1 TypedArray( )
+
+ This description applies only if the TypedArray function is called with no
+ arguments.
+
+ 1. If NewTarget is undefined, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ assert.throws(TypeError, function() {
+ TA();
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/no-args/no-args-use-custom-proto-if-object.js b/test/built-ins/TypedArrays/ctors-bigint/no-args/no-args-use-custom-proto-if-object.js
new file mode 100644
index 000000000..4266724f0
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/no-args/no-args-use-custom-proto-if-object.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray
+description: >
+ Use prototype from new target if it's an Object
+info: |
+ 22.2.4.1 TypedArray( )
+
+ This description applies only if the TypedArray function is called with no
+ arguments.
+
+ ...
+ 3. Return ? AllocateTypedArray(constructorName, NewTarget,
+ %TypedArrayPrototype%, 0).
+
+ 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]
+---*/
+
+function newTarget() {}
+var proto = {};
+newTarget.prototype = proto;
+
+testWithTypedArrayConstructors(function(TA) {
+ var ta = Reflect.construct(TA, [], newTarget);
+
+ assert.sameValue(ta.constructor, Object);
+ assert.sameValue(Object.getPrototypeOf(ta), proto);
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/no-args/no-args-use-default-proto-if-custom-proto-is-not-object.js b/test/built-ins/TypedArrays/ctors-bigint/no-args/no-args-use-default-proto-if-custom-proto-is-not-object.js
new file mode 100644
index 000000000..e76ef585e
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/no-args/no-args-use-default-proto-if-custom-proto-is-not-object.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray
+description: >
+ Use prototype from %TypedArray% if newTarget's prototype is not an Object
+info: |
+ 22.2.4.1 TypedArray( )
+
+ This description applies only if the TypedArray function is called with no
+ arguments.
+
+ ...
+ 3. Return ? AllocateTypedArray(constructorName, NewTarget,
+ %TypedArrayPrototype%, 0).
+
+ 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]
+---*/
+
+function newTarget() {}
+newTarget.prototype = null;
+
+testWithTypedArrayConstructors(function(TA) {
+ var ta = Reflect.construct(TA, [], newTarget);
+
+ assert.sameValue(ta.constructor, TA);
+ assert.sameValue(Object.getPrototypeOf(ta), TA.prototype);
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-as-array-returns.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-as-array-returns.js
new file mode 100644
index 000000000..6e15b4ea4
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-as-array-returns.js
@@ -0,0 +1,28 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-object
+description: >
+ Return typedArray from array argument
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var obj = [7, 42];
+
+testWithTypedArrayConstructors(function(TA, N) {
+ var typedArray = new TA(N(obj));
+ assert.sameValue(typedArray.length, 2);
+ assert.sameValue(typedArray[0], N(7));
+ assert.sameValue(typedArray[1], N(42));
+ assert.sameValue(typedArray.constructor, TA);
+ assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype);
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-as-generator-iterable-returns.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-as-generator-iterable-returns.js
new file mode 100644
index 000000000..7e2876294
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-as-generator-iterable-returns.js
@@ -0,0 +1,30 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-object
+description: >
+ Return typedArray from iterable argument
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA, N) {
+ var obj = (function *() {
+ yield N(7); yield N(42);
+ })();
+
+ var typedArray = new TA(obj);
+ assert.sameValue(typedArray.length, 2);
+ assert.sameValue(typedArray[0], N(7));
+ assert.sameValue(typedArray[1], N(42));
+ assert.sameValue(typedArray.constructor, TA);
+ assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype);
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-conversion-operation-consistent-nan.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-conversion-operation-consistent-nan.js
new file mode 100644
index 000000000..a81d4c504
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-conversion-operation-consistent-nan.js
@@ -0,0 +1,60 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-object
+description: Consistent canonicalization of NaN values
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 9. Repeat, while k < len
+ ...
+ c. Perform ? Set(O, Pk, kValue, true).
+ ...
+
+ 9.4.5.9 IntegerIndexedElementSet ( O, index, value )
+
+ ...
+ 15. Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue).
+ ...
+
+ 24.1.1.6 SetValueInBuffer ( arrayBuffer, byteIndex, type, value [ ,
+ isLittleEndian ] )
+
+ ...
+ 8. If type is "Float32", then
+ a. Set rawBytes to a List containing the 4 bytes that are the result
+ of converting value to IEEE 754-2008 binary32 format using “Round to
+ nearest, ties to even” rounding mode. If isLittleEndian is false, the
+ bytes are arranged in big endian order. Otherwise, the bytes are
+ arranged in little endian order. If value is NaN, rawValue may be set
+ to any implementation chosen IEEE 754-2008 binary64 format Not-a-Number
+ encoding. An implementation must always choose the same encoding for
+ each implementation distinguishable NaN value.
+ 9. Else, if type is "Float64", then
+ a. Set rawBytes to a List containing the 8 bytes that are the IEEE
+ 754-2008 binary64 format encoding of value. If isLittleEndian is false,
+ the bytes are arranged in big endian order. Otherwise, the bytes are
+ arranged in little endian order. If value is NaN, rawValue may be set
+ to any implementation chosen IEEE 754-2008 binary32 format Not-a-Number
+ encoding. An implementation must always choose the same encoding for
+ each implementation distinguishable NaN value.
+ ...
+includes: [nans.js, testTypedArray.js, compareArray.js]
+---*/
+
+function body(FloatArray) {
+ var first = new FloatArray(distinctNaNs);
+ var second = new FloatArray(distinctNaNs);
+ var firstBytes = new Uint8Array(first.buffer);
+ var secondBytes = new Uint8Array(second.buffer);
+
+ assert(compareArray(firstBytes, secondBytes));
+}
+
+testWithTypedArrayConstructors(body, [Float32Array, Float64Array]);
diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-conversion-operation.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-conversion-operation.js
new file mode 100644
index 000000000..d14a14023
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-conversion-operation.js
@@ -0,0 +1,52 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-typedarray-object
+description: >
+ Verify conversion values on returned instance
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 9. Repeat, while k < len
+ ...
+ c. Perform ? Set(O, Pk, kValue, true).
+ ...
+
+ 9.4.5.9 IntegerIndexedElementSet ( O, index, value )
+
+ ...
+ 15. Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue).
+ ...
+
+ 24.1.1.6 SetValueInBuffer ( arrayBuffer, byteIndex, type, value [ ,
+ isLittleEndian ] )
+
+ ...
+ 8. If type is "Float32", then
+ ...
+ 9. Else, if type is "Float64", then
+ ...
+ 10. Else,
+ ...
+ b. Let convOp be the abstract operation named in the Conversion Operation
+ column in Table 50 for Element Type type.
+ c. Let intValue be convOp(value).
+ d. If intValue ≥ 0, then
+ ...
+ e. Else,
+ ...
+includes: [byteConversionValues.js, testTypedArray.js]
+---*/
+
+testTypedArrayConversions(byteConversionValues, function(TA, value, expected) {
+ var sample = new TA([value]);
+
+ assert.sameValue(sample[0], expected, value + " converts to " + expected);
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-custom-proto-access-throws.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-custom-proto-access-throws.js
new file mode 100644
index 000000000..f5ced4ea4
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-custom-proto-access-throws.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-object
+description: >
+ Return abrupt completion getting newTarget's prototype
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 3. Let O be ? AllocateTypedArray(TypedArray.[[TypedArrayConstructorName]],
+ NewTarget, "%TypedArrayPrototype%").
+ ...
+
+ 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget,
+ defaultProto [ , length ])
+
+ 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto).
+ ...
+
+ 9.1.15 GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto )
+
+ ...
+ 3. Let proto be ? Get(constructor, "prototype").
+ ...
+includes: [testTypedArray.js]
+features: [Reflect, TypedArray]
+---*/
+
+var newTarget = function() {}.bind(null);
+Object.defineProperty(newTarget, "prototype", {
+ get() {
+ throw new Test262Error();
+ }
+});
+
+var o = {};
+
+testWithTypedArrayConstructors(function(TA) {
+ assert.throws(Test262Error, function() {
+ Reflect.construct(TA, [o], newTarget);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-iterating-throws.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-iterating-throws.js
new file mode 100644
index 000000000..41fc55509
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-iterating-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-object
+description: >
+ Return abrupt from iterating object argument
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 4. Let arrayLike be ? IterableToArrayLike(object).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var obj = (function *() {
+ yield 0;
+ throw new Test262Error();
+ })();
+
+ assert.throws(Test262Error, function() {
+ new TA(obj);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-iterator-not-callable-throws.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-iterator-not-callable-throws.js
new file mode 100644
index 000000000..ad6db0877
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-iterator-not-callable-throws.js
@@ -0,0 +1,39 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-object
+description: >
+ Return abrupt when object @@iterator is not callable
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 4. Let arrayLike be ? IterableToArrayLike(object).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.iterator, TypedArray]
+---*/
+
+var obj = function () {};
+
+testWithTypedArrayConstructors(function(TA) {
+ obj[Symbol.iterator] = {};
+ assert.throws(TypeError, function() {
+ new TA(obj);
+ });
+
+ obj[Symbol.iterator] = true;
+ assert.throws(TypeError, function() {
+ new TA(obj);
+ });
+
+ obj[Symbol.iterator] = 42;
+ assert.throws(TypeError, function() {
+ new TA(obj);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-iterator-throws.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-iterator-throws.js
new file mode 100644
index 000000000..571ad77ad
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-iterator-throws.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-object
+description: >
+ Return abrupt from getting object @@iterator
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 4. Let arrayLike be ? IterableToArrayLike(object).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.iterator, TypedArray]
+---*/
+
+var obj = function () {};
+
+Object.defineProperty(obj, Symbol.iterator, {
+ get() {
+ throw new Test262Error();
+ }
+});
+
+testWithTypedArrayConstructors(function(TA) {
+ assert.throws(Test262Error, function() {
+ new TA(obj);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-length-excessive-throws.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-length-excessive-throws.js
new file mode 100644
index 000000000..f8279f50a
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-length-excessive-throws.js
@@ -0,0 +1,30 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-object
+description: >
+ Return abrupt from allocating array buffer with excessive length
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 6. Perform ? AllocateTypedArrayBuffer(O, len).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var obj = {
+ length: Math.pow(2, 53)
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ assert.throws(RangeError, function() {
+ new TA(obj);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-length-is-symbol-throws.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-length-is-symbol-throws.js
new file mode 100644
index 000000000..b452dea03
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-length-is-symbol-throws.js
@@ -0,0 +1,30 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-object
+description: >
+ Return abrupt from length property as a Symbol on the object argument
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 5. Let len be ? ToLength(? Get(arrayLike, "length")).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var obj = {
+ length: Symbol("1")
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ assert.throws(TypeError, function() {
+ new TA(obj);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-length-throws.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-length-throws.js
new file mode 100644
index 000000000..08f8cd130
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-length-throws.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-object
+description: >
+ Return abrupt from getting length property on the object argument
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 5. Let len be ? ToLength(? Get(arrayLike, "length")).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var obj = {};
+
+Object.defineProperty(obj, "length", {
+ get() {
+ throw new Test262Error();
+ }
+});
+
+testWithTypedArrayConstructors(function(TA) {
+ assert.throws(Test262Error, function() {
+ new TA(obj);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-new-instance-extensibility.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-new-instance-extensibility.js
new file mode 100644
index 000000000..bd335774b
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-new-instance-extensibility.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-object
+description: >
+ The new typedArray instance from an object argument is extensible
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ ...
+ 4. Let O be ? AllocateTypedArray(constructorName, NewTarget,
+ "%TypedArrayPrototype%").
+ ...
+
+ 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget,
+ defaultProto [ , length ])
+
+ ...
+ 2. Let obj be IntegerIndexedObjectCreate(proto, « [[ViewedArrayBuffer]],
+ [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]] »).
+ ...
+
+ 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList)
+
+ ...
+ 11. Set the [[Extensible]] internal slot of A to true.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA, N) {
+ var obj = {
+ "0": N(0),
+ "1": N(1),
+ "2": N(2),
+ length: 3
+ };
+
+ var sample = new TA(obj);
+
+ assert(Object.isExtensible(sample));
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-proto-from-ctor-realm.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-proto-from-ctor-realm.js
new file mode 100644
index 000000000..a92ceee00
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-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-object
+description: Default [[Prototype]] value derived from realm of the newTarget
+info: |
+ [...]
+ 4. Let O be ? AllocateTypedArray(constructorName, NewTarget,
+ "%TypedArrayPrototype%").
+ [...]
+
+ 22.2.4.2.1 Runtime Semantics: AllocateTypedArray
+
+ 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto).
+ [...]
+
+ 9.1.14 GetPrototypeFromConstructor
+
+ [...]
+ 3. Let proto be ? Get(constructor, "prototype").
+ 4. If Type(proto) is not Object, then
+ a. Let realm be ? GetFunctionRealm(constructor).
+ b. Let proto be realm's intrinsic object named intrinsicDefaultProto.
+ 5. Return proto.
+includes: [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, [{}], C);
+
+ assert.sameValue(Object.getPrototypeOf(ta), other[TA.name].prototype);
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-returns.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-returns.js
new file mode 100644
index 000000000..cb06ba220
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-returns.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-object
+description: >
+ Return typedArray from object argument
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var obj = {
+ "0": null,
+ "2": 42,
+ "3": "7",
+ "4": NaN,
+ "5": Symbol("1"),
+ length: 5
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var typedArray = new TA(obj);
+ assert.sameValue(typedArray.length, 5);
+ assert.sameValue(typedArray[0], 0);
+ assert.sameValue(typedArray[2], 42);
+ assert.sameValue(typedArray[3], 7);
+ assert.sameValue(typedArray[5], undefined);
+ assert.sameValue(typedArray.constructor, TA);
+ assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype);
+
+ if (TA === Float32Array || TA === Float64Array) {
+ assert.sameValue(typedArray[1], NaN);
+ assert.sameValue(typedArray[4], NaN);
+ } else {
+ assert.sameValue(typedArray[1], 0);
+ assert.sameValue(typedArray[4], 0);
+ }
+},
+ // Cannot create Big*64Arrays from non-safe integers.
+ numericTypedArrayConstructors);
diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-from-property.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-from-property.js
new file mode 100644
index 000000000..4a0d60825
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-from-property.js
@@ -0,0 +1,40 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-object
+description: >
+ Return abrupt from getting object property
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ b. Let kValue be ? Get(arrayLike, Pk).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var obj = {
+ length: 4
+};
+
+Object.defineProperty(obj, "2", {
+ get() {
+ throw new Test262Error();
+ }
+});
+
+testWithTypedArrayConstructors(function(TA, N) {
+ obj[0] = N(0);
+ obj[1] = N(0);
+ assert.throws(Test262Error, function() {
+ new TA(obj);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-obj-to-primitive-typeerror.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-obj-to-primitive-typeerror.js
new file mode 100644
index 000000000..3aee05e56
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-obj-to-primitive-typeerror.js
@@ -0,0 +1,77 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-object
+description: >
+ Throw TypeError from @@toPrimitive returning an Object when setting a property
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ b. Let kValue be ? Get(arrayLike, Pk).
+ c. Perform ? Set(O, Pk, kValue, true).
+ ...
+
+ 9.4.5.5 [[Set]] ( P, V, Receiver)
+
+ ...
+ 2. If Type(P) is String and if SameValue(O, Receiver) is true, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ i. Return ? IntegerIndexedElementSet(O, numericIndex, V).
+ ...
+
+ 9.4.5.9 IntegerIndexedElementSet ( O, index, value )
+
+ ...
+ 3. Let numValue be ? ToNumber(value).
+ ...
+
+ 7.1.3 ToNumber ( argument )
+
+ Object, Apply the following steps:
+
+ 1. Let primValue be ? ToPrimitive(argument, hint Number).
+ 2. Return ? ToNumber(primValue).
+
+ 7.1.1 ToPrimitive ( input [ , PreferredType ] )
+
+ ...
+ 4. Let exoticToPrim be ? GetMethod(input, @@toPrimitive).
+ 5. If exoticToPrim is not undefined, then
+ a. Let result be ? Call(exoticToPrim, input, « hint »).
+ b. If Type(result) is not Object, return result.
+ c. Throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.toPrimitive, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA, N) {
+ var sample = new Int8Array(1);
+ var toPrimitive = 0;
+ var valueOf = 0;
+
+ sample[Symbol.toPrimitive] = function() {
+ toPrimitive++;
+ return {};
+ };
+
+ sample.valueOf = function() {
+ valueOf++;
+ };
+
+ assert.throws(TypeError, function() {
+ new TA([N(8), sample]);
+ }, "abrupt completion from sample @@toPrimitive");
+
+ assert.sameValue(toPrimitive, 1, "toPrimitive was called once");
+ assert.sameValue(valueOf, 0, "sample.valueOf is not called");
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-obj-to-primitive.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-obj-to-primitive.js
new file mode 100644
index 000000000..516586863
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-obj-to-primitive.js
@@ -0,0 +1,75 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-object
+description: >
+ Return abrupt from @@toPrimitive when setting a property
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ b. Let kValue be ? Get(arrayLike, Pk).
+ c. Perform ? Set(O, Pk, kValue, true).
+ ...
+
+ 9.4.5.5 [[Set]] ( P, V, Receiver)
+
+ ...
+ 2. If Type(P) is String and if SameValue(O, Receiver) is true, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ i. Return ? IntegerIndexedElementSet(O, numericIndex, V).
+ ...
+
+ 9.4.5.9 IntegerIndexedElementSet ( O, index, value )
+
+ ...
+ 3. Let numValue be ? ToNumber(value).
+ ...
+
+ 7.1.3 ToNumber ( argument )
+
+ Object, Apply the following steps:
+
+ 1. Let primValue be ? ToPrimitive(argument, hint Number).
+ 2. Return ? ToNumber(primValue).
+
+ 7.1.1 ToPrimitive ( input [ , PreferredType ] )
+
+ ...
+ 4. Let exoticToPrim be ? GetMethod(input, @@toPrimitive).
+ 5. If exoticToPrim is not undefined, then
+ a. Let result be ? Call(exoticToPrim, input, « hint »).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.toPrimitive, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA, N) {
+ var sample = new Int8Array(1);
+ var toPrimitive = 0;
+ var valueOf = 0;
+
+ sample[Symbol.toPrimitive] = function() {
+ toPrimitive++;
+ throw new Test262Error();
+ };
+
+ sample.valueOf = function() {
+ valueOf++;
+ };
+
+ assert.throws(Test262Error, function() {
+ new TA([N(8), sample]);
+ }, "abrupt completion from sample @@toPrimitive");
+
+ assert.sameValue(toPrimitive, 1, "toPrimitive was called once");
+ assert.sameValue(valueOf, 0, "it does not call sample.valueOf");
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-obj-tostring.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-obj-tostring.js
new file mode 100644
index 000000000..3e2d84e75
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-obj-tostring.js
@@ -0,0 +1,88 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-object
+description: >
+ Return abrupt from toString() when setting a property
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ b. Let kValue be ? Get(arrayLike, Pk).
+ c. Perform ? Set(O, Pk, kValue, true).
+ ...
+
+ 9.4.5.5 [[Set]] ( P, V, Receiver)
+
+ ...
+ 2. If Type(P) is String and if SameValue(O, Receiver) is true, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ i. Return ? IntegerIndexedElementSet(O, numericIndex, V).
+ ...
+
+ 9.4.5.9 IntegerIndexedElementSet ( O, index, value )
+
+ ...
+ 3. Let numValue be ? ToNumber(value).
+ ...
+
+ 7.1.3 ToNumber ( argument )
+
+ Object, Apply the following steps:
+
+ 1. Let primValue be ? ToPrimitive(argument, hint Number).
+ 2. Return ? ToNumber(primValue).
+
+ 7.1.1 ToPrimitive ( input [ , PreferredType ] )
+
+ ...
+ 4. Let exoticToPrim be ? GetMethod(input, @@toPrimitive).
+ 5. If exoticToPrim is not undefined, then
+ a. Let result be ? Call(exoticToPrim, input, « hint »).
+ b. If Type(result) is not Object, return result.
+ c. Throw a TypeError exception.
+ ...
+ 7. Return ? OrdinaryToPrimitive(input, hint).
+
+ OrdinaryToPrimitive
+
+ ...
+ 5. For each name in methodNames in List order, do
+ a. Let method be ? Get(O, name).
+ b. If IsCallable(method) is true, then
+ i. Let result be ? Call(method, O).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA, N) {
+ var sample = new Int8Array(1);
+ var valueOf = 0;
+ var toString = 0;
+
+ sample.valueOf = function() {
+ valueOf++;
+ return {};
+ };
+
+ sample.toString = function() {
+ toString++;
+ throw new Test262Error();
+ };
+
+ assert.throws(Test262Error, function() {
+ new TA([N(8), sample]);
+ }, "abrupt completion from ToNumber(sample)");
+
+ assert.sameValue(valueOf, 1, "valueOf called once");
+ assert.sameValue(toString, 1, "toString called once");
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-obj-valueof-typeerror.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-obj-valueof-typeerror.js
new file mode 100644
index 000000000..c58fe2425
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-obj-valueof-typeerror.js
@@ -0,0 +1,89 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-object
+description: >
+ Throw TypeError from OrdinaryToPrimitive when setting a property
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ b. Let kValue be ? Get(arrayLike, Pk).
+ c. Perform ? Set(O, Pk, kValue, true).
+ ...
+
+ 9.4.5.5 [[Set]] ( P, V, Receiver)
+
+ ...
+ 2. If Type(P) is String and if SameValue(O, Receiver) is true, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ i. Return ? IntegerIndexedElementSet(O, numericIndex, V).
+ ...
+
+ 9.4.5.9 IntegerIndexedElementSet ( O, index, value )
+
+ ...
+ 3. Let numValue be ? ToNumber(value).
+ ...
+
+ 7.1.3 ToNumber ( argument )
+
+ Object, Apply the following steps:
+
+ 1. Let primValue be ? ToPrimitive(argument, hint Number).
+ 2. Return ? ToNumber(primValue).
+
+ 7.1.1 ToPrimitive ( input [ , PreferredType ] )
+
+ ...
+ 4. Let exoticToPrim be ? GetMethod(input, @@toPrimitive).
+ 5. If exoticToPrim is not undefined, then
+ a. Let result be ? Call(exoticToPrim, input, « hint »).
+ b. If Type(result) is not Object, return result.
+ c. Throw a TypeError exception.
+ ...
+ 7. Return ? OrdinaryToPrimitive(input, hint).
+
+ OrdinaryToPrimitive
+
+ ...
+ 5. For each name in methodNames in List order, do
+ a. Let method be ? Get(O, name).
+ b. If IsCallable(method) is true, then
+ i. Let result be ? Call(method, O).
+ ii. If Type(result) is not Object, return result.
+ 6. Throw a TypeError exception.
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA, N) {
+ var sample = new Int8Array(1);
+ var valueOf = 0;
+ var toString = 0;
+
+ sample.valueOf = function() {
+ valueOf++;
+ return {};
+ };
+
+ sample.toString = function() {
+ toString++;
+ return {};
+ };
+
+ assert.throws(TypeError, function() {
+ new TA([N(8), sample]);
+ }, "abrupt completion from ToNumber(sample)");
+
+ assert.sameValue(valueOf, 1, "valueOf called once");
+ assert.sameValue(toString, 1, "toString called once");
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-obj-valueof.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-obj-valueof.js
new file mode 100644
index 000000000..ae4515f34
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-obj-valueof.js
@@ -0,0 +1,82 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-object
+description: >
+ Return abrupt from valueOf() when setting a property
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ b. Let kValue be ? Get(arrayLike, Pk).
+ c. Perform ? Set(O, Pk, kValue, true).
+ ...
+
+ 9.4.5.5 [[Set]] ( P, V, Receiver)
+
+ ...
+ 2. If Type(P) is String and if SameValue(O, Receiver) is true, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ i. Return ? IntegerIndexedElementSet(O, numericIndex, V).
+ ...
+
+ 9.4.5.9 IntegerIndexedElementSet ( O, index, value )
+
+ ...
+ 3. Let numValue be ? ToNumber(value).
+ ...
+
+ 7.1.3 ToNumber ( argument )
+
+ Object, Apply the following steps:
+
+ 1. Let primValue be ? ToPrimitive(argument, hint Number).
+ 2. Return ? ToNumber(primValue).
+
+ 7.1.1 ToPrimitive ( input [ , PreferredType ] )
+
+ ...
+ 4. Let exoticToPrim be ? GetMethod(input, @@toPrimitive).
+ 5. If exoticToPrim is not undefined, then
+ a. Let result be ? Call(exoticToPrim, input, « hint »).
+ b. If Type(result) is not Object, return result.
+ c. Throw a TypeError exception.
+ ...
+ 7. Return ? OrdinaryToPrimitive(input, hint).
+
+ OrdinaryToPrimitive
+
+ ...
+ 5. For each name in methodNames in List order, do
+ a. Let method be ? Get(O, name).
+ b. If IsCallable(method) is true, then
+ i. Let result be ? Call(method, O).
+ ii. If Type(result) is not Object, return result.
+ 6. Throw a TypeError exception.
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA, N) {
+ var sample = new Int8Array(1);
+ var valueOf = 0;
+
+ sample.valueOf = function() {
+ valueOf++;
+ throw new Test262Error();
+ };
+
+ assert.throws(Test262Error, function() {
+ new TA([N(8), sample]);
+ }, "abrupt completion from ToNumber(sample)");
+
+ assert.sameValue(valueOf, 1, "valueOf called once");
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-property.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-property.js
new file mode 100644
index 000000000..489234c90
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-property.js
@@ -0,0 +1,40 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-object
+description: >
+ Return abrupt from setting property
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ b. Let kValue be ? Get(arrayLike, Pk).
+ c. Perform ? Set(O, Pk, kValue, true).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var obj = {
+ "2": {
+ valueOf() {
+ throw new Test262Error();
+ }
+ },
+ length: 4
+};
+
+testWithTypedArrayConstructors(function(TA, N) {
+ obj[0] = N(0);
+ obj[1] = N(0);
+ assert.throws(Test262Error, function() {
+ new TA(obj);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-symbol-property.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-symbol-property.js
new file mode 100644
index 000000000..42b4a54b8
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-symbol-property.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-object
+description: >
+ Return abrupt from setting property
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ b. Let kValue be ? Get(arrayLike, Pk).
+ c. Perform ? Set(O, Pk, kValue, true).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var obj = {
+ "2": Symbol("1"),
+ length: 4
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ assert.throws(TypeError, function() {
+ new TA(obj);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-undefined-newtarget-throws.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-undefined-newtarget-throws.js
new file mode 100644
index 000000000..36f68493a
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-undefined-newtarget-throws.js
@@ -0,0 +1,30 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-object
+description: >
+ Throws a TypeError if NewTarget is undefined.
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 2. If NewTarget is undefined, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ assert.throws(TypeError, function() {
+ TA({});
+ });
+
+ assert.throws(TypeError, function() {
+ TA([]);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-use-custom-proto-if-object.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-use-custom-proto-if-object.js
new file mode 100644
index 000000000..bb5754a9c
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-use-custom-proto-if-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-object
+description: >
+ Use prototype from new target if it's an Object
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 3. Let O be ? AllocateTypedArray(TypedArray.[[TypedArrayConstructorName]],
+ NewTarget, "%TypedArrayPrototype%").
+ ...
+
+ 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget,
+ defaultProto [ , length ])
+
+ 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto).
+ 2. Let obj be IntegerIndexedObjectCreate (proto, «[[ViewedArrayBuffer]],
+ [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]]» ).
+ ...
+
+ 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList)
+
+ ...
+ 10. Set the [[Prototype]] internal slot of A to prototype.
+ ...
+ 12. Return A.
+includes: [testTypedArray.js]
+features: [Reflect, TypedArray]
+---*/
+
+function newTarget() {}
+var proto = {};
+newTarget.prototype = proto;
+
+testWithTypedArrayConstructors(function(TA) {
+ var ta = Reflect.construct(TA, [], newTarget);
+
+ assert.sameValue(ta.constructor, Object);
+ assert.sameValue(Object.getPrototypeOf(ta), proto);
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-use-default-proto-if-custom-proto-is-not-object.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-use-default-proto-if-custom-proto-is-not-object.js
new file mode 100644
index 000000000..6aba187c2
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-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-object
+description: >
+ Use prototype from %TypedArray% if newTarget's prototype is not an Object
+info: |
+ 22.2.4.4 TypedArray ( object )
+
+ This description applies only if the TypedArray function is called with at
+ least one argument and the Type of the first argument is Object and that
+ object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]]
+ internal slot.
+
+ ...
+ 3. Let O be ? AllocateTypedArray(TypedArray.[[TypedArrayConstructorName]],
+ NewTarget, "%TypedArrayPrototype%").
+ ...
+
+ 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget,
+ defaultProto [ , length ])
+
+ 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto).
+ 2. Let obj be IntegerIndexedObjectCreate (proto, «[[ViewedArrayBuffer]],
+ [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]]» ).
+ ...
+
+ 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList)
+
+ ...
+ 10. Set the [[Prototype]] internal slot of A to prototype.
+ ...
+ 12. Return A.
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+function newTarget() {}
+newTarget.prototype = null;
+var o = [];
+
+testWithTypedArrayConstructors(function(TA) {
+ var ta = Reflect.construct(TA, [o], newTarget);
+
+ assert.sameValue(ta.constructor, TA);
+ assert.sameValue(Object.getPrototypeOf(ta), TA.prototype);
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-custom-proto-access-throws.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-custom-proto-access-throws.js
new file mode 100644
index 000000000..281d09353
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-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-typedarray
+description: >
+ Return abrupt completion getting newTarget's prototype
+info: |
+ 22.2.4.3 TypedArray ( typedArray )
+
+ 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 a [[TypedArrayName]] 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 newTarget = function() {}.bind(null);
+Object.defineProperty(newTarget, "prototype", {
+ get() {
+ throw new Test262Error();
+ }
+});
+
+var sample = new Int8Array();
+
+testWithTypedArrayConstructors(function(TA) {
+ assert.throws(Test262Error, function() {
+ Reflect.construct(TA, [sample], newTarget);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-detached-when-species-retrieved-different-type.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-detached-when-species-retrieved-different-type.js
new file mode 100644
index 000000000..8ee2fba54
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-detached-when-species-retrieved-different-type.js
@@ -0,0 +1,61 @@
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-typedarray-typedarray
+description: >
+ When a TypedArray is created from another TypedArray with a different element-type
+ and SpeciesConstructor detaches the source buffer, AllocateArrayBuffer is still
+ executed.
+info: |
+ 22.2.4.3 TypedArray ( typedArray )
+
+ ...
+ 16. If IsSharedArrayBuffer(srcData) is false, then
+ a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%).
+ ...
+ 18. If SameValue(elementType, srcType) is true, then
+ ...
+ 19. Else,
+ a. Let data be ? AllocateArrayBuffer(bufferConstructor, byteLength).
+ b. If IsDetachedBuffer(srcData) is true, throw a TypeError exception.
+ ...
+
+ 24.1.1.1 AllocateArrayBuffer ( constructor, byteLength )
+
+ 1. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%ArrayBufferPrototype%",
+ « [[ArrayBufferData]], [[ArrayBufferByteLength]] »).
+ ...
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray, Symbol.species]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var speciesCallCount = 0;
+ var bufferConstructor = Object.defineProperty({}, Symbol.species, {
+ get: function() {
+ speciesCallCount += 1;
+ $DETACHBUFFER(ta.buffer);
+ return speciesConstructor;
+ }
+ });
+
+ var prototypeCallCount = 0;
+ var speciesConstructor = Object.defineProperty(function(){}.bind(), "prototype", {
+ get: function() {
+ prototypeCallCount += 1;
+ return null;
+ }
+ });
+
+ var ta = new TA(0);
+ ta.buffer.constructor = bufferConstructor;
+
+ assert.throws(TypeError, function() {
+ var targetType = TA !== Int32Array ? Int32Array : Uint32Array;
+ new targetType(ta);
+ }, "TypeError thrown for detached source buffer");
+
+ assert.sameValue(speciesCallCount, 1, "@@species getter called once");
+ assert.sameValue(prototypeCallCount, 1, "prototype getter called once");
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-detached-when-species-retrieved-same-type.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-detached-when-species-retrieved-same-type.js
new file mode 100644
index 000000000..978f42af6
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-detached-when-species-retrieved-same-type.js
@@ -0,0 +1,64 @@
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-typedarray-typedarray
+description: >
+ When a TypedArray is created from another TypedArray with the same element-type
+ and SpeciesConstructor detaches the source buffer, AllocateArrayBuffer is still
+ executed.
+info: |
+ 22.2.4.3 TypedArray ( typedArray )
+
+ ...
+ 16. If IsSharedArrayBuffer(srcData) is false, then
+ a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%).
+ ...
+ 18. If SameValue(elementType, srcType) is true, then
+ a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset, byteLength, bufferConstructor).
+ ...
+
+ 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset, srcLength, cloneConstructor )
+
+ ...
+ 3. Let targetBuffer be ? AllocateArrayBuffer(cloneConstructor, srcLength).
+ 4. If IsDetachedBuffer(srcBuffer) is true, throw a TypeError exception.
+ ...
+
+ 24.1.1.1 AllocateArrayBuffer ( constructor, byteLength )
+
+ 1. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%ArrayBufferPrototype%",
+ « [[ArrayBufferData]], [[ArrayBufferByteLength]] »).
+ ...
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray, Symbol.species]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var speciesCallCount = 0;
+ var bufferConstructor = Object.defineProperty({}, Symbol.species, {
+ get: function() {
+ speciesCallCount += 1;
+ $DETACHBUFFER(ta.buffer);
+ return speciesConstructor;
+ }
+ });
+
+ var prototypeCallCount = 0;
+ var speciesConstructor = Object.defineProperty(function(){}.bind(), "prototype", {
+ get: function() {
+ prototypeCallCount += 1;
+ return null;
+ }
+ });
+
+ var ta = new TA(0);
+ ta.buffer.constructor = bufferConstructor;
+
+ assert.throws(TypeError, function() {
+ new TA(ta);
+ }, "TypeError thrown for detached source buffer");
+
+ assert.sameValue(speciesCallCount, 1, "@@species getter called once");
+ assert.sameValue(prototypeCallCount, 1, "prototype getter called once");
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-new-instance-extensibility.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-new-instance-extensibility.js
new file mode 100644
index 000000000..d29848bf8
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-new-instance-extensibility.js
@@ -0,0 +1,46 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-typedarray
+description: >
+ The new typedArray instance from a typedArray argument is extensible
+info: |
+ 22.2.4.3 TypedArray ( typedArray )
+
+ ...
+ 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]
+---*/
+
+var typedArraySample1 = new Int8Array();
+var typedArraySample2 = new Int8Array();
+Object.preventExtensions(typedArraySample2);
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample1 = new TA(typedArraySample1);
+
+ assert(Object.isExtensible(sample1), "new instance is extensible");
+
+ var sample2 = new TA(typedArraySample2);
+ assert(
+ Object.isExtensible(sample2),
+ "new instance does not inherit extensibility from typedarray argument"
+ );
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-access-throws.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-access-throws.js
new file mode 100644
index 000000000..b8976d696
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-access-throws.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-typedarray
+description: >
+ Return abrupt completion from getting typedArray argument's buffer.constructor
+info: |
+ 22.2.4.3 TypedArray ( typedArray )
+
+ 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 a [[TypedArrayName]] internal slot.
+
+ ...
+ 18. Else,
+ a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 2. Let C be ? Get(O, "constructor").
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var OtherCtor = TA === Int8Array ? Int16Array : Int8Array;
+ var sample = new OtherCtor();
+
+ Object.defineProperty(sample.buffer, "constructor", {
+ get() {
+ throw new Test262Error();
+ }
+ });
+
+ assert.throws(Test262Error, function() {
+ new TA(sample);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-custom-species-proto-from-ctor-realm.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-custom-species-proto-from-ctor-realm.js
new file mode 100644
index 000000000..03860d1a7
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-custom-species-proto-from-ctor-realm.js
@@ -0,0 +1,59 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-typedarray
+description: >
+ Derive the ArrayBuffer prototype from the realm of the species constructor
+info: |
+ 22.2.4.3 TypedArray ( typedArray )
+
+ 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 a [[TypedArrayName]] internal slot.
+
+ ...
+ 18. Else,
+ a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%).
+ b. Let data be ? AllocateArrayBuffer(bufferConstructor, byteLength).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ 6. If S is either undefined or null, return defaultConstructor.
+ 7. If IsConstructor(S) is true, return S.
+ ...
+
+ 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.
+ ...
+includes: [testTypedArray.js]
+features: [cross-realm, Symbol.species, TypedArray]
+---*/
+
+var sample1 = new Int8Array();
+var sample2 = new Int16Array();
+var other = $262.createRealm().global;
+var C = new other.Function();
+C.prototype = null;
+
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = TA === Int8Array ? sample2 : sample1;
+ var ctor = {};
+
+ sample.buffer.constructor = ctor;
+
+ ctor[Symbol.species] = C;
+
+ var typedArray = new TA(sample);
+ assert.sameValue(
+ Object.getPrototypeOf(typedArray.buffer), other.ArrayBuffer.prototype
+ );
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-custom-species.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-custom-species.js
new file mode 100644
index 000000000..a510d7806
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-custom-species.js
@@ -0,0 +1,52 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-typedarray
+description: >
+ Use default ArrayBuffer constructor on undefined buffer.constructor.@@species
+info: |
+ 22.2.4.3 TypedArray ( typedArray )
+
+ 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 a [[TypedArrayName]] internal slot.
+
+ ...
+ 18. Else,
+ a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%).
+ b. Let data be ? AllocateArrayBuffer(bufferConstructor, byteLength).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ 6. If S is either undefined or null, return defaultConstructor.
+ 7. If IsConstructor(S) is true, return S.
+ ...
+
+includes: [testTypedArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+var sample1 = new Int8Array();
+var sample2 = new Int16Array();
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = TA === Int8Array ? sample2 : sample1;
+ var ctor = {};
+ var called = 0;
+ var custom = {};
+
+ sample.buffer.constructor = ctor;
+
+ ctor[Symbol.species] = function() {
+ called++;
+ };
+
+ ctor[Symbol.species].prototype = custom;
+
+ var typedArray = new TA(sample);
+ assert.sameValue(Object.getPrototypeOf(typedArray.buffer), custom);
+ assert.sameValue(called, 0);
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-not-object-throws.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-not-object-throws.js
new file mode 100644
index 000000000..cfb79f1a9
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-not-object-throws.js
@@ -0,0 +1,61 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-typedarray
+description: >
+ Return abrupt completion from typedArray argument's buffer.constructor's value
+info: |
+ 22.2.4.3 TypedArray ( typedArray )
+
+ 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 a [[TypedArrayName]] internal slot.
+
+ ...
+ 18. Else,
+ a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 2. Let C be ? Get(O, "constructor").
+ ...
+ 4. If Type(C) is not Object, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var sample1 = new Int8Array();
+var sample2 = new Int16Array();
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = TA === Int8Array ? sample2 : sample1;
+
+ sample.buffer.constructor = 1;
+ assert.throws(TypeError, function() {
+ new TA(sample);
+ });
+
+ sample.buffer.constructor = true;
+ assert.throws(TypeError, function() {
+ new TA(sample);
+ });
+
+ sample.buffer.constructor = "";
+ assert.throws(TypeError, function() {
+ new TA(sample);
+ });
+
+ sample.buffer.constructor = null;
+ assert.throws(TypeError, function() {
+ new TA(sample);
+ });
+
+ var s = Symbol("1");
+ sample.buffer.constructor = s;
+ assert.throws(TypeError, function() {
+ new TA(sample);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-access-throws.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-access-throws.js
new file mode 100644
index 000000000..4b0b19aca
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-access-throws.js
@@ -0,0 +1,45 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-typedarray
+description: >
+ Return abrupt from getting typedArray argument's buffer.constructor.@@species
+info: |
+ 22.2.4.3 TypedArray ( typedArray )
+
+ 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 a [[TypedArrayName]] internal slot.
+
+ ...
+ 18. Else,
+ a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+var sample1 = new Int8Array();
+var sample2 = new Int16Array();
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = TA === Int8Array ? sample2 : sample1;
+ var ctor = {};
+
+ sample.buffer.constructor = ctor;
+ Object.defineProperty(ctor, Symbol.species, {
+ get: function() {
+ throw new Test262Error();
+ }
+ });
+
+ assert.throws(Test262Error, function() {
+ new TA(sample);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-not-ctor-throws.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-not-ctor-throws.js
new file mode 100644
index 000000000..c485cae13
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-not-ctor-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-typedarray
+description: >
+ Return abrupt from buffer.constructor.@@species.prototype
+info: |
+ 22.2.4.3 TypedArray ( typedArray )
+
+ 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 a [[TypedArrayName]] internal slot.
+
+ ...
+ 18. Else,
+ a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ 6. If S is either undefined or null, return defaultConstructor.
+ 7. If IsConstructor(S) is true, return S.
+ 8. Throw a TypeError exception.
+includes: [testTypedArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+var sample1 = new Int8Array();
+var sample2 = new Int16Array();
+
+var ctor = function() {
+ throw new Test262Error();
+};
+var m = { m() {} }.m;
+ctor[Symbol.species] = m;
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = TA === Int8Array ? sample2 : sample1;
+
+ sample.buffer.constructor = ctor;
+
+ assert.throws(TypeError, function() {
+ new TA(sample);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-null.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-null.js
new file mode 100644
index 000000000..96ba9009d
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-null.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-typedarray
+description: >
+ Use default ArrayBuffer constructor on null buffer.constructor.@@species
+info: |
+ 22.2.4.3 TypedArray ( typedArray )
+
+ 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 a [[TypedArrayName]] internal slot.
+
+ ...
+ 18. Else,
+ a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ 6. If S is either undefined or null, return defaultConstructor.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var OtherCtor = TA === Int8Array ? Int16Array : Int8Array;
+ var sample = new OtherCtor();
+ var ctor = {};
+
+ sample.buffer.constructor = ctor;
+
+ ctor[Symbol.species] = null;
+ var typedArray = new TA(sample);
+
+ assert.sameValue(
+ Object.getPrototypeOf(typedArray.buffer),
+ ArrayBuffer.prototype,
+ "buffer ctor is not called when species is null"
+ );
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-prototype-throws.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-prototype-throws.js
new file mode 100644
index 000000000..135634646
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-prototype-throws.js
@@ -0,0 +1,59 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-typedarray
+description: >
+ Return abrupt from buffer.constructor.@@species.prototype
+info: |
+ 22.2.4.3 TypedArray ( typedArray )
+
+ 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 a [[TypedArrayName]] internal slot.
+
+ ...
+ 18. Else,
+ a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%).
+ b. Let data be ? AllocateArrayBuffer(bufferConstructor, byteLength).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ 6. If S is either undefined or null, return defaultConstructor.
+ 7. If IsConstructor(S) is true, return S.
+ ...
+
+ 24.1.1.1 AllocateArrayBuffer ( constructor, byteLength )
+
+ ...
+ 1. Let obj be ? OrdinaryCreateFromConstructor(constructor,
+ "%ArrayBufferPrototype%", « [[ArrayBufferData]], [[ArrayBufferByteLength]] » )
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+var sample1 = new Int8Array();
+var sample2 = new Int16Array();
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = TA === Int8Array ? sample2 : sample1;
+ var ctor = {};
+ var called = 0;
+
+ sample.buffer.constructor = ctor;
+
+ ctor[Symbol.species] = function() {called++;}.bind(null);
+ Object.defineProperty(ctor[Symbol.species], "prototype", {
+ get: function() {
+ throw new Test262Error();
+ }
+ });
+
+ assert.throws(Test262Error, function() {
+ new TA(sample);
+ });
+ assert.sameValue(called, 0);
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-undefined.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-undefined.js
new file mode 100644
index 000000000..32e78a37d
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-undefined.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-typedarray
+description: >
+ Use default ArrayBuffer constructor on undefined buffer.constructor.@@species
+info: |
+ 22.2.4.3 TypedArray ( typedArray )
+
+ 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 a [[TypedArrayName]] internal slot.
+
+ ...
+ 18. Else,
+ a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ 6. If S is either undefined or null, return defaultConstructor.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var OtherCtor = TA === Int8Array ? Int16Array : Int8Array;
+ var sample = new OtherCtor();
+ var ctor = {};
+
+ sample.buffer.constructor = ctor;
+
+ ctor[Symbol.species] = undefined;
+ var a = new TA(sample);
+ assert.sameValue(
+ Object.getPrototypeOf(a.buffer),
+ ArrayBuffer.prototype,
+ "buffer ctor is not called when species is undefined"
+ );
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-returns-new-typedarray.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-returns-new-typedarray.js
new file mode 100644
index 000000000..34cb4dee6
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-returns-new-typedarray.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-typedarray
+description: >
+ Return abrupt from getting typedArray argument's buffer.constructor.@@species
+info: |
+ 22.2.4.3 TypedArray ( typedArray )
+
+ 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 a [[TypedArrayName]] internal slot.
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var sample1 = new Int8Array(7);
+var sample2 = new Int16Array(7);
+var sample3 = new BigInt64Array(7);
+var sample4 = new BigUint64Array(7);
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = TA === Int8Array ? sample2 :
+ TA === BigInt64Array ? sample4 :
+ TA === BigUint64Array ? sample3 : sample1;
+ var typedArray = new TA(sample);
+
+ assert.sameValue(typedArray.length, 7);
+ assert.notSameValue(typedArray, sample);
+ assert.sameValue(typedArray.constructor, TA);
+ assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype);
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-proto-from-ctor-realm.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-proto-from-ctor-realm.js
new file mode 100644
index 000000000..6e58746cd
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-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-typedarray
+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 TA()], C);
+
+ assert.sameValue(Object.getPrototypeOf(ta), other[TA.name].prototype);
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-returns-new-instance.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-returns-new-instance.js
new file mode 100644
index 000000000..128ec4021
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-returns-new-instance.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-typedarray
+description: >
+ Return a TypedArray object
+info: |
+ 22.2.4.3 TypedArray ( typedArray )
+
+ 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 a [[TypedArrayName]] internal slot.
+
+ ...
+ 20. Return O.
+
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var len = 10;
+var typedArraySample = new Int8Array(len);
+
+testWithTypedArrayConstructors(function(TA) {
+ var typedArray = new TA(typedArraySample);
+
+ assert.notSameValue(typedArray, typedArraySample);
+ assert.sameValue(typedArray.length, len);
+ assert.sameValue(typedArray.constructor, TA);
+ assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype);
+}, numericTypedArrayConstructors);
diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-access-throws.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-access-throws.js
new file mode 100644
index 000000000..f8e75d209
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-access-throws.js
@@ -0,0 +1,46 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-typedarray
+description: >
+ Return abrupt completion from getting typedArray argument's buffer.constructor
+info: |
+ 22.2.4.3 TypedArray ( typedArray )
+
+ 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 a [[TypedArrayName]] internal slot.
+
+ ...
+ 17. If SameValue(elementType, srcType) is true, then
+ a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset).
+ ...
+
+ 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] )
+
+ ...
+ 2. If cloneConstructor is not present, then
+ a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 2. Let C be ? Get(O, "constructor").
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ Object.defineProperty(sample.buffer, "constructor", {
+ get: function() {
+ throw new Test262Error();
+ }
+ });
+
+ assert.throws(Test262Error, function() {
+ new TA(sample);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-custom-proto-from-ctor-realm.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-custom-proto-from-ctor-realm.js
new file mode 100644
index 000000000..43743b956
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-custom-proto-from-ctor-realm.js
@@ -0,0 +1,68 @@
+// 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-typedarray
+description: >
+ Derive the ArrayBuffer prototype from the realm of the species constructor
+info: |
+ 22.2.4.3 TypedArray ( typedArray )
+
+ 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 a [[TypedArrayName]] internal slot.
+
+ ...
+ 17. If SameValue(elementType, srcType) is true, then
+ a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset).
+ ...
+
+ 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] )
+
+ ...
+ 2. If cloneConstructor is not present, then
+ a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ 6. If S is either undefined or null, return defaultConstructor.
+ 7. If IsConstructor(S) is true, return S.
+ ...
+
+ 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] )
+
+ ...
+ 8. Let targetBuffer be ? AllocateArrayBuffer(cloneConstructor, cloneLength).
+ ...
+
+ 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.
+ ...
+includes: [testTypedArray.js]
+features: [cross-realm, Symbol.species, TypedArray]
+---*/
+
+var other = $262.createRealm().global;
+var C = new other.Function();
+C.prototype = null;
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ var ctor = {};
+
+ sample.buffer.constructor = ctor;
+
+ ctor[Symbol.species] = C;
+
+ var typedArray = new TA(sample);
+ assert.sameValue(
+ Object.getPrototypeOf(typedArray.buffer), other.ArrayBuffer.prototype
+ );
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-custom.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-custom.js
new file mode 100644
index 000000000..7ed3aca0d
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-custom.js
@@ -0,0 +1,60 @@
+// 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-typedarray
+description: >
+ Use default ArrayBuffer constructor on undefined buffer.constructor.@@species
+info: |
+ 22.2.4.3 TypedArray ( typedArray )
+
+ 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 a [[TypedArrayName]] internal slot.
+
+ ...
+ 17. If SameValue(elementType, srcType) is true, then
+ a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset).
+ ...
+
+ 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] )
+
+ ...
+ 2. If cloneConstructor is not present, then
+ a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ 6. If S is either undefined or null, return defaultConstructor.
+ 7. If IsConstructor(S) is true, return S.
+ ...
+
+ 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] )
+
+ ...
+ 8. Let targetBuffer be ? AllocateArrayBuffer(cloneConstructor, cloneLength).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ var ctor = {};
+ var called = 0;
+ var custom = {};
+
+ sample.buffer.constructor = ctor;
+
+ ctor[Symbol.species] = function() {
+ called++;
+ };
+
+ ctor[Symbol.species].prototype = custom;
+
+ var typedArray = new TA(sample);
+ assert.sameValue(Object.getPrototypeOf(typedArray.buffer), custom);
+ assert.sameValue(called, 0);
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-not-ctor.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-not-ctor.js
new file mode 100644
index 000000000..2072aa96d
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-not-ctor.js
@@ -0,0 +1,49 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-typedarray
+description: >
+ Return abrupt from buffer.constructor.@@species.prototype
+info: |
+ 22.2.4.3 TypedArray ( typedArray )
+
+ 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 a [[TypedArrayName]] internal slot.
+
+ ...
+ 17. If SameValue(elementType, srcType) is true, then
+ a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset).
+ ...
+
+ 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] )
+
+ ...
+ 2. If cloneConstructor is not present, then
+ a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ 6. If S is either undefined or null, return defaultConstructor.
+ 7. If IsConstructor(S) is true, return S.
+ 8. Throw a TypeError exception.
+includes: [testTypedArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ var ctor = {};
+ var m = { m() {} };
+
+ sample.buffer.constructor = ctor;
+
+ ctor[Symbol.species] = m;
+
+ assert.throws(TypeError, function() {
+ new TA(sample);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-null.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-null.js
new file mode 100644
index 000000000..e42780610
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-null.js
@@ -0,0 +1,49 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-typedarray
+description: >
+ Use default ArrayBuffer constructor on null buffer.constructor.@@species
+info: |
+ 22.2.4.3 TypedArray ( typedArray )
+
+ 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 a [[TypedArrayName]] internal slot.
+
+ ...
+ 17. If SameValue(elementType, srcType) is true, then
+ a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset).
+ ...
+
+ 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] )
+
+ ...
+ 2. If cloneConstructor is not present, then
+ a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ 6. If S is either undefined or null, return defaultConstructor.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(4);
+ var ctor = {};
+
+ sample.buffer.constructor = ctor;
+
+ ctor[Symbol.species] = null;
+ var typedArray = new TA(sample);
+ assert.sameValue(
+ Object.getPrototypeOf(typedArray.buffer),
+ ArrayBuffer.prototype,
+ "buffer ctor is not called when species is null"
+ );
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-prototype-throws.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-prototype-throws.js
new file mode 100644
index 000000000..b171826cf
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-prototype-throws.js
@@ -0,0 +1,62 @@
+// 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-typedarray
+description: >
+ Return abrupt from buffer.constructor.@@species.prototype
+info: |
+ 22.2.4.3 TypedArray ( typedArray )
+
+ 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 a [[TypedArrayName]] internal slot.
+
+ ...
+ 17. If SameValue(elementType, srcType) is true, then
+ a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset).
+ ...
+
+ 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] )
+
+ ...
+ 2. If cloneConstructor is not present, then
+ a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%).
+ ...
+ 8. Let targetBuffer be ? AllocateArrayBuffer(cloneConstructor, cloneLength).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ 6. If S is either undefined or null, return defaultConstructor.
+ 7. If IsConstructor(S) is true, return S.
+ ...
+
+ 24.1.1.1 AllocateArrayBuffer ( constructor, byteLength )
+
+ ...
+ 1. Let obj be ? OrdinaryCreateFromConstructor(constructor,
+ "%ArrayBufferPrototype%", « [[ArrayBufferData]], [[ArrayBufferByteLength]] » )
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ var ctor = {};
+
+ sample.buffer.constructor = ctor;
+
+ ctor[Symbol.species] = function(){}.bind(null);
+ Object.defineProperty(ctor[Symbol.species], "prototype", {
+ get() {
+ throw new Test262Error();
+ }
+ });
+
+ assert.throws(Test262Error, function() {
+ new TA(sample);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-throws.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-throws.js
new file mode 100644
index 000000000..ec2aaf3c1
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-throws.js
@@ -0,0 +1,49 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-typedarray
+description: >
+ Return abrupt from getting typedArray argument's buffer.constructor.@@species
+info: |
+ 22.2.4.3 TypedArray ( typedArray )
+
+ 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 a [[TypedArrayName]] internal slot.
+
+ ...
+ 17. If SameValue(elementType, srcType) is true, then
+ a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset).
+ ...
+
+ 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] )
+
+ ...
+ 2. If cloneConstructor is not present, then
+ a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ var ctor = {};
+
+ sample.buffer.constructor = ctor;
+ Object.defineProperty(ctor, Symbol.species, {
+ get() {
+ throw new Test262Error();
+ }
+ });
+
+ assert.throws(Test262Error, function() {
+ new TA(sample);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-undefined.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-undefined.js
new file mode 100644
index 000000000..339d3041b
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-undefined.js
@@ -0,0 +1,49 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-typedarray
+description: >
+ Use default ArrayBuffer constructor on undefined buffer.constructor.@@species
+info: |
+ 22.2.4.3 TypedArray ( typedArray )
+
+ 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 a [[TypedArrayName]] internal slot.
+
+ ...
+ 17. If SameValue(elementType, srcType) is true, then
+ a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset).
+ ...
+
+ 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] )
+
+ ...
+ 2. If cloneConstructor is not present, then
+ a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ 6. If S is either undefined or null, return defaultConstructor.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(4);
+ var ctor = {};
+
+ sample.buffer.constructor = ctor;
+
+ ctor[Symbol.species] = undefined;
+ var typedArray = new TA(sample);
+ assert.sameValue(
+ Object.getPrototypeOf(typedArray.buffer),
+ ArrayBuffer.prototype,
+ "buffer ctor is not called when species is undefined"
+ );
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-value-not-obj-throws.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-value-not-obj-throws.js
new file mode 100644
index 000000000..ef9709749
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-value-not-obj-throws.js
@@ -0,0 +1,65 @@
+// 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-typedarray
+description: >
+ Return abrupt completion from typedArray argument's buffer.constructor's value
+info: |
+ 22.2.4.3 TypedArray ( typedArray )
+
+ 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 a [[TypedArrayName]] internal slot.
+
+ ...
+ 17. If SameValue(elementType, srcType) is true, then
+ a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset).
+ ...
+
+ 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] )
+
+ ...
+ 2. If cloneConstructor is not present, then
+ a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 2. Let C be ? Get(O, "constructor").
+ ...
+ 4. If Type(C) is not Object, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+
+ sample.buffer.constructor = 1;
+ assert.throws(TypeError, function() {
+ new TA(sample);
+ });
+
+ sample.buffer.constructor = true;
+ assert.throws(TypeError, function() {
+ new TA(sample);
+ });
+
+ sample.buffer.constructor = '';
+ assert.throws(TypeError, function() {
+ new TA(sample);
+ });
+
+ sample.buffer.constructor = null;
+ assert.throws(TypeError, function() {
+ new TA(sample);
+ });
+
+ var s = Symbol('1');
+ sample.buffer.constructor = s;
+ assert.throws(TypeError, function() {
+ new TA(sample);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-returns-new-cloned-typedarray.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-returns-new-cloned-typedarray.js
new file mode 100644
index 000000000..4d9b442c9
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-returns-new-cloned-typedarray.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-typedarray
+description: >
+ Same typedArray ctor argument returns a new cloned typedArray
+info: |
+ 22.2.4.3 TypedArray ( typedArray )
+
+ 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 a [[TypedArrayName]] internal slot.
+
+ ...
+ 17. If SameValue(elementType, srcType) is true, then
+ a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset).
+ ...
+ 23. Return O.
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(7);
+ var typedArray = new TA(sample);
+
+ assert.sameValue(typedArray.length, 7);
+ assert.notSameValue(typedArray, sample);
+ assert.notSameValue(typedArray.buffer, sample.buffer);
+ assert.sameValue(typedArray.constructor, TA);
+ assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype);
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-undefined-newtarget-throws.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-undefined-newtarget-throws.js
new file mode 100644
index 000000000..12839b2d7
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-undefined-newtarget-throws.js
@@ -0,0 +1,27 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-typedarray-typedarray
+description: >
+ Throws a TypeError if NewTarget is undefined.
+info: |
+ 22.2.4.3 TypedArray ( typedArray )
+
+ 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 a [[TypedArrayName]] internal slot.
+
+ ...
+ 2. If NewTarget is undefined, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var typedArray = new TA(4);
+
+ assert.throws(TypeError, function() {
+ TA(typedArray);
+ });
+});
diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-use-custom-proto-if-object.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-use-custom-proto-if-object.js
new file mode 100644
index 000000000..2745fc5e2
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-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-typedarray
+description: >
+ Use prototype from new target if it's an Object
+info: |
+ 22.2.4.3 TypedArray ( typedArray )
+
+ 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 a [[TypedArrayName]] 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]
+---*/
+
+function newTarget() {}
+var proto = {};
+newTarget.prototype = proto;
+
+var sample = new Int8Array(8);
+
+testWithTypedArrayConstructors(function(TA) {
+ var ta = Reflect.construct(TA, [sample], newTarget);
+
+ assert.sameValue(ta.constructor, Object);
+ assert.sameValue(Object.getPrototypeOf(ta), proto);
+}, numericTypedArrayConstructors);
diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-use-default-proto-if-custom-proto-is-not-object.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-use-default-proto-if-custom-proto-is-not-object.js
new file mode 100644
index 000000000..ec1997e91
--- /dev/null
+++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-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-typedarray
+description: >
+ Use prototype from %TypedArray% if newTarget's prototype is not an Object
+info: |
+ 22.2.4.3 TypedArray ( typedArray )
+
+ 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 a [[TypedArrayName]] 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]
+---*/
+
+function newTarget() {}
+newTarget.prototype = null;
+
+var sample = new Int8Array(8);
+
+testWithTypedArrayConstructors(function(TA) {
+ var ta = Reflect.construct(TA, [sample], newTarget);
+
+ assert.sameValue(ta.constructor, TA);
+ assert.sameValue(Object.getPrototypeOf(ta), TA.prototype);
+}, numericTypedArrayConstructors);