summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/ArrayBuffer/isView
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/ArrayBuffer/isView')
-rw-r--r--js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-has-no-viewedarraybuffer.js19
-rw-r--r--js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-arraybuffer.js20
-rw-r--r--js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-dataview-buffer.js21
-rw-r--r--js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-dataview-constructor.js19
-rw-r--r--js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-dataview-subclass-instance.js23
-rw-r--r--js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-dataview.js21
-rw-r--r--js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-not-object.js20
-rw-r--r--js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-typedarray-buffer.js24
-rw-r--r--js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-typedarray-constructor.js22
-rw-r--r--js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-typedarray-subclass-instance.js26
-rw-r--r--js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-typedarray.js24
-rw-r--r--js/src/tests/test262/built-ins/ArrayBuffer/isView/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/ArrayBuffer/isView/invoked-as-a-fn.js31
-rw-r--r--js/src/tests/test262/built-ins/ArrayBuffer/isView/length.js31
-rw-r--r--js/src/tests/test262/built-ins/ArrayBuffer/isView/name.js28
-rw-r--r--js/src/tests/test262/built-ins/ArrayBuffer/isView/no-arg.js17
-rw-r--r--js/src/tests/test262/built-ins/ArrayBuffer/isView/not-a-constructor.js31
-rw-r--r--js/src/tests/test262/built-ins/ArrayBuffer/isView/prop-desc.js19
-rw-r--r--js/src/tests/test262/built-ins/ArrayBuffer/isView/shell.js124
19 files changed, 520 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-has-no-viewedarraybuffer.js b/js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-has-no-viewedarraybuffer.js
new file mode 100644
index 0000000000..28138d45e3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-has-no-viewedarraybuffer.js
@@ -0,0 +1,19 @@
+// 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-arraybuffer.isview
+description: >
+ Return false if arg has no [[ViewedArrayBuffer]] internal slot.
+info: |
+ 24.1.3.1 ArrayBuffer.isView ( arg )
+
+ 1. If Type(arg) is not Object, return false.
+ 2. If arg has a [[ViewedArrayBuffer]] internal slot, return true.
+ 3. Return false.
+---*/
+
+assert.sameValue(ArrayBuffer.isView({}), false, "ordinary object");
+assert.sameValue(ArrayBuffer.isView([]), false, "Array");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-arraybuffer.js b/js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-arraybuffer.js
new file mode 100644
index 0000000000..2ca8a2d1ee
--- /dev/null
+++ b/js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-arraybuffer.js
@@ -0,0 +1,20 @@
+// Copyright (C) 2016 The V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-arraybuffer.isview
+description: >
+ Return false from an instance of ArrayBuffer
+info: |
+ 24.1.3.1 ArrayBuffer.isView ( arg )
+
+ 1. If Type(arg) is not Object, return false.
+ 2. If arg has a [[ViewedArrayBuffer]] internal slot, return true.
+ 3. Return false.
+---*/
+
+var sample = new ArrayBuffer(1);
+
+assert.sameValue(ArrayBuffer.isView(sample), false);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-dataview-buffer.js b/js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-dataview-buffer.js
new file mode 100644
index 0000000000..2b59775a4b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-dataview-buffer.js
@@ -0,0 +1,21 @@
+// Copyright (C) 2016 The V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-arraybuffer.isview
+description: >
+ Return false from DataView's instance `.buffer`
+info: |
+ 24.1.3.1 ArrayBuffer.isView ( arg )
+
+ 1. If Type(arg) is not Object, return false.
+ 2. If arg has a [[ViewedArrayBuffer]] internal slot, return true.
+ 3. Return false.
+features: [DataView]
+---*/
+
+var sample = new DataView(new ArrayBuffer(1), 0, 0).buffer;
+
+assert.sameValue(ArrayBuffer.isView(sample), false);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-dataview-constructor.js b/js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-dataview-constructor.js
new file mode 100644
index 0000000000..1095947f70
--- /dev/null
+++ b/js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-dataview-constructor.js
@@ -0,0 +1,19 @@
+// 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-arraybuffer.isview
+description: >
+ Return false if arg is the DataView constructor
+info: |
+ 24.1.3.1 ArrayBuffer.isView ( arg )
+
+ 1. If Type(arg) is not Object, return false.
+ 2. If arg has a [[ViewedArrayBuffer]] internal slot, return true.
+ 3. Return false.
+features: [DataView]
+---*/
+
+assert.sameValue(ArrayBuffer.isView(DataView), false, "DataView");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-dataview-subclass-instance.js b/js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-dataview-subclass-instance.js
new file mode 100644
index 0000000000..727e318f0d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-dataview-subclass-instance.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-arraybuffer.isview
+description: >
+ Return true if arg is an instance from a subclass of DataView
+info: |
+ 24.1.3.1 ArrayBuffer.isView ( arg )
+
+ 1. If Type(arg) is not Object, return false.
+ 2. If arg has a [[ViewedArrayBuffer]] internal slot, return true.
+ 3. Return false.
+features: [class, DataView]
+---*/
+
+class DV extends DataView {}
+
+var sample = new DV(new ArrayBuffer(1), 0, 0);
+
+assert(ArrayBuffer.isView(sample));
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-dataview.js b/js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-dataview.js
new file mode 100644
index 0000000000..ab145cf6cf
--- /dev/null
+++ b/js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-dataview.js
@@ -0,0 +1,21 @@
+// Copyright (C) 2016 The V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-arraybuffer.isview
+description: >
+ Return true if is an instance of DataView
+info: |
+ 24.1.3.1 ArrayBuffer.isView ( arg )
+
+ 1. If Type(arg) is not Object, return false.
+ 2. If arg has a [[ViewedArrayBuffer]] internal slot, return true.
+ 3. Return false.
+features: [DataView]
+---*/
+
+var sample = new DataView(new ArrayBuffer(1), 0, 0);
+
+assert.sameValue(ArrayBuffer.isView(sample), true);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-not-object.js b/js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-not-object.js
new file mode 100644
index 0000000000..3fc13f5b05
--- /dev/null
+++ b/js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-not-object.js
@@ -0,0 +1,20 @@
+// Copyright (C) 2016 The V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-arraybuffer.isview
+description: >
+ Return false if arg is not Object
+info: |
+ 24.1.3.1 ArrayBuffer.isView ( arg )
+
+ 1. If Type(arg) is not Object, return false.
+ ...
+---*/
+
+assert.sameValue(ArrayBuffer.isView(null), false, "null");
+assert.sameValue(ArrayBuffer.isView(undefined), false, "undefined");
+assert.sameValue(ArrayBuffer.isView(1), false, "number");
+assert.sameValue(ArrayBuffer.isView(""), false, "string");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-typedarray-buffer.js b/js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-typedarray-buffer.js
new file mode 100644
index 0000000000..9e8918b388
--- /dev/null
+++ b/js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-typedarray-buffer.js
@@ -0,0 +1,24 @@
+// Copyright (C) 2016 The V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-arraybuffer.isview
+description: >
+ Return false from TypedArray's instance `.buffer`
+info: |
+ 24.1.3.1 ArrayBuffer.isView ( arg )
+
+ 1. If Type(arg) is not Object, return false.
+ 2. If arg has a [[ViewedArrayBuffer]] internal slot, return true.
+ 3. Return false.
+features: [TypedArray]
+includes: [testTypedArray.js]
+---*/
+
+testWithTypedArrayConstructors(function(ctor) {
+ var sample = new ctor().buffer;
+
+ assert.sameValue(ArrayBuffer.isView(sample), false);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-typedarray-constructor.js b/js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-typedarray-constructor.js
new file mode 100644
index 0000000000..efd5d16984
--- /dev/null
+++ b/js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-typedarray-constructor.js
@@ -0,0 +1,22 @@
+// Copyright (C) 2016 The V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-arraybuffer.isview
+description: >
+ Return false if arg is a TypedArray constructor
+info: |
+ 24.1.3.1 ArrayBuffer.isView ( arg )
+
+ 1. If Type(arg) is not Object, return false.
+ 2. If arg has a [[ViewedArrayBuffer]] internal slot, return true.
+ 3. Return false.
+features: [TypedArray]
+includes: [testTypedArray.js]
+---*/
+
+testWithTypedArrayConstructors(function(ctor) {
+ assert.sameValue(ArrayBuffer.isView(ctor), false);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-typedarray-subclass-instance.js b/js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-typedarray-subclass-instance.js
new file mode 100644
index 0000000000..3d17140d0f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-typedarray-subclass-instance.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-arraybuffer.isview
+description: >
+ Return true if arg is an instance from a subclass of TypedArray
+info: |
+ 24.1.3.1 ArrayBuffer.isView ( arg )
+
+ 1. If Type(arg) is not Object, return false.
+ 2. If arg has a [[ViewedArrayBuffer]] internal slot, return true.
+ 3. Return false.
+features: [class, TypedArray]
+includes: [testTypedArray.js]
+---*/
+
+testWithTypedArrayConstructors(function(ctor) {
+ class TA extends ctor {}
+
+ var sample = new TA();
+
+ assert(ArrayBuffer.isView(sample));
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-typedarray.js b/js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-typedarray.js
new file mode 100644
index 0000000000..78cbfbbf61
--- /dev/null
+++ b/js/src/tests/test262/built-ins/ArrayBuffer/isView/arg-is-typedarray.js
@@ -0,0 +1,24 @@
+// Copyright (C) 2016 The V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-arraybuffer.isview
+description: >
+ Return true if arg is an instance of TypedArray
+info: |
+ 24.1.3.1 ArrayBuffer.isView ( arg )
+
+ 1. If Type(arg) is not Object, return false.
+ 2. If arg has a [[ViewedArrayBuffer]] internal slot, return true.
+ 3. Return false.
+features: [TypedArray]
+includes: [testTypedArray.js]
+---*/
+
+testWithTypedArrayConstructors(function(ctor) {
+ var sample = new ctor();
+
+ assert.sameValue(ArrayBuffer.isView(sample), true);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/ArrayBuffer/isView/browser.js b/js/src/tests/test262/built-ins/ArrayBuffer/isView/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/ArrayBuffer/isView/browser.js
diff --git a/js/src/tests/test262/built-ins/ArrayBuffer/isView/invoked-as-a-fn.js b/js/src/tests/test262/built-ins/ArrayBuffer/isView/invoked-as-a-fn.js
new file mode 100644
index 0000000000..e58a330cdb
--- /dev/null
+++ b/js/src/tests/test262/built-ins/ArrayBuffer/isView/invoked-as-a-fn.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-arraybuffer.isview
+description: >
+ `isView` can be invoked as a function
+info: |
+ 24.1.3.1 ArrayBuffer.isView ( arg )
+
+ 1. If Type(arg) is not Object, return false.
+ 2. If arg has a [[ViewedArrayBuffer]] internal slot, return true.
+ 3. Return false.
+features: [TypedArray, DataView]
+includes: [testTypedArray.js]
+---*/
+
+var isView = ArrayBuffer.isView;
+
+testWithTypedArrayConstructors(function(ctor) {
+ var sample = new ctor();
+ assert.sameValue(isView(sample), true, "instance of TypedArray");
+});
+
+var dv = new DataView(new ArrayBuffer(1), 0, 0);
+assert.sameValue(isView(dv), true, "instance of DataView");
+
+assert.sameValue(isView(), false, "undefined arg");
+assert.sameValue(isView({}), false, "ordinary object");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/ArrayBuffer/isView/length.js b/js/src/tests/test262/built-ins/ArrayBuffer/isView/length.js
new file mode 100644
index 0000000000..d74f5ab42d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/ArrayBuffer/isView/length.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-arraybuffer.isview
+description: >
+ ArrayBuffer.isView.length is 1.
+info: |
+ ArrayBuffer.isView ( arg )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(ArrayBuffer.isView.length, 1);
+
+verifyNotEnumerable(ArrayBuffer.isView, "length");
+verifyNotWritable(ArrayBuffer.isView, "length");
+verifyConfigurable(ArrayBuffer.isView, "length");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/ArrayBuffer/isView/name.js b/js/src/tests/test262/built-ins/ArrayBuffer/isView/name.js
new file mode 100644
index 0000000000..e8ef8b04e5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/ArrayBuffer/isView/name.js
@@ -0,0 +1,28 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-arraybuffer.isview
+description: >
+ ArrayBuffer.isView.name is "isView".
+info: |
+ ArrayBuffer.isView ( arg )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, that is not
+ identified as an anonymous function has a name property whose value
+ is a String.
+
+ Unless otherwise specified, the name property of a built-in Function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(ArrayBuffer.isView.name, "isView");
+
+verifyNotEnumerable(ArrayBuffer.isView, "name");
+verifyNotWritable(ArrayBuffer.isView, "name");
+verifyConfigurable(ArrayBuffer.isView, "name");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/ArrayBuffer/isView/no-arg.js b/js/src/tests/test262/built-ins/ArrayBuffer/isView/no-arg.js
new file mode 100644
index 0000000000..c3b747b7bf
--- /dev/null
+++ b/js/src/tests/test262/built-ins/ArrayBuffer/isView/no-arg.js
@@ -0,0 +1,17 @@
+// 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-arraybuffer.isview
+description: >
+ Return false if isView is called with no arg
+info: |
+ 24.1.3.1 ArrayBuffer.isView ( arg )
+
+ 1. If Type(arg) is not Object, return false.
+ ...
+---*/
+
+assert.sameValue(ArrayBuffer.isView(), false);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/ArrayBuffer/isView/not-a-constructor.js b/js/src/tests/test262/built-ins/ArrayBuffer/isView/not-a-constructor.js
new file mode 100644
index 0000000000..09f8d71685
--- /dev/null
+++ b/js/src/tests/test262/built-ins/ArrayBuffer/isView/not-a-constructor.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+ ArrayBuffer.isView does not implement [[Construct]], is not new-able
+info: |
+ ECMAScript Function Objects
+
+ Built-in function objects that are not identified as constructors do not
+ implement the [[Construct]] internal method unless otherwise specified in
+ the description of a particular function.
+
+ sec-evaluatenew
+
+ ...
+ 7. If IsConstructor(constructor) is false, throw a TypeError exception.
+ ...
+includes: [isConstructor.js]
+features: [Reflect.construct, ArrayBuffer, arrow-function]
+---*/
+
+assert.sameValue(isConstructor(ArrayBuffer.isView), false, 'isConstructor(ArrayBuffer.isView) must return false');
+
+assert.throws(TypeError, () => {
+ new ArrayBuffer.isView();
+}, '`new ArrayBuffer.isView()` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/ArrayBuffer/isView/prop-desc.js b/js/src/tests/test262/built-ins/ArrayBuffer/isView/prop-desc.js
new file mode 100644
index 0000000000..3eebf6ed54
--- /dev/null
+++ b/js/src/tests/test262/built-ins/ArrayBuffer/isView/prop-desc.js
@@ -0,0 +1,19 @@
+// 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-arraybuffer.isview
+description: >
+ "isView" property of ArrayBuffer
+info: |
+ ES6 section 17: Every other data property described in clauses 18 through 26
+ and in Annex B.2 has the attributes { [[Writable]]: true,
+ [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js]
+---*/
+
+verifyNotEnumerable(ArrayBuffer, "isView");
+verifyWritable(ArrayBuffer, "isView");
+verifyConfigurable(ArrayBuffer, "isView");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/ArrayBuffer/isView/shell.js b/js/src/tests/test262/built-ins/ArrayBuffer/isView/shell.js
new file mode 100644
index 0000000000..e9580b3113
--- /dev/null
+++ b/js/src/tests/test262/built-ins/ArrayBuffer/isView/shell.js
@@ -0,0 +1,124 @@
+// GENERATED, DO NOT EDIT
+// file: testTypedArray.js
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+description: |
+ Collection of functions used to assert the correctness of TypedArray objects.
+defines:
+ - typedArrayConstructors
+ - floatArrayConstructors
+ - intArrayConstructors
+ - TypedArray
+ - testWithTypedArrayConstructors
+ - testWithAtomicsFriendlyTypedArrayConstructors
+ - testWithNonAtomicsFriendlyTypedArrayConstructors
+ - testTypedArrayConversions
+---*/
+
+/**
+ * Array containing every typed array constructor.
+ */
+var typedArrayConstructors = [
+ Float64Array,
+ Float32Array,
+ Int32Array,
+ Int16Array,
+ Int8Array,
+ Uint32Array,
+ Uint16Array,
+ Uint8Array,
+ Uint8ClampedArray
+];
+
+var floatArrayConstructors = typedArrayConstructors.slice(0, 2);
+var intArrayConstructors = typedArrayConstructors.slice(2, 7);
+
+/**
+ * The %TypedArray% intrinsic constructor function.
+ */
+var TypedArray = Object.getPrototypeOf(Int8Array);
+
+/**
+ * Callback for testing a typed array constructor.
+ *
+ * @callback typedArrayConstructorCallback
+ * @param {Function} Constructor the constructor object to test with.
+ */
+
+/**
+ * Calls the provided function for every typed array constructor.
+ *
+ * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
+ * @param {Array} selected - An optional Array with filtered typed arrays
+ */
+function testWithTypedArrayConstructors(f, selected) {
+ var constructors = selected || typedArrayConstructors;
+ for (var i = 0; i < constructors.length; ++i) {
+ var constructor = constructors[i];
+ try {
+ f(constructor);
+ } catch (e) {
+ e.message += " (Testing with " + constructor.name + ".)";
+ throw e;
+ }
+ }
+}
+
+/**
+ * Calls the provided function for every non-"Atomics Friendly" typed array constructor.
+ *
+ * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
+ * @param {Array} selected - An optional Array with filtered typed arrays
+ */
+function testWithNonAtomicsFriendlyTypedArrayConstructors(f) {
+ testWithTypedArrayConstructors(f, [
+ Float64Array,
+ Float32Array,
+ Uint8ClampedArray
+ ]);
+}
+
+/**
+ * Calls the provided function for every "Atomics Friendly" typed array constructor.
+ *
+ * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
+ * @param {Array} selected - An optional Array with filtered typed arrays
+ */
+function testWithAtomicsFriendlyTypedArrayConstructors(f) {
+ testWithTypedArrayConstructors(f, [
+ Int32Array,
+ Int16Array,
+ Int8Array,
+ Uint32Array,
+ Uint16Array,
+ Uint8Array,
+ ]);
+}
+
+/**
+ * Helper for conversion operations on TypedArrays, the expected values
+ * properties are indexed in order to match the respective value for each
+ * TypedArray constructor
+ * @param {Function} fn - the function to call for each constructor and value.
+ * will be called with the constructor, value, expected
+ * value, and a initial value that can be used to avoid
+ * a false positive with an equivalent expected value.
+ */
+function testTypedArrayConversions(byteConversionValues, fn) {
+ var values = byteConversionValues.values;
+ var expected = byteConversionValues.expected;
+
+ testWithTypedArrayConstructors(function(TA) {
+ var name = TA.name.slice(0, -5);
+
+ return values.forEach(function(value, index) {
+ var exp = expected[name][index];
+ var initial = 0;
+ if (exp === 0) {
+ initial = 1;
+ }
+ fn(TA, value, exp, initial);
+ });
+ });
+}