summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/TypedArray/of
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/TypedArray/of')
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/of/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/of/invoked-as-func.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/of/invoked-as-method.js26
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/of/length.js33
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/of/name.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/of/not-a-constructor.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/of/prop-desc.js19
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/of/shell.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/of/this-is-not-constructor.js24
9 files changed, 210 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/TypedArray/of/browser.js b/js/src/tests/test262/built-ins/TypedArray/of/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/of/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/of/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/of/invoked-as-func.js
new file mode 100644
index 0000000000..1f40a9659b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/of/invoked-as-func.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.
+/*---
+es6id: 22.2.2.2
+description: >
+ "of" cannot be invoked as a function
+info: |
+ 22.2.2.2 %TypedArray%.of ( ...items )
+
+ ...
+ 3. Let C be the this value.
+ 4. If IsConstructor(C) is false, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var of = TypedArray.of;
+
+assert.throws(TypeError, function() {
+ of();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/of/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/of/invoked-as-method.js
new file mode 100644
index 0000000000..0b671ca852
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/of/invoked-as-method.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%.of
+description: >
+ "of" cannot be invoked as a method of %TypedArray%
+info: |
+ 22.2.2.2 %TypedArray%.of ( ...items )
+
+ ...
+ 5. Let newObj be ? TypedArrayCreate(C, «len»).
+ ...
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ 1. Let newTypedArray be ? Construct(constructor, argumentList).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.throws(TypeError, function() {
+ TypedArray.of();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/of/length.js b/js/src/tests/test262/built-ins/TypedArray/of/length.js
new file mode 100644
index 0000000000..9739cd5045
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/of/length.js
@@ -0,0 +1,33 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%-of
+description: >
+ %TypedArray%.of.length is 0.
+info: |
+ %TypedArray%.of ( ...items )
+
+ 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. Optional parameters (which are indicated with brackets:
+ [ ]) or rest parameters (which are 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, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.of.length, 0);
+
+verifyNotEnumerable(TypedArray.of, "length");
+verifyNotWritable(TypedArray.of, "length");
+verifyConfigurable(TypedArray.of, "length");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/of/name.js b/js/src/tests/test262/built-ins/TypedArray/of/name.js
new file mode 100644
index 0000000000..c18c95cafe
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/of/name.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es6id: 22.2.2.2
+description: >
+ %TypedArray%.of.name is "of".
+info: |
+ %TypedArray%.of ( ...items )
+
+ 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, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.of.name, "of");
+
+verifyNotEnumerable(TypedArray.of, "name");
+verifyNotWritable(TypedArray.of, "name");
+verifyConfigurable(TypedArray.of, "name");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/of/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/of/not-a-constructor.js
new file mode 100644
index 0000000000..575bb492fb
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/of/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: >
+ TypedArray.of 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, testTypedArray.js]
+features: [Reflect.construct, TypedArray, arrow-function]
+---*/
+
+assert.sameValue(isConstructor(TypedArray.of), false, 'isConstructor(TypedArray.of) must return false');
+
+assert.throws(TypeError, () => {
+ new TypedArray.of(1, 2, 3, 4);
+}, '`new TypedArray.of(1, 2, 3, 4)` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/of/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/of/prop-desc.js
new file mode 100644
index 0000000000..86bad8552c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/of/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.
+/*---
+es6id: 22.2.2.2
+description: >
+ "of" property of TypedArray
+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, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+verifyNotEnumerable(TypedArray, 'of');
+verifyWritable(TypedArray, 'of');
+verifyConfigurable(TypedArray, 'of');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/of/shell.js b/js/src/tests/test262/built-ins/TypedArray/of/shell.js
new file mode 100644
index 0000000000..eda1477282
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/of/shell.js
@@ -0,0 +1,24 @@
+// GENERATED, DO NOT EDIT
+// file: isConstructor.js
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: |
+ Test if a given function is a constructor function.
+defines: [isConstructor]
+features: [Reflect.construct]
+---*/
+
+function isConstructor(f) {
+ if (typeof f !== "function") {
+ throw new Test262Error("isConstructor invoked with a non-function value");
+ }
+
+ try {
+ Reflect.construct(function(){}, [], f);
+ } catch (e) {
+ return false;
+ }
+ return true;
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/of/this-is-not-constructor.js b/js/src/tests/test262/built-ins/TypedArray/of/this-is-not-constructor.js
new file mode 100644
index 0000000000..606fba3255
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/of/this-is-not-constructor.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-%typedarray%.of
+description: >
+ Throws a TypeError exception if this is not a constructor
+info: |
+ 22.2.2.2 %TypedArray%.of ( ...items )
+
+ ...
+ 3. Let C be the this value.
+ 4. If IsConstructor(C) is false, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var m = { m() {} }.m;
+
+assert.throws(TypeError, function() {
+ TypedArray.of.call(m, []);
+});
+
+reportCompare(0, 0);