summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/TypedArray/prototype/buffer
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/TypedArray/prototype/buffer')
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/buffer/BigInt/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/buffer/BigInt/detached-buffer.js23
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/buffer/BigInt/return-buffer.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/buffer/BigInt/shell.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/buffer/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/buffer/detached-buffer.js23
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/buffer/invoked-as-accessor.js25
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/buffer/invoked-as-func.js27
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/buffer/length.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/buffer/name.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/buffer/prop-desc.js26
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/buffer/return-buffer.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/buffer/shell.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/buffer/this-has-no-typedarrayname-internal.js43
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/buffer/this-inherits-typedarray.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/buffer/this-is-not-object.js50
16 files changed, 407 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/BigInt/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/BigInt/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/BigInt/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/BigInt/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/BigInt/detached-buffer.js
new file mode 100644
index 0000000000..c255fe3436
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/BigInt/detached-buffer.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-get-%typedarray%.prototype.buffer
+description: The getter method does not throw with a detached buffer
+info: |
+ 22.2.3.1 get %TypedArray%.prototype.buffer
+
+ ...
+ 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot.
+ 5. Return buffer.
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var buffer = new ArrayBuffer(8);
+ var sample = new TA(buffer, 0, 1);
+ $DETACHBUFFER(sample.buffer);
+ assert.sameValue(sample.buffer, buffer);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/BigInt/return-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/BigInt/return-buffer.js
new file mode 100644
index 0000000000..a9055b85a6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/BigInt/return-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-get-%typedarray%.prototype.buffer
+description: >
+ Return buffer from [[ViewedArrayBuffer]] internal slot
+info: |
+ 22.2.3.1 get %TypedArray%.prototype.buffer
+
+ ...
+ 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot.
+ 5. Return buffer.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT);
+ var ta = new TA(buffer);
+
+ assert.sameValue(ta.buffer, buffer);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/BigInt/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/BigInt/shell.js
new file mode 100644
index 0000000000..90ee9c114d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/BigInt/shell.js
@@ -0,0 +1,42 @@
+// GENERATED, DO NOT EDIT
+// file: testBigIntTypedArray.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 BigInt TypedArray objects.
+defines:
+ - TypedArray
+ - testWithBigIntTypedArrayConstructors
+---*/
+
+/**
+ * The %TypedArray% intrinsic constructor function.
+ */
+var TypedArray = Object.getPrototypeOf(Int8Array);
+
+/**
+ * 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 testWithBigIntTypedArrayConstructors(f, selected) {
+ /**
+ * Array containing every BigInt typed array constructor.
+ */
+ var constructors = selected || [
+ BigInt64Array,
+ BigUint64Array
+ ];
+
+ 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;
+ }
+ }
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/detached-buffer.js
new file mode 100644
index 0000000000..37d07fc49b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/detached-buffer.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-get-%typedarray%.prototype.buffer
+description: The getter method does not throw with a detached buffer
+info: |
+ 22.2.3.1 get %TypedArray%.prototype.buffer
+
+ ...
+ 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot.
+ 5. Return buffer.
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var buffer = new ArrayBuffer(8);
+ var sample = new TA(buffer, 0, 1);
+ $DETACHBUFFER(sample.buffer);
+ assert.sameValue(sample.buffer, buffer);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/invoked-as-accessor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/invoked-as-accessor.js
new file mode 100644
index 0000000000..d1ce4b348a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/invoked-as-accessor.js
@@ -0,0 +1,25 @@
+// 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-get-%typedarray%.prototype.buffer
+description: >
+ Requires this value to have a [[ViewedArrayBuffer]] internal slot
+info: |
+ 22.2.3.1 get %TypedArray%.prototype.buffer
+
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+ 3. If O does not have a [[ViewedArrayBuffer]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+assert.throws(TypeError, function() {
+ TypedArrayPrototype.buffer;
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/invoked-as-func.js
new file mode 100644
index 0000000000..4b47043775
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/invoked-as-func.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-get-%typedarray%.prototype.buffer
+description: Throws a TypeError exception when invoked as a function
+info: |
+ 22.2.3.1 get %TypedArray%.prototype.buffer
+
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+ 3. If O does not have a [[ViewedArrayBuffer]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+var getter = Object.getOwnPropertyDescriptor(
+ TypedArrayPrototype, 'buffer'
+).get;
+
+assert.throws(TypeError, function() {
+ getter();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/length.js
new file mode 100644
index 0000000000..5d0450e8f0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/length.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-get-%typedarray%.prototype.buffer
+description: >
+ get %TypedArray%.prototype.buffer.length is 0.
+info: |
+ get %TypedArray%.prototype.buffer
+
+ 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, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var desc = Object.getOwnPropertyDescriptor(TypedArray.prototype, "buffer");
+
+assert.sameValue(desc.get.length, 0);
+
+verifyNotEnumerable(desc.get, "length");
+verifyNotWritable(desc.get, "length");
+verifyConfigurable(desc.get, "length");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/name.js
new file mode 100644
index 0000000000..f0464af9dc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/name.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-get-%typedarray%.prototype.buffer
+description: >
+ get %TypedArray%.prototype.buffer.name is "get buffer".
+info: |
+ get %TypedArray%.prototype.buffer
+
+ 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]
+---*/
+
+var desc = Object.getOwnPropertyDescriptor(TypedArray.prototype, "buffer");
+
+assert.sameValue(desc.get.name, "get buffer");
+
+verifyNotEnumerable(desc.get, "name");
+verifyNotWritable(desc.get, "name");
+verifyConfigurable(desc.get, "name");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/prop-desc.js
new file mode 100644
index 0000000000..70f7c8973f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/prop-desc.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-get-%typedarray%.prototype.buffer
+description: >
+ "buffer" property of TypedArrayPrototype
+info: |
+ %TypedArray%.prototype.buffer is an accessor property whose set accessor
+ function is undefined.
+
+ Section 17: Every accessor property described in clauses 18 through 26 and in
+ Annex B.2 has the attributes {[[Enumerable]]: false, [[Configurable]]: true }
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+var desc = Object.getOwnPropertyDescriptor(TypedArrayPrototype, "buffer");
+
+assert.sameValue(desc.set, undefined);
+assert.sameValue(typeof desc.get, "function");
+
+verifyNotEnumerable(TypedArrayPrototype, "buffer");
+verifyConfigurable(TypedArrayPrototype, "buffer");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/return-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/return-buffer.js
new file mode 100644
index 0000000000..aa17d649bf
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/return-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-get-%typedarray%.prototype.buffer
+description: >
+ Return buffer from [[ViewedArrayBuffer]] internal slot
+info: |
+ 22.2.3.1 get %TypedArray%.prototype.buffer
+
+ ...
+ 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot.
+ 5. Return buffer.
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT);
+ var ta = new TA(buffer);
+
+ assert.sameValue(ta.buffer, buffer);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/shell.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/this-has-no-typedarrayname-internal.js b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/this-has-no-typedarrayname-internal.js
new file mode 100644
index 0000000000..69844e2da1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/this-has-no-typedarrayname-internal.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-get-%typedarray%.prototype.buffer
+description: >
+ Throws a TypeError exception when `this` does not have a [[TypedArrayName]]
+ internal slot
+info: |
+ 22.2.3.1 get %TypedArray%.prototype.buffer
+
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+ 3. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [DataView, TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+var getter = Object.getOwnPropertyDescriptor(
+ TypedArrayPrototype, "buffer"
+).get;
+
+assert.throws(TypeError, function() {
+ getter.call({});
+});
+
+assert.throws(TypeError, function() {
+ getter.call([]);
+});
+
+var ab = new ArrayBuffer(8);
+assert.throws(TypeError, function() {
+ getter.call(ab);
+});
+
+var dv = new DataView(new ArrayBuffer(8), 0);
+assert.throws(TypeError, function() {
+ getter.call(dv);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/this-inherits-typedarray.js b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/this-inherits-typedarray.js
new file mode 100644
index 0000000000..27d44fee16
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/this-inherits-typedarray.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Google. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.buffer
+description: >
+ Throws a TypeError exception when `this` does not have a [[TypedArrayName]]
+ internal slot, even if its prototype does
+info: |
+ 22.2.3.1 get %TypedArray%.prototype.buffer
+
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+ 3. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+var getter = Object.getOwnPropertyDescriptor(
+ TypedArrayPrototype, "buffer"
+).get;
+
+testWithTypedArrayConstructors(TA => {
+ var typedArray = new TA(5);
+ var o = {};
+ Object.setPrototypeOf(o, typedArray);
+ assert.throws(TypeError, function() {
+ getter.call(o);
+ },
+ "Internal slot should not be inherited");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/this-is-not-object.js
new file mode 100644
index 0000000000..6f23eb7253
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/this-is-not-object.js
@@ -0,0 +1,50 @@
+// 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-get-%typedarray%.prototype.buffer
+description: Throws a TypeError exception when `this` is not Object
+info: |
+ 22.2.3.1 get %TypedArray%.prototype.buffer
+
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+var getter = Object.getOwnPropertyDescriptor(
+ TypedArrayPrototype, "buffer"
+).get;
+
+assert.throws(TypeError, function() {
+ getter.call(undefined);
+}, "this is undefined");
+
+assert.throws(TypeError, function() {
+ getter.call(null);
+}, "this is null");
+
+assert.throws(TypeError, function() {
+ getter.call(42);
+}, "this is 42");
+
+assert.throws(TypeError, function() {
+ getter.call("1");
+}, "this is a string");
+
+assert.throws(TypeError, function() {
+ getter.call(true);
+}, "this is true");
+
+assert.throws(TypeError, function() {
+ getter.call(false);
+}, "this is false");
+
+var s = Symbol("s");
+assert.throws(TypeError, function() {
+ getter.call(s);
+}, "this is a Symbol");
+
+reportCompare(0, 0);