summaryrefslogtreecommitdiff
path: root/test/built-ins/TypedArray/prototype/length
diff options
context:
space:
mode:
Diffstat (limited to 'test/built-ins/TypedArray/prototype/length')
-rw-r--r--test/built-ins/TypedArray/prototype/length/BigInt/detached-buffer.js21
-rw-r--r--test/built-ins/TypedArray/prototype/length/BigInt/invoked-as-accessor.js23
-rw-r--r--test/built-ins/TypedArray/prototype/length/BigInt/invoked-as-func.js23
-rw-r--r--test/built-ins/TypedArray/prototype/length/BigInt/length.js32
-rw-r--r--test/built-ins/TypedArray/prototype/length/BigInt/name.js29
-rw-r--r--test/built-ins/TypedArray/prototype/length/BigInt/prop-desc.js24
-rw-r--r--test/built-ins/TypedArray/prototype/length/BigInt/return-length.js28
-rw-r--r--test/built-ins/TypedArray/prototype/length/BigInt/this-has-no-typedarrayname-internal.js41
-rw-r--r--test/built-ins/TypedArray/prototype/length/BigInt/this-is-not-object.js49
-rw-r--r--test/built-ins/TypedArray/prototype/length/invoked-as-accessor.js2
-rw-r--r--test/built-ins/TypedArray/prototype/length/invoked-as-func.js2
-rw-r--r--test/built-ins/TypedArray/prototype/length/length.js3
-rw-r--r--test/built-ins/TypedArray/prototype/length/name.js3
-rw-r--r--test/built-ins/TypedArray/prototype/length/prop-desc.js3
14 files changed, 278 insertions, 5 deletions
diff --git a/test/built-ins/TypedArray/prototype/length/BigInt/detached-buffer.js b/test/built-ins/TypedArray/prototype/length/BigInt/detached-buffer.js
new file mode 100644
index 000000000..31ee55484
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/length/BigInt/detached-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-get-%typedarray%.prototype.length
+description: Returns 0 if the instance has a detached buffer
+info: |
+ 22.2.3.18 get %TypedArray%.prototype.length
+
+ ...
+ 5. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot.
+ 6. If IsDetachedBuffer(buffer) is true, return 0.
+ ...
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(42);
+ $DETACHBUFFER(sample.buffer);
+ assert.sameValue(sample.length, 0);
+});
diff --git a/test/built-ins/TypedArray/prototype/length/BigInt/invoked-as-accessor.js b/test/built-ins/TypedArray/prototype/length/BigInt/invoked-as-accessor.js
new file mode 100644
index 000000000..d67d24370
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/length/BigInt/invoked-as-accessor.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.length
+description: >
+ Requires this value to have a [[ViewedArrayBuffer]] internal slot
+info: |
+ 22.2.3.17 get %TypedArray%.prototype.length
+
+ 1. Let O be the this value.
+ ...
+ 3. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+assert.throws(TypeError, function() {
+ TypedArrayPrototype.length;
+});
diff --git a/test/built-ins/TypedArray/prototype/length/BigInt/invoked-as-func.js b/test/built-ins/TypedArray/prototype/length/BigInt/invoked-as-func.js
new file mode 100644
index 000000000..100bf4c55
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/length/BigInt/invoked-as-func.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.length
+description: Throws a TypeError exception when invoked as a function
+info: |
+ 22.2.3.17 get %TypedArray%.prototype.length
+
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+var getter = Object.getOwnPropertyDescriptor(
+ TypedArrayPrototype, 'length'
+).get;
+
+assert.throws(TypeError, function() {
+ getter();
+});
diff --git a/test/built-ins/TypedArray/prototype/length/BigInt/length.js b/test/built-ins/TypedArray/prototype/length/BigInt/length.js
new file mode 100644
index 000000000..832fba4a9
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/length/BigInt/length.js
@@ -0,0 +1,32 @@
+// 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.length
+description: >
+ get %TypedArray%.prototype.length.length is 0.
+info: |
+ get %TypedArray%.prototype.length
+
+ 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, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var desc = Object.getOwnPropertyDescriptor(TypedArray.prototype, "length");
+
+assert.sameValue(desc.get.length, 0);
+
+verifyNotEnumerable(desc.get, "length");
+verifyNotWritable(desc.get, "length");
+verifyConfigurable(desc.get, "length");
diff --git a/test/built-ins/TypedArray/prototype/length/BigInt/name.js b/test/built-ins/TypedArray/prototype/length/BigInt/name.js
new file mode 100644
index 000000000..f7f29be88
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/length/BigInt/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.
+
+/*---
+esid: sec-get-%typedarray%.prototype.length
+description: >
+ get %TypedArray%.prototype.length.name is "get length".
+info: |
+ get %TypedArray%.prototype.length
+
+ 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, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var desc = Object.getOwnPropertyDescriptor(TypedArray.prototype, "length");
+
+assert.sameValue(desc.get.name, "get length");
+
+verifyNotEnumerable(desc.get, "name");
+verifyNotWritable(desc.get, "name");
+verifyConfigurable(desc.get, "name");
diff --git a/test/built-ins/TypedArray/prototype/length/BigInt/prop-desc.js b/test/built-ins/TypedArray/prototype/length/BigInt/prop-desc.js
new file mode 100644
index 000000000..2afd62048
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/length/BigInt/prop-desc.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.length
+description: >
+ "length" property of TypedArrayPrototype
+info: |
+ %TypedArray%.prototype.length 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, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+var desc = Object.getOwnPropertyDescriptor(TypedArrayPrototype, "length");
+
+assert.sameValue(desc.set, undefined);
+assert.sameValue(typeof desc.get, "function");
+
+verifyNotEnumerable(TypedArrayPrototype, "length");
+verifyConfigurable(TypedArrayPrototype, "length");
diff --git a/test/built-ins/TypedArray/prototype/length/BigInt/return-length.js b/test/built-ins/TypedArray/prototype/length/BigInt/return-length.js
new file mode 100644
index 000000000..419acd0f6
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/length/BigInt/return-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-get-%typedarray%.prototype.length
+description: >
+ Return value from the [[ArrayLength]] internal slot
+info: |
+ 22.2.3.18 get %TypedArray%.prototype.length
+
+ ...
+ 6. Let length be the value of O's [[ArrayLength]] internal slot.
+ 7. Return length.
+
+ ---
+
+ The current tests on `prop-desc.js` and `length.js` already assert `length` is
+ not a dynamic property as in regular arrays.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var ta1 = new TA();
+ assert.sameValue(ta1.length, 0);
+
+ var ta2 = new TA(42);
+ assert.sameValue(ta2.length, 42);
+});
diff --git a/test/built-ins/TypedArray/prototype/length/BigInt/this-has-no-typedarrayname-internal.js b/test/built-ins/TypedArray/prototype/length/BigInt/this-has-no-typedarrayname-internal.js
new file mode 100644
index 000000000..1dd1d7696
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/length/BigInt/this-has-no-typedarrayname-internal.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-get-%typedarray%.prototype.length
+description: >
+ Throws a TypeError exception when `this` does not have a [[TypedArrayName]]
+ internal slot
+info: |
+ 22.2.3.18 get %TypedArray%.prototype.length
+
+ 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: [testBigIntTypedArray.js]
+features: [BigInt, DataView, TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+var getter = Object.getOwnPropertyDescriptor(
+ TypedArrayPrototype, "length"
+).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);
+});
diff --git a/test/built-ins/TypedArray/prototype/length/BigInt/this-is-not-object.js b/test/built-ins/TypedArray/prototype/length/BigInt/this-is-not-object.js
new file mode 100644
index 000000000..663a6402b
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/length/BigInt/this-is-not-object.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-get-%typedarray%.prototype.length
+description: Throws a TypeError exception when `this` is not Object
+info: |
+ 22.2.3.18 get %TypedArray%.prototype.length
+
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+var getter = Object.getOwnPropertyDescriptor(
+ TypedArrayPrototype, "length"
+).get;
+
+
+assert.throws(TypeError, function() {
+ getter.call(undefined);
+}, "undefined");
+
+assert.throws(TypeError, function() {
+ getter.call(null);
+}, "null");
+
+assert.throws(TypeError, function() {
+ getter.call(42);
+}, "number");
+
+assert.throws(TypeError, function() {
+ getter.call("1");
+}, "string");
+
+assert.throws(TypeError, function() {
+ getter.call(true);
+}, "true");
+
+assert.throws(TypeError, function() {
+ getter.call(false);
+}, "false");
+
+var s = Symbol("s");
+assert.throws(TypeError, function() {
+ getter.call(s);
+}, "symbol");
diff --git a/test/built-ins/TypedArray/prototype/length/invoked-as-accessor.js b/test/built-ins/TypedArray/prototype/length/invoked-as-accessor.js
index 731737656..cc13ea81c 100644
--- a/test/built-ins/TypedArray/prototype/length/invoked-as-accessor.js
+++ b/test/built-ins/TypedArray/prototype/length/invoked-as-accessor.js
@@ -1,7 +1,7 @@
// 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.3.17
+esid: sec-get-%typedarray%.prototype.length
description: >
Requires this value to have a [[ViewedArrayBuffer]] internal slot
info: |
diff --git a/test/built-ins/TypedArray/prototype/length/invoked-as-func.js b/test/built-ins/TypedArray/prototype/length/invoked-as-func.js
index 7f94fd1bb..4606e730e 100644
--- a/test/built-ins/TypedArray/prototype/length/invoked-as-func.js
+++ b/test/built-ins/TypedArray/prototype/length/invoked-as-func.js
@@ -1,7 +1,7 @@
// 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.3.17
+esid: sec-get-%typedarray%.prototype.length
description: Throws a TypeError exception when invoked as a function
info: |
22.2.3.17 get %TypedArray%.prototype.length
diff --git a/test/built-ins/TypedArray/prototype/length/length.js b/test/built-ins/TypedArray/prototype/length/length.js
index 43ac09dc6..83477ed19 100644
--- a/test/built-ins/TypedArray/prototype/length/length.js
+++ b/test/built-ins/TypedArray/prototype/length/length.js
@@ -2,7 +2,7 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
-es6id: 22.2.3.17
+esid: sec-get-%typedarray%.prototype.length
description: >
get %TypedArray%.prototype.length.length is 0.
info: |
@@ -20,6 +20,7 @@ info: |
object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
[[Configurable]]: true }.
includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
---*/
var desc = Object.getOwnPropertyDescriptor(TypedArray.prototype, "length");
diff --git a/test/built-ins/TypedArray/prototype/length/name.js b/test/built-ins/TypedArray/prototype/length/name.js
index d9d6605da..733f7c4ea 100644
--- a/test/built-ins/TypedArray/prototype/length/name.js
+++ b/test/built-ins/TypedArray/prototype/length/name.js
@@ -2,7 +2,7 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
-es6id: 22.2.3.17
+esid: sec-get-%typedarray%.prototype.length
description: >
get %TypedArray%.prototype.length.name is "get length".
info: |
@@ -17,6 +17,7 @@ info: |
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, "length");
diff --git a/test/built-ins/TypedArray/prototype/length/prop-desc.js b/test/built-ins/TypedArray/prototype/length/prop-desc.js
index 290311346..eb3284e68 100644
--- a/test/built-ins/TypedArray/prototype/length/prop-desc.js
+++ b/test/built-ins/TypedArray/prototype/length/prop-desc.js
@@ -1,7 +1,7 @@
// 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.3.17
+esid: sec-get-%typedarray%.prototype.length
description: >
"length" property of TypedArrayPrototype
info: |
@@ -11,6 +11,7 @@ info: |
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;