summaryrefslogtreecommitdiff
path: root/test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt
diff options
context:
space:
mode:
Diffstat (limited to 'test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt')
-rw-r--r--test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt/detached-buffer-key-is-not-number.js38
-rw-r--r--test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt/detached-buffer-key-is-symbol.js31
-rw-r--r--test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt/detached-buffer-realm.js39
-rw-r--r--test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt/detached-buffer.js33
-rw-r--r--test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt/enumerate-detached-buffer.js42
-rw-r--r--test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt/index-prop-desc.js36
-rw-r--r--test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt/key-is-minus-zero.js37
-rw-r--r--test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt/key-is-not-canonical-index.js48
-rw-r--r--test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt/key-is-not-integer.js31
-rw-r--r--test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt/key-is-not-numeric-index.js38
-rw-r--r--test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt/key-is-out-of-bounds.js34
-rw-r--r--test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt/key-is-symbol.js31
12 files changed, 438 insertions, 0 deletions
diff --git a/test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt/detached-buffer-key-is-not-number.js b/test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt/detached-buffer-key-is-not-number.js
new file mode 100644
index 000000000..6f7ad44ab
--- /dev/null
+++ b/test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt/detached-buffer-key-is-not-number.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-integer-indexed-exotic-objects-getownproperty-p
+description: >
+ Does not throw on an instance with a detached buffer if key is not a number
+info: |
+ 9.4.5.1 [[GetOwnProperty]] ( P )
+
+ ...
+ 3. If Type(P) is String, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ ...
+ 4. Return OrdinaryGetOwnProperty(O, P).
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n]);
+ $DETACHBUFFER(sample.buffer);
+
+ assert.sameValue(
+ Object.getOwnPropertyDescriptor(sample, "undef"),
+ undefined,
+ "undefined property"
+ );
+
+ // Tests for the property descriptor are defined on the tests for
+ // [[DefineOwnProperty]] calls
+ Object.defineProperty(sample, "foo", { value: "bar" });
+ assert.sameValue(
+ Object.getOwnPropertyDescriptor(sample, "foo").value,
+ "bar",
+ "return value from a String key"
+ );
+});
diff --git a/test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt/detached-buffer-key-is-symbol.js b/test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt/detached-buffer-key-is-symbol.js
new file mode 100644
index 000000000..e316218f5
--- /dev/null
+++ b/test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt/detached-buffer-key-is-symbol.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-integer-indexed-exotic-objects-getownproperty-p
+description: >
+ Does not throw on an instance with a detached buffer if key is a Symbol
+info: |
+ 9.4.5.1 [[GetOwnProperty]] ( P )
+
+ ...
+ 3. If Type(P) is String, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ ...
+ 4. Return OrdinaryGetOwnProperty(O, P).
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n]);
+ $DETACHBUFFER(sample.buffer);
+
+ var s = Symbol("foo");
+ Object.defineProperty(sample, s, { value: "baz" });
+ assert.sameValue(
+ Object.getOwnPropertyDescriptor(sample, s).value,
+ "baz",
+ "return value from a Symbol key"
+ );
+});
diff --git a/test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt/detached-buffer-realm.js b/test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt/detached-buffer-realm.js
new file mode 100644
index 000000000..91c06732b
--- /dev/null
+++ b/test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt/detached-buffer-realm.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-integer-indexed-exotic-objects-getownproperty-p
+description: >
+ Throws a TypeError if this has a detached buffer (honoring the Realm of the
+ current execution context)
+info: |
+ 9.4.5.1 [[GetOwnProperty]] ( P )
+
+ ...
+ 3. If Type(P) is String, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ i. Let value be ? IntegerIndexedElementGet(O, numericIndex).
+ ...
+
+ 9.4.5.8 IntegerIndexedElementGet ( O, index )
+
+ ...
+ 3. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot.
+ 4. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, cross-realm, TypedArray]
+---*/
+
+var other = $262.createRealm().global;
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var OtherTA = other[TA.name];
+ var sample = new OtherTA(1);
+
+ $DETACHBUFFER(sample.buffer);
+
+ assert.throws(TypeError, function() {
+ Object.getOwnPropertyDescriptor(sample, 0);
+ });
+});
diff --git a/test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt/detached-buffer.js b/test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt/detached-buffer.js
new file mode 100644
index 000000000..5f14f0317
--- /dev/null
+++ b/test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt/detached-buffer.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-integer-indexed-exotic-objects-getownproperty-p
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 9.4.5.1 [[GetOwnProperty]] ( P )
+
+ ...
+ 3. If Type(P) is String, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ i. Let value be ? IntegerIndexedElementGet(O, numericIndex).
+ ...
+
+ 9.4.5.8 IntegerIndexedElementGet ( O, index )
+
+ ...
+ 3. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot.
+ 4. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+
+ assert.throws(TypeError, function() {
+ Object.getOwnPropertyDescriptor(sample, 0);
+ });
+});
diff --git a/test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt/enumerate-detached-buffer.js b/test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt/enumerate-detached-buffer.js
new file mode 100644
index 000000000..9523e3a5f
--- /dev/null
+++ b/test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt/enumerate-detached-buffer.js
@@ -0,0 +1,42 @@
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-integer-indexed-exotic-objects-getownproperty-p
+description: Test for-in enumeration with detached buffer.
+info: |
+ 9.4.5.1 [[GetOwnProperty]] ( P )
+ ...
+ 3. If Type(P) is String, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ i. Let value be ? IntegerIndexedElementGet(O, numericIndex).
+ ...
+
+ 9.4.5.8 IntegerIndexedElementGet ( O, index )
+ ...
+ 3. Let buffer be O.[[ViewedArrayBuffer]].
+ 4. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+
+ 13.7.5.15 EnumerateObjectProperties (O)
+ ...
+ EnumerateObjectProperties must obtain the own property keys of the
+ target object by calling its [[OwnPropertyKeys]] internal method.
+ Property attributes of the target object must be obtained by
+ calling its [[GetOwnProperty]] internal method.
+
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(42);
+ $DETACHBUFFER(sample.buffer);
+
+ assert.throws(TypeError, function() {
+ for (var key in sample) {
+ throw new Test262Error();
+ }
+ });
+});
diff --git a/test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt/index-prop-desc.js b/test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt/index-prop-desc.js
new file mode 100644
index 000000000..ad44eb8d3
--- /dev/null
+++ b/test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt/index-prop-desc.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-integer-indexed-exotic-objects-getownproperty-p
+description: >
+ Returns a descriptor object from an index property
+info: |
+ 9.4.5.1 [[GetOwnProperty]] ( P )
+
+ ...
+ 3. If Type(P) is String, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ ...
+ iii. Return a PropertyDescriptor{[[Value]]: value, [[Writable]]: true,
+ [[Enumerable]]: true, [[Configurable]]: false}.
+ ...
+includes: [testBigIntTypedArray.js, propertyHelper.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n]);
+
+ var desc0 = Object.getOwnPropertyDescriptor(sample, 0);
+ assert.sameValue(desc0.value, 42n, "value", "desc0.value === 42");
+ assert.sameValue(desc0.writable, true, "index descriptor is writable [0]");
+ verifyEnumerable(sample, "0", "index descriptor is enumerable [0]");
+ verifyNotConfigurable(sample, "0", "index descriptor is not configurable [0]");
+
+ var desc1 = Object.getOwnPropertyDescriptor(sample, 1);
+ assert.sameValue(desc1.value, 43n, "value", "desc1.value === 43");
+ assert.sameValue(desc1.writable, true, "index descriptor is writable [1]");
+ verifyEnumerable(sample, "1", "index descriptor is enumerable [1]");
+ verifyNotConfigurable(sample, "1", "index descriptor is not configurable [1]");
+});
diff --git a/test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt/key-is-minus-zero.js b/test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt/key-is-minus-zero.js
new file mode 100644
index 000000000..598deda2c
--- /dev/null
+++ b/test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt/key-is-minus-zero.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-integer-indexed-exotic-objects-getownproperty-p
+description: Returns undefined when P is -0.
+info: |
+ 9.4.5.1 [[GetOwnProperty]] ( P )
+
+ ...
+ 3. If Type(P) is String, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ i. Let value be ? IntegerIndexedElementGet(O, numericIndex).
+ ii. If value is undefined, return undefined.
+ ...
+
+ 7.1.16 CanonicalNumericIndexString ( argument )
+
+ ...
+ 2. If argument is "-0", return -0.
+ ...
+
+ 9.4.5.8 IntegerIndexedElementGet ( O, index )
+
+ ...
+ 6. If index = -0, return undefined.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n]);
+
+ // -0 as a number value is converted to "0" before calling [[GetOwnProperty]]
+ assert.sameValue(Object.getOwnPropertyDescriptor(sample, "-0"), undefined);
+});
diff --git a/test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt/key-is-not-canonical-index.js b/test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt/key-is-not-canonical-index.js
new file mode 100644
index 000000000..02f46bd6d
--- /dev/null
+++ b/test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt/key-is-not-canonical-index.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-integer-indexed-exotic-objects-getownproperty-p
+description: >
+ Returns an ordinary property value if numeric key is not a
+ CanonicalNumericIndex
+info: |
+ 9.4.5.1 [[GetOwnProperty]] ( P )
+
+ ...
+ 3. If Type(P) is String, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ ...
+ 4. Return OrdinaryGetOwnProperty(O, P).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var keys = [
+ "1.0",
+ "+1",
+ "1000000000000000000000",
+ "0.0000001"
+];
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ keys.forEach(function(key) {
+ var sample = new TA([42n, 43n]);
+
+ assert.sameValue(
+ Object.getOwnPropertyDescriptor(sample, key),
+ undefined,
+ "undefined property [" + key + "]"
+ );
+
+ // Tests for the property descriptor are defined on the tests for
+ // [[DefineOwnProperty]] calls
+ Object.defineProperty(sample, key, {value: "bar"});
+ assert.sameValue(
+ Object.getOwnPropertyDescriptor(sample, key).value,
+ "bar",
+ "return value from a ordinary property key [" + key + "]"
+ );
+ });
+});
diff --git a/test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt/key-is-not-integer.js b/test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt/key-is-not-integer.js
new file mode 100644
index 000000000..e52e033aa
--- /dev/null
+++ b/test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt/key-is-not-integer.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-integer-indexed-exotic-objects-getownproperty-p
+description: Returns undefined when P is not an integer.
+info: |
+ 9.4.5.1 [[GetOwnProperty]] ( P )
+
+ ...
+ 3. If Type(P) is String, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ i. Let value be ? IntegerIndexedElementGet(O, numericIndex).
+ ii. If value is undefined, return undefined.
+ ...
+
+ 9.4.5.8 IntegerIndexedElementGet ( O, index )
+
+ ...
+ 5. If IsInteger(index) is false, return undefined.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n]);
+
+ assert.sameValue(Object.getOwnPropertyDescriptor(sample, "1.1"), undefined);
+ assert.sameValue(Object.getOwnPropertyDescriptor(sample, "0.1"), undefined);
+});
diff --git a/test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt/key-is-not-numeric-index.js b/test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt/key-is-not-numeric-index.js
new file mode 100644
index 000000000..e65c23ad9
--- /dev/null
+++ b/test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt/key-is-not-numeric-index.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-integer-indexed-exotic-objects-getownproperty-p
+description: >
+ Returns an ordinary property value if key is not a CanonicalNumericIndex
+info: |
+ 9.4.5.1 [[GetOwnProperty]] ( P )
+
+ ...
+ 3. If Type(P) is String, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ ...
+ 4. Return OrdinaryGetOwnProperty(O, P).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n]);
+
+ assert.sameValue(
+ Object.getOwnPropertyDescriptor(sample, "undef"),
+ undefined,
+ "undefined property"
+ );
+
+ // Tests for the property descriptor are defined on the tests for
+ // [[DefineOwnProperty]] calls
+ Object.defineProperty(sample, "foo", { value: "bar" });
+ assert.sameValue(
+ Object.getOwnPropertyDescriptor(sample, "foo").value,
+ "bar",
+ "return value from a String key"
+ );
+});
diff --git a/test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt/key-is-out-of-bounds.js b/test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt/key-is-out-of-bounds.js
new file mode 100644
index 000000000..71e5d5ef7
--- /dev/null
+++ b/test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt/key-is-out-of-bounds.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-integer-indexed-exotic-objects-getownproperty-p
+description: Returns undefined when P is not a valid index number.
+info: |
+ 9.4.5.1 [[GetOwnProperty]] ( P )
+
+ ...
+ 3. If Type(P) is String, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ i. Let value be ? IntegerIndexedElementGet(O, numericIndex).
+ ii. If value is undefined, return undefined.
+ ...
+
+ 9.4.5.8 IntegerIndexedElementGet ( O, index )
+
+ ...
+ 7. Let length be the value of O's [[ArrayLength]] internal slot.
+ 8. If index < 0 or index ≥ length, return undefined.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n]);
+
+ assert.sameValue(Object.getOwnPropertyDescriptor(sample, "-1"), undefined);
+ assert.sameValue(Object.getOwnPropertyDescriptor(sample, "-42"), undefined);
+ assert.sameValue(Object.getOwnPropertyDescriptor(sample, "1"), undefined);
+ assert.sameValue(Object.getOwnPropertyDescriptor(sample, "42"), undefined);
+});
diff --git a/test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt/key-is-symbol.js b/test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt/key-is-symbol.js
new file mode 100644
index 000000000..c5509a0d9
--- /dev/null
+++ b/test/built-ins/TypedArrays/internals/GetOwnProperty/BigInt/key-is-symbol.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-integer-indexed-exotic-objects-getownproperty-p
+description: >
+ Returns an ordinary property value if key is a Symbol
+info: |
+ 9.4.5.1 [[GetOwnProperty]] ( P )
+
+ ...
+ 3. If Type(P) is String, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ ...
+ 4. Return OrdinaryGetOwnProperty(O, P).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n]);
+
+ var s = Symbol("foo");
+ Object.defineProperty(sample, s, { value: "baz" });
+ assert.sameValue(
+ Object.getOwnPropertyDescriptor(sample, s).value,
+ "baz",
+ "return value from a Symbol key"
+ );
+});