summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt')
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/desc-value-throws.js54
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/detached-buffer-throws-realm.js54
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/detached-buffer-throws.js50
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/detached-buffer.js122
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-greater-than-last-index.js49
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-lower-than-zero.js36
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-minus-zero.js38
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-not-canonical-index.js100
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-not-integer.js126
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-not-numeric-index-throws.js47
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-not-numeric-index.js54
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-numericindex-accessor-desc-throws.js46
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-numericindex-accessor-desc.js60
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-numericindex-desc-configurable.js38
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-numericindex-desc-not-configurable-throws.js41
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-numericindex-desc-not-enumerable-throws.js41
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-numericindex-desc-not-enumerable.js37
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-numericindex-desc-not-writable-throws.js41
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-numericindex-desc-not-writable.js37
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-numericindex.js40
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-symbol.js56
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/non-extensible-new-key.js46
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/non-extensible-redefine-key.js59
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/set-value.js57
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/shell.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/this-is-not-extensible.js33
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/tonumber-value-detached-buffer.js61
28 files changed, 1465 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/browser.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/desc-value-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/desc-value-throws.js
new file mode 100644
index 0000000000..687ae5e5ef
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/desc-value-throws.js
@@ -0,0 +1,54 @@
+// 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-defineownproperty-p-desc
+description: >
+ Return abrupt from the evaluation of ToNumber(desc.value)
+info: |
+ 9.4.5.3 [[DefineOwnProperty]] ( P, Desc)
+ ...
+ 3. If Type(P) is String, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ ...
+ xi. If Desc has a [[Value]] field, then
+ 1. Let value be Desc.[[Value]].
+ 2. Return ? IntegerIndexedElementSet(O, intIndex, value).
+ ...
+
+ IntegerIndexedElementSet ( O, index, value )
+
+ Assert: O is an Integer-Indexed exotic object.
+ If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value).
+ Otherwise, let numValue be ? ToNumber(value).
+ Let buffer be O.[[ViewedArrayBuffer]].
+ If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then
+ Let offset be O.[[ByteOffset]].
+ Let arrayTypeName be the String value of O.[[TypedArrayName]].
+ Let elementSize be the Element Size value specified in Table 62 for arrayTypeName.
+ Let indexedPosition be (ℝ(index) × elementSize) + offset.
+ Let elementType be the Element Type value in Table 62 for arrayTypeName.
+ Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue, true, Unordered).
+ Return NormalCompletion(undefined).
+
+ Return NormalCompletion(undefined).
+
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var obj = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n]);
+
+ assert.throws(Test262Error, function() {
+ Object.defineProperty(sample, "0", {value: obj});
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/detached-buffer-throws-realm.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/detached-buffer-throws-realm.js
new file mode 100644
index 0000000000..2a17145caf
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/detached-buffer-throws-realm.js
@@ -0,0 +1,54 @@
+// 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-defineownproperty-p-desc
+description: >
+ Throws TypeError for valid descriptor & canonical numeric string if buffer is detached.
+ (honoring the Realm of the current execution context)
+info: |
+ [[DefineOwnProperty]] ( P, Desc )
+
+ [...]
+ 3. If Type(P) is String, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ i. If ! IsValidIntegerIndex(O, numericIndex) is false, return false.
+
+ IsValidIntegerIndex ( O, index )
+
+ [...]
+ 2. If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, return false.
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray]
+---*/
+
+var other = $262.createRealm().global;
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var OtherTA = other[TA.name];
+ var sample = new OtherTA([0n]);
+ var desc = Object.getOwnPropertyDescriptor(sample, "0");
+ $DETACHBUFFER(sample.buffer);
+
+ assert.throws(TypeError, function() {
+ Object.defineProperty(sample, "0", desc);
+ });
+
+ assert.throws(TypeError, function() {
+ Object.defineProperty(sample, "1", desc);
+ });
+
+ assert.throws(TypeError, function() {
+ Object.defineProperty(sample, "-1", desc);
+ });
+
+ assert.throws(TypeError, function() {
+ Object.defineProperty(sample, "1.5", desc);
+ });
+
+ assert.throws(TypeError, function() {
+ Object.defineProperty(sample, "-0", desc);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/detached-buffer-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/detached-buffer-throws.js
new file mode 100644
index 0000000000..747595e86b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/detached-buffer-throws.js
@@ -0,0 +1,50 @@
+// Copyright (C) 2021 Alexey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-integer-indexed-exotic-objects-defineownproperty-p-desc
+description: >
+ Throws TypeError for valid descriptor & canonical numeric string if buffer is detached.
+info: |
+ [[DefineOwnProperty]] ( P, Desc )
+
+ [...]
+ 3. If Type(P) is String, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ i. If ! IsValidIntegerIndex(O, numericIndex) is false, return false.
+
+ IsValidIntegerIndex ( O, index )
+
+ [...]
+ 2. If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, return false.
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([0n]);
+ var desc = Object.getOwnPropertyDescriptor(sample, "0");
+ $DETACHBUFFER(sample.buffer);
+
+ assert.throws(TypeError, function() {
+ Object.defineProperty(sample, "0", desc);
+ });
+
+ assert.throws(TypeError, function() {
+ Object.defineProperty(sample, "1", desc);
+ });
+
+ assert.throws(TypeError, function() {
+ Object.defineProperty(sample, "-1", desc);
+ });
+
+ assert.throws(TypeError, function() {
+ Object.defineProperty(sample, "1.5", desc);
+ });
+
+ assert.throws(TypeError, function() {
+ Object.defineProperty(sample, "-0", desc);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/detached-buffer.js
new file mode 100644
index 0000000000..b857d4c3a1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/detached-buffer.js
@@ -0,0 +1,122 @@
+// 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-defineownproperty-p-desc
+description: >
+ Returns false if this has valid numeric index and a detached buffer
+info: |
+ 9.4.5.3 [[DefineOwnProperty]] ( P, Desc)
+ ...
+ 3. If Type(P) is String, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ ...
+ xi. If Desc has a [[Value]] field, then
+ 1. Let value be Desc.[[Value]].
+ 2. Return ? IntegerIndexedElementSet(O, intIndex, value).
+ ...
+
+ IntegerIndexedElementSet ( O, index, value )
+
+ Assert: O is an Integer-Indexed exotic object.
+ If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value).
+ Otherwise, let numValue be ? ToNumber(value).
+ Let buffer be O.[[ViewedArrayBuffer]].
+ If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then
+ Let offset be O.[[ByteOffset]].
+ Let arrayTypeName be the String value of O.[[TypedArrayName]].
+ Let elementSize be the Element Size value specified in Table 62 for arrayTypeName.
+ Let indexedPosition be (ℝ(index) × elementSize) + offset.
+ Let elementType be the Element Type value in Table 62 for arrayTypeName.
+ Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue, true, Unordered).
+ Return NormalCompletion(undefined).
+
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [align-detached-buffer-semantics-with-web-reality, BigInt, Reflect, TypedArray]
+---*/
+var desc = {
+ value: 0n,
+ configurable: false,
+ enumerable: true,
+ writable: true
+};
+
+var obj = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(42);
+ $DETACHBUFFER(sample.buffer);
+
+ assert.sameValue(
+ Reflect.defineProperty(sample, '0', desc),
+ false,
+ 'Reflect.defineProperty(sample, "0", {value: 0n, configurable: false, enumerable: true, writable: true}) must return false'
+ );
+
+ assert.sameValue(
+ Reflect.defineProperty(sample, '-1', desc),
+ false,
+ 'Reflect.defineProperty(sample, "-1", {value: 0n, configurable: false, enumerable: true, writable: true}) must return false'
+ );
+
+ assert.sameValue(
+ Reflect.defineProperty(sample, '1.1', desc),
+ false,
+ 'Reflect.defineProperty(sample, "1.1", {value: 0n, configurable: false, enumerable: true, writable: true}) must return false'
+ );
+
+ assert.sameValue(
+ Reflect.defineProperty(sample, '-0', desc),
+ false,
+ 'Reflect.defineProperty(sample, "-0", {value: 0n, configurable: false, enumerable: true, writable: true}) must return false'
+ );
+
+ assert.sameValue(Reflect.defineProperty(sample, '2', {
+ configurable: true,
+ enumerable: true,
+ writable: true,
+ value: obj
+ }), false, 'Reflect.defineProperty(sample, "2", {configurable: true, enumerable: true, writable: true, value: obj}) must return false');
+
+ assert.sameValue(Reflect.defineProperty(sample, '3', {
+ configurable: false,
+ enumerable: false,
+ writable: true,
+ value: obj
+ }), false, 'Reflect.defineProperty(sample, "3", {configurable: false, enumerable: false, writable: true, value: obj}) must return false');
+
+ assert.sameValue(Reflect.defineProperty(sample, '4', {
+ writable: false,
+ configurable: false,
+ enumerable: true,
+ value: obj
+ }), false, 'Reflect.defineProperty(sample, "4", {writable: false, configurable: false, enumerable: true, value: obj}) must return false');
+
+ assert.sameValue(
+ Reflect.defineProperty(sample, '42', desc),
+ false,
+ 'Reflect.defineProperty(sample, "42", {value: 0n, configurable: false, enumerable: true, writable: true}) must return false'
+ );
+
+ assert.sameValue(
+ Reflect.defineProperty(sample, '43', desc),
+ false,
+ 'Reflect.defineProperty(sample, "43", {value: 0n, configurable: false, enumerable: true, writable: true}) must return false'
+ );
+
+ assert.sameValue(Reflect.defineProperty(sample, '5', {
+ get: function() {}
+ }), false, 'Reflect.defineProperty(sample, "5", {get: function() {}}) must return false');
+
+ assert.sameValue(Reflect.defineProperty(sample, '6', {
+ configurable: false,
+ enumerable: true,
+ writable: true
+ }), false, 'Reflect.defineProperty(sample, "6", {configurable: false, enumerable: true, writable: true}) must return false');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-greater-than-last-index.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-greater-than-last-index.js
new file mode 100644
index 0000000000..08799367b7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-greater-than-last-index.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-integer-indexed-exotic-objects-defineownproperty-p-desc
+description: >
+ Returns false if numericIndex is >= [[ArrayLength]]
+info: |
+ 9.4.5.3 [[DefineOwnProperty]] ( P, Desc)
+ ...
+ 3. If Type(P) is String, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ ...
+ ii. Let intIndex be numericIndex.
+ ...
+ v. Let length be the value of O's [[ArrayLength]] internal slot.
+ vi. If intIndex ≥ length, return false.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Reflect, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n]);
+
+ assert.sameValue(
+ Reflect.defineProperty(sample, "2", {
+ value: 42n,
+ configurable: false,
+ enumerable: true,
+ writable: true
+ }),
+ false,
+ "numericIndex == length"
+ );
+
+ assert.sameValue(
+ Reflect.defineProperty(sample, "3", {
+ value: 42n,
+ configurable: false,
+ enumerable: true,
+ writable: true
+ }),
+ false,
+ "numericIndex > length"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-lower-than-zero.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-lower-than-zero.js
new file mode 100644
index 0000000000..b7e490c51d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-lower-than-zero.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-defineownproperty-p-desc
+description: >
+ Returns false if numericIndex is < 0
+info: |
+ 9.4.5.3 [[DefineOwnProperty]] ( P, Desc)
+ ...
+ 3. If Type(P) is String, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ ...
+ ii. Let intIndex be numericIndex.
+ iv. If intIndex < 0, return false.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Reflect, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n]);
+
+ assert.sameValue(
+ Reflect.defineProperty(sample, "-1", {
+ value: 42n,
+ configurable: false,
+ enumerable: true,
+ writable: true
+ }),
+ false,
+ "-1"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-minus-zero.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-minus-zero.js
new file mode 100644
index 0000000000..5dadc628c6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-minus-zero.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-defineownproperty-p-desc
+description: >
+ Returns false if numericIndex is "-0"
+info: |
+ 9.4.5.3 [[DefineOwnProperty]] ( P, Desc)
+ ...
+ 3. If Type(P) is String, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ i. If IsInteger(numericIndex) is false, return false.
+ ii. Let intIndex be numericIndex.
+ iii. If intIndex = -0, return false.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Reflect, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ assert.sameValue(
+ Reflect.defineProperty(sample, "-0", {
+ value: 42n,
+ configurable: false,
+ enumerable: true,
+ writable: true
+ }),
+ false,
+ "defineProperty returns false"
+ );
+ assert.sameValue(sample[0], 0n, "does not change the value for [0]");
+ assert.sameValue(sample["-0"], undefined, "does define a value for ['-0']");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-not-canonical-index.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-not-canonical-index.js
new file mode 100644
index 0000000000..7fdad5a989
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-not-canonical-index.js
@@ -0,0 +1,100 @@
+// 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-defineownproperty-p-desc
+description: >
+ Sets an ordinary property value if numeric key is not a CanonicalNumericIndex
+info: |
+ 9.4.5.3 [[DefineOwnProperty]] ( P, Desc)
+ ...
+ 3. If Type(P) is String, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ ...
+ 4. Return OrdinaryDefineOwnProperty(O, P, Desc).
+ ...
+includes: [testBigIntTypedArray.js, propertyHelper.js]
+features: [BigInt, Reflect, TypedArray]
+---*/
+
+var keys = [
+ "1.0",
+ "+1",
+ "1000000000000000000000",
+ "0.0000001"
+];
+
+var fnset = function() {};
+var fnget = function() {};
+
+var acDesc = {
+ get: fnget,
+ set: fnset,
+ enumerable: true,
+ configurable: false
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ keys.forEach(function(key) {
+ var dataDesc = {
+ value: 42n,
+ writable: true,
+ configurable: true
+ };
+
+ var sample1 = new TA();
+
+ assert.sameValue(
+ Reflect.defineProperty(sample1, key, dataDesc),
+ true,
+ "return true after defining data property [" + key + "]"
+ );
+
+ assert.sameValue(sample1[key], 42n, "value is set to [" + key + "]");
+ verifyNotEnumerable(sample1, key);
+ verifyWritable(sample1, key);
+ verifyConfigurable(sample1, key);
+
+ assert.sameValue(sample1[0], undefined, "no value is set on sample1[0]");
+ assert.sameValue(sample1.length, 0, "length is still 0");
+
+ var sample2 = new TA();
+
+ assert.sameValue(
+ Reflect.defineProperty(sample2, key, acDesc),
+ true,
+ "return true after defining accessors property [" + key + "]"
+ );
+
+ var desc = Object.getOwnPropertyDescriptor(sample2, key);
+ verifyEnumerable(sample2, key);
+ assert.sameValue(desc.get, fnget, "accessor's get [" + key + "]");
+ assert.sameValue(desc.set, fnset, "accessor's set [" + key + "]");
+ verifyNotConfigurable(sample2, key);
+
+ assert.sameValue(sample2[0], undefined,"no value is set on sample2[0]");
+ assert.sameValue(sample2.length, 0, "length is still 0");
+
+ var sample3 = new TA();
+ Object.preventExtensions(sample3);
+
+ assert.sameValue(
+ Reflect.defineProperty(sample3, key, dataDesc),
+ false,
+ "return false defining property on a non-extensible sample"
+ );
+ assert.sameValue(Object.getOwnPropertyDescriptor(sample3, key), undefined);
+
+ var sample4 = new TA();
+ Object.preventExtensions(sample4);
+
+ assert.sameValue(
+ Reflect.defineProperty(sample4, key, acDesc),
+ false,
+ "return false defining property on a non-extensible sample"
+ );
+ assert.sameValue(Object.getOwnPropertyDescriptor(sample4, key), undefined);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-not-integer.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-not-integer.js
new file mode 100644
index 0000000000..c0c53679d0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-not-integer.js
@@ -0,0 +1,126 @@
+// 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-defineownproperty-p-desc
+description: >
+ Returns false if numericIndex is not an integer
+info: |
+ 9.4.5.3 [[DefineOwnProperty]] ( P, Desc)
+ ...
+ 3. If Type(P) is String, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ i. If IsInteger(numericIndex) is false, return false.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Reflect, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ assert.sameValue(
+ Reflect.defineProperty(sample, "0.1", {
+ value: 42n,
+ configurable: false,
+ enumerable: true,
+ writable: true
+ }),
+ false,
+ "0.1"
+ );
+ assert.sameValue(sample[0], 0n, "'0.1' - does not change the value for [0]");
+ assert.sameValue(
+ sample["0.1"],
+ undefined,
+ "'0.1' - does not define a value for ['0.1']"
+ );
+
+ assert.sameValue(
+ Reflect.defineProperty(sample, "0.000001", {
+ value: 42n,
+ configurable: false,
+ enumerable: true,
+ writable: true
+ }),
+ false,
+ "0.000001"
+ );
+ assert.sameValue(
+ sample[0], 0n,
+ "'0.000001' - does not change the value for [0]"
+ );
+ assert.sameValue(
+ sample["0.000001"],
+ undefined,
+ "'0.000001' - does not define a value for ['0.000001']"
+ );
+
+ assert.sameValue(
+ Reflect.defineProperty(sample, "1.1", {
+ value: 42n,
+ configurable: false,
+ enumerable: true,
+ writable: true
+ }),
+ false,
+ "1.1"
+ );
+ assert.sameValue(sample[1], 0n, "'1.1' - does not change the value for [1]");
+ assert.sameValue(
+ sample["1.1"],
+ undefined,
+ "'1.1' - does not define a value for ['1.1']"
+ );
+
+ assert.sameValue(
+ Reflect.defineProperty(sample, "Infinity", {
+ value: 42n,
+ configurable: false,
+ enumerable: true,
+ writable: true
+ }),
+ false,
+ "Infinity"
+ );
+ assert.sameValue(
+ sample[0], 0n,
+ "'Infinity' - does not change the value for [0]"
+ );
+ assert.sameValue(
+ sample[1], 0n,
+ "'Infinity' - does not change the value for [1]"
+ );
+ assert.sameValue(
+ sample["Infinity"],
+ undefined,
+ "'Infinity' - does not define a value for ['Infinity']"
+ );
+
+ assert.sameValue(
+ Reflect.defineProperty(sample, "-Infinity", {
+ value: 42n,
+ configurable: false,
+ enumerable: true,
+ writable: true
+ }),
+ false,
+ "-Infinity"
+ );
+ assert.sameValue(
+ sample[0], 0n,
+ "'-Infinity' - does not change the value for [0]"
+ );
+ assert.sameValue(
+ sample[1], 0n,
+ "'-Infinity' - does not change the value for [1]"
+ );
+ assert.sameValue(
+ sample["-Infinity"],
+ undefined,
+ "'-Infinity' - does not define a value for ['-Infinity']"
+ );
+
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-not-numeric-index-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-not-numeric-index-throws.js
new file mode 100644
index 0000000000..272c7e74f9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-not-numeric-index-throws.js
@@ -0,0 +1,47 @@
+// Copyright (C) 2021 Alexey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-integer-indexed-exotic-objects-defineownproperty-p-desc
+description: >
+ Throws TypeError for valid descriptor & canonical numeric string that is invalid index.
+info: |
+ [[DefineOwnProperty]] ( P, Desc )
+
+ [...]
+ 3. If Type(P) is String, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ i. If ! IsValidIntegerIndex(O, numericIndex) is false, return false.
+
+ IsValidIntegerIndex ( O, index )
+
+ [...]
+ 3. If ! IsIntegralNumber(index) is false, return false.
+ 4. If index is -0𝔽, return false.
+ 5. If ℝ(index) < 0 or ℝ(index) ≥ O.[[ArrayLength]], return false.
+includes: [testBigIntTypedArray.js]
+features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([0n]);
+ var desc = Object.getOwnPropertyDescriptor(sample, "0");
+
+ assert.throws(TypeError, function() {
+ Object.defineProperty(sample, "1", desc);
+ });
+
+ assert.throws(TypeError, function() {
+ Object.defineProperty(sample, "-1", desc);
+ });
+
+ assert.throws(TypeError, function() {
+ Object.defineProperty(sample, "1.5", desc);
+ });
+
+ assert.throws(TypeError, function() {
+ Object.defineProperty(sample, "-0", desc);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-not-numeric-index.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-not-numeric-index.js
new file mode 100644
index 0000000000..c2d3b19e17
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-not-numeric-index.js
@@ -0,0 +1,54 @@
+// 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-defineownproperty-p-desc
+description: >
+ Returns an ordinary property value if key is not a CanonicalNumericIndex
+info: |
+ 9.4.5.3 [[DefineOwnProperty]] ( P, Desc)
+ ...
+ 3. If Type(P) is String, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ ...
+ 4. Return OrdinaryDefineOwnProperty(O, P, Desc).
+ ...
+includes: [testBigIntTypedArray.js, propertyHelper.js]
+features: [BigInt, Reflect, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n]);
+
+ assert.sameValue(
+ Reflect.defineProperty(sample, "foo", {value:42}),
+ true,
+ "return true after defining property"
+ );
+
+ assert.sameValue(sample.foo, 42);
+ verifyNotWritable(sample, "foo");
+ verifyNotConfigurable(sample, "foo");
+ verifyNotEnumerable(sample, "foo");
+
+ var fnset = function() {};
+ var fnget = function() {};
+ assert.sameValue(
+ Reflect.defineProperty(sample, "bar", {
+ get: fnget,
+ set: fnset,
+ enumerable: false,
+ configurable: true
+ }),
+ true,
+ "return true after defining property"
+ );
+
+ var desc = Object.getOwnPropertyDescriptor(sample, "bar");
+ assert.sameValue(desc.get, fnget, "accessor's get");
+ assert.sameValue(desc.set, fnset, "accessor's set");
+ verifyNotEnumerable(sample, "bar");
+ verifyConfigurable(sample, "bar");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-numericindex-accessor-desc-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-numericindex-accessor-desc-throws.js
new file mode 100644
index 0000000000..6093419b97
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-numericindex-accessor-desc-throws.js
@@ -0,0 +1,46 @@
+// Copyright (C) 2021 Alexey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-integer-indexed-exotic-objects-defineownproperty-p-desc
+description: >
+ Throws TypeError for valid index & accessor descriptor.
+info: |
+ [[DefineOwnProperty]] ( P, Desc )
+
+ [...]
+ 3. If Type(P) is String, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ [...]
+ iv. If IsAccessorDescriptor(Desc) is true, return false.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([0n]);
+
+ assert.throws(TypeError, function() {
+ Object.defineProperty(sample, "0", {
+ get: function() { return 42n; },
+ });
+ }, "get accessor");
+ assert.sameValue(sample[0], 0n, "get accessor - side effect check");
+
+ assert.throws(TypeError, function() {
+ Object.defineProperty(sample, "0", {
+ set: function(_v) {},
+ });
+ }, "set accessor");
+ assert.sameValue(sample[0], 0n, "set accessor - side effect check");
+
+ assert.throws(TypeError, function() {
+ Object.defineProperty(sample, "0", {
+ get: function() { return 42n; },
+ set: function(_v) {},
+ });
+ }, "get and set accessors");
+ assert.sameValue(sample[0], 0n, "get and set accessors - side effect check");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-numericindex-accessor-desc.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-numericindex-accessor-desc.js
new file mode 100644
index 0000000000..073c905f19
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-numericindex-accessor-desc.js
@@ -0,0 +1,60 @@
+// 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-defineownproperty-p-desc
+description: >
+ Returns false if key is a numeric index and Descriptor is an
+ AccessorDescriptor
+info: |
+ 9.4.5.3 [[DefineOwnProperty]] ( P, Desc)
+ ...
+ 3. If Type(P) is String, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ ...
+ vii. If IsAccessorDescriptor(Desc) is true, return false.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Reflect, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ assert.sameValue(
+ Reflect.defineProperty(sample, "0", {
+ get: function() {
+ return 42;
+ },
+ enumerable: true
+ }),
+ false,
+ "get accessor"
+ );
+ assert.sameValue(sample[0], 0n, "get accessor - side effect check");
+
+ assert.sameValue(
+ Reflect.defineProperty(sample, "0", {
+ set: function() {},
+ enumerable: true
+ }),
+ false,
+ "set accessor"
+ );
+ assert.sameValue(sample[0], 0n, "set accessor - side effect check");
+
+ assert.sameValue(
+ Reflect.defineProperty(sample, "0", {
+ set: function() {},
+ get: function() {
+ return 42;
+ },
+ enumerable: true
+ }),
+ false,
+ "get and set accessors"
+ );
+ assert.sameValue(sample[0], 0n, "get and set accessors - side effect check");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-numericindex-desc-configurable.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-numericindex-desc-configurable.js
new file mode 100644
index 0000000000..02fbb4e786
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-numericindex-desc-configurable.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-defineownproperty-p-desc
+description: >
+ Returns true if key is a numeric index and Desc.[[Configurable]] is true
+info: |
+ 9.4.5.3 [[DefineOwnProperty]] ( P, Desc)
+ ...
+ 3. If Type(P) is String, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ ...
+ If Desc has a [[Value]] field, then
+ Let value be Desc.[[Value]].
+ Return ? IntegerIndexedElementSet(O, numericIndex, value).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Reflect, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ assert.sameValue(
+ Reflect.defineProperty(sample, "0", {
+ value: 42n,
+ configurable: true,
+ enumerable: true,
+ writable: true
+ }),
+ true,
+ "defineProperty's result"
+ );
+ assert.sameValue(sample[0], 42n, "side effect check");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-numericindex-desc-not-configurable-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-numericindex-desc-not-configurable-throws.js
new file mode 100644
index 0000000000..970f59f008
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-numericindex-desc-not-configurable-throws.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2021 Alexey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-integer-indexed-exotic-objects-defineownproperty-p-desc
+description: >
+ Throws TypeError for valid index & non-configurable descriptor.
+info: |
+ [[DefineOwnProperty]] ( P, Desc )
+
+ [...]
+ 3. If Type(P) is String, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ [...]
+ ii. If Desc has a [[Configurable]] field and if Desc.[[Configurable]] is false, return false.
+includes: [testBigIntTypedArray.js]
+features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([0n]);
+
+ assert.throws(TypeError, function() {
+ Object.defineProperty(sample, "0", {
+ configurable: false,
+ });
+ }, "partial descriptor");
+
+ assert.throws(TypeError, function() {
+ Object.defineProperty(sample, "0", {
+ value: 42n,
+ writable: true,
+ enumerable: true,
+ configurable: false,
+ });
+ }, "complete descriptor");
+
+ assert.sameValue(sample[0], 0n, "side effect check");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-numericindex-desc-not-enumerable-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-numericindex-desc-not-enumerable-throws.js
new file mode 100644
index 0000000000..a8878645dd
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-numericindex-desc-not-enumerable-throws.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2021 Alexey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-integer-indexed-exotic-objects-defineownproperty-p-desc
+description: >
+ Throws TypeError for valid index & non-enumerable descriptor.
+info: |
+ [[DefineOwnProperty]] ( P, Desc )
+
+ [...]
+ 3. If Type(P) is String, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ [...]
+ iii. If Desc has an [[Enumerable]] field and if Desc.[[Enumerable]] is false, return false.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([0n]);
+
+ assert.throws(TypeError, function() {
+ Object.defineProperty(sample, "0", {
+ enumerable: false,
+ });
+ }, "partial descriptor");
+
+ assert.throws(TypeError, function() {
+ Object.defineProperty(sample, "0", {
+ value: 42n,
+ writable: true,
+ enumerable: false,
+ configurable: true,
+ });
+ }, "complete descriptor");
+
+ assert.sameValue(sample[0], 0n, "side effect check");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-numericindex-desc-not-enumerable.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-numericindex-desc-not-enumerable.js
new file mode 100644
index 0000000000..104cf33d0f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-numericindex-desc-not-enumerable.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-defineownproperty-p-desc
+description: >
+ Returns false if key is a numeric index and Desc.[[Enumerable]] is false
+info: |
+ 9.4.5.3 [[DefineOwnProperty]] ( P, Desc)
+ ...
+ 3. If Type(P) is String, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ ...
+ ix. If Desc has an [[Enumerable]] field and if Desc.[[Enumerable]] is
+ false, return false.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Reflect, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ assert.sameValue(
+ Reflect.defineProperty(sample, "0", {
+ value: 42n,
+ configurable: false,
+ enumerable: false,
+ writable: true
+ }),
+ false,
+ "defineProperty's result"
+ );
+ assert.sameValue(sample[0], 0n, "side effect check");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-numericindex-desc-not-writable-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-numericindex-desc-not-writable-throws.js
new file mode 100644
index 0000000000..6ddf3303df
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-numericindex-desc-not-writable-throws.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2021 Alexey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-integer-indexed-exotic-objects-defineownproperty-p-desc
+description: >
+ Throws TypeError for valid index & non-writable descriptor.
+info: |
+ [[DefineOwnProperty]] ( P, Desc )
+
+ [...]
+ 3. If Type(P) is String, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ [...]
+ v. If Desc has a [[Writable]] field and if Desc.[[Writable]] is false, return false.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([0n]);
+
+ assert.throws(TypeError, function() {
+ Object.defineProperty(sample, "0", {
+ writable: false,
+ });
+ }, "partial descriptor");
+
+ assert.throws(TypeError, function() {
+ Object.defineProperty(sample, "0", {
+ value: 42n,
+ writable: false,
+ enumerable: true,
+ configurable: true,
+ });
+ }, "complete descriptor");
+
+ assert.sameValue(sample[0], 0n, "side effect check");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-numericindex-desc-not-writable.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-numericindex-desc-not-writable.js
new file mode 100644
index 0000000000..48adf6678e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-numericindex-desc-not-writable.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-defineownproperty-p-desc
+description: >
+ Returns false if key is a numeric index and Desc.[[Writable]] is false
+info: |
+ 9.4.5.3 [[DefineOwnProperty]] ( P, Desc)
+ ...
+ 3. If Type(P) is String, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ ...
+ x. If Desc has a [[Writable]] field and if Desc.[[Writable]] is false,
+ return false.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Reflect, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ assert.sameValue(
+ Reflect.defineProperty(sample, "0", {
+ value: 42n,
+ configurable: false,
+ enumerable: true,
+ writable: false
+ }),
+ false,
+ "defineProperty's result"
+ );
+ assert.sameValue(sample[0], 0n, "side effect check");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-numericindex.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-numericindex.js
new file mode 100644
index 0000000000..aaadd22433
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-numericindex.js
@@ -0,0 +1,40 @@
+// 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-defineownproperty-p-desc
+description: >
+ Returns true after setting a valid numeric index key
+info: |
+ 9.4.5.3 [[DefineOwnProperty]] ( P, Desc)
+ ...
+ 3. If Type(P) is String, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ ...
+ If Desc has a [[Value]] field, then
+ Let value be Desc.[[Value]].
+ Return ? IntegerIndexedElementSet(O, numericIndex, value).
+
+ ...
+includes: [testBigIntTypedArray.js]
+features: [align-detached-buffer-semantics-with-web-reality, BigInt, Reflect, TypedArray]
+---*/
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 42n]);
+
+ assert.sameValue(Reflect.defineProperty(sample, '0', {
+ value: 8n,
+ configurable: true,
+ enumerable: true,
+ writable: true
+ }), true, 'Reflect.defineProperty(sample, "0", {value: 8n, configurable: true, enumerable: true, writable: true}) must return true');
+
+ assert.sameValue(sample[0], 8n, 'The value of sample[0] is 8n');
+ var desc = Object.getOwnPropertyDescriptor(sample, '0');
+ assert.sameValue(desc.value, 8n, 'The value of desc.value is 8n');
+ assert.sameValue(desc.configurable, true, 'The value of desc.configurable is true');
+ assert.sameValue(desc.enumerable, true, 'The value of desc.enumerable is true');
+ assert.sameValue(desc.writable, true, 'The value of desc.writable is true');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-symbol.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-symbol.js
new file mode 100644
index 0000000000..ec5fed280c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-symbol.js
@@ -0,0 +1,56 @@
+// 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-defineownproperty-p-desc
+description: >
+ Define an ordinary property value if key is a Symbol
+info: |
+ 9.4.5.3 [[DefineOwnProperty]] ( P, Desc)
+ ...
+ 3. If Type(P) is String, then
+ ...
+ 4. Return OrdinaryDefineOwnProperty(O, P, Desc).
+ ...
+includes: [testBigIntTypedArray.js, propertyHelper.js]
+features: [BigInt, Reflect, Symbol, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n]);
+
+ var s1 = Symbol("foo");
+ assert.sameValue(
+ Reflect.defineProperty(sample, s1, {
+ value: 42,
+ configurable: true
+ }),
+ true,
+ "return true after defining property"
+ );
+
+ assert.sameValue(sample[s1], 42);
+ verifyNotWritable(sample, s1);
+ verifyNotEnumerable(sample, s1);
+ verifyConfigurable(sample, s1);
+
+ var s2 = Symbol("bar");
+ var fnset = function() {};
+ var fnget = function() {};
+ assert.sameValue(
+ Reflect.defineProperty(sample, s2, {
+ get: fnget,
+ set: fnset,
+ enumerable: true
+ }),
+ true,
+ "return true after defining property"
+ );
+
+ var desc = Object.getOwnPropertyDescriptor(sample, s2);
+ assert.sameValue(desc.get, fnget, "accessor's get");
+ assert.sameValue(desc.set, fnset, "accessor's set");
+ assert.sameValue(desc.enumerable, true);
+ verifyNotConfigurable(sample, s2);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/non-extensible-new-key.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/non-extensible-new-key.js
new file mode 100644
index 0000000000..0f6624e723
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/non-extensible-new-key.js
@@ -0,0 +1,46 @@
+// 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-defineownproperty-p-desc
+description: >
+ Can't define a new non-numerical key on a non-extensible instance
+info: |
+ 9.4.5.3 [[DefineOwnProperty]] ( P, Desc)
+ ...
+ 3. If Type(P) is String, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ ...
+ 4. Return OrdinaryDefineOwnProperty(O, P, Desc).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Reflect, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n]);
+ Object.preventExtensions(sample);
+
+ assert.sameValue(
+ Reflect.defineProperty(sample, "foo", {value:42}),
+ false,
+ "return false on a non-extensible object - data descriptor"
+ );
+
+ assert.sameValue(Object.getOwnPropertyDescriptor(sample, "foo"), undefined);
+
+ assert.sameValue(
+ Reflect.defineProperty(sample, "bar", {
+ get: function() {},
+ set: function() {},
+ enumerable: false,
+ configurable: true
+ }),
+ false,
+ "return false on a non-extensible object - accessor descriptor"
+ );
+
+ assert.sameValue(Object.getOwnPropertyDescriptor(sample, "bar"), undefined);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/non-extensible-redefine-key.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/non-extensible-redefine-key.js
new file mode 100644
index 0000000000..6db2aa90ca
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/non-extensible-redefine-key.js
@@ -0,0 +1,59 @@
+// 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-defineownproperty-p-desc
+description: >
+ Redefine a non-numerical key on a non-extensible instance
+info: |
+ 9.4.5.3 [[DefineOwnProperty]] ( P, Desc)
+ ...
+ 3. If Type(P) is String, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ ...
+ 4. Return OrdinaryDefineOwnProperty(O, P, Desc).
+ ...
+includes: [testBigIntTypedArray.js, propertyHelper.js]
+features: [BigInt, Reflect, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n]);
+ sample.foo = true;
+ sample.bar = true;
+
+ Object.preventExtensions(sample);
+
+ assert.sameValue(
+ Reflect.defineProperty(sample, "foo", {value:42}),
+ true,
+ "data descriptor"
+ );
+
+ assert.sameValue(sample.foo, 42);
+ verifyEnumerable(sample, "foo");
+ verifyWritable(sample, "foo");
+ verifyConfigurable(sample, "foo");
+
+ var fnget = function() {};
+ var fnset = function() {};
+
+ assert.sameValue(
+ Reflect.defineProperty(sample, "bar", {
+ get: fnget,
+ set: fnset,
+ enumerable: false,
+ configurable: false
+ }),
+ true,
+ "accessor descriptor"
+ );
+
+ var desc = Object.getOwnPropertyDescriptor(sample, "bar");
+ assert.sameValue(desc.get, fnget, "accessor's get");
+ assert.sameValue(desc.set, fnset, "accessor's set");
+ verifyNotEnumerable(sample, "bar");
+ verifyNotConfigurable(sample, "bar");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/set-value.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/set-value.js
new file mode 100644
index 0000000000..6998041783
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/set-value.js
@@ -0,0 +1,57 @@
+// 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-defineownproperty-p-desc
+description: >
+ Set the value and return true
+info: |
+ 9.4.5.3 [[DefineOwnProperty]] ( P, Desc)
+ ...
+ 3. If Type(P) is String, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ ...
+ xi. If Desc has a [[Value]] field, then
+ 1. Let value be Desc.[[Value]].
+ 2. Return ? IntegerIndexedElementSet(O, intIndex, value).
+ ...
+
+ IntegerIndexedElementSet ( O, index, value )
+
+ Assert: O is an Integer-Indexed exotic object.
+ If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value).
+ Otherwise, let numValue be ? ToNumber(value).
+ Let buffer be O.[[ViewedArrayBuffer]].
+ If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then
+ Let offset be O.[[ByteOffset]].
+ Let arrayTypeName be the String value of O.[[TypedArrayName]].
+ Let elementSize be the Element Size value specified in Table 62 for arrayTypeName.
+ Let indexedPosition be (ℝ(index) × elementSize) + offset.
+ Let elementType be the Element Type value in Table 62 for arrayTypeName.
+ Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue, true, Unordered).
+ Return NormalCompletion(undefined).
+
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Reflect, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([0n, 0n]);
+
+ assert.sameValue(
+ Reflect.defineProperty(sample, "0", {value: 1n}),
+ true,
+ "set value for sample[0] returns true"
+ );
+
+ assert.sameValue(
+ Reflect.defineProperty(sample, "1", {value: 2n}),
+ true,
+ "set value for sample[1] returns true"
+ );
+
+ assert.sameValue(sample[0], 1n, "sample[0]");
+ assert.sameValue(sample[1], 2n, "sample[1]");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/shell.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/shell.js
new file mode 100644
index 0000000000..90ee9c114d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/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/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/this-is-not-extensible.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/this-is-not-extensible.js
new file mode 100644
index 0000000000..f3e20f5bea
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/this-is-not-extensible.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-defineownproperty-p-desc
+description: >
+ Returns false for non-numeric index property value if `this` is not extensible
+info: |
+ 9.4.5.3 [[DefineOwnProperty]] ( P, Desc)
+ ...
+ 3. If Type(P) is String, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ ...
+ 4. Return OrdinaryDefineOwnProperty(O, P, Desc).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Reflect, Symbol, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n]);
+
+ Object.preventExtensions(sample);
+
+ assert.sameValue(Reflect.defineProperty(sample, "foo", {value:42}), false);
+ assert.sameValue(Reflect.getOwnPropertyDescriptor(sample, "foo"), undefined);
+
+ var s = Symbol("1");
+ assert.sameValue(Reflect.defineProperty(sample, s, {value:42}), false);
+ assert.sameValue(Reflect.getOwnPropertyDescriptor(sample, s), undefined);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/tonumber-value-detached-buffer.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/tonumber-value-detached-buffer.js
new file mode 100644
index 0000000000..c10b7a5579
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/tonumber-value-detached-buffer.js
@@ -0,0 +1,61 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-integer-indexed-exotic-objects-defineownproperty-p-desc
+description: >
+ Defining a typed array element to a value that, when converted to the typed
+ array element type, detaches the typed array's underlying buffer, should return
+ true and not modify the typed array.
+info: |
+ 9.4.5.3 [[DefineOwnProperty]] ( P, Desc )
+
+ ...
+ 3. If Type(P) is String, then
+ a. Let numericIndex be ! CanonicalNumericIndexString(P).
+ b. If numericIndex is not undefined, then
+ ...
+ x. If Desc has a [[Value]] field, then
+ 1. Let value be Desc.[[Value]].
+ 2. Return ? IntegerIndexedElementSet(O, numericIndex, value).
+ ...
+
+ IntegerIndexedElementSet ( O, index, value )
+
+ Assert: O is an Integer-Indexed exotic object.
+ If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value).
+ Otherwise, let numValue be ? ToNumber(value).
+ Let buffer be O.[[ViewedArrayBuffer]].
+ If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then
+ Let offset be O.[[ByteOffset]].
+ Let arrayTypeName be the String value of O.[[TypedArrayName]].
+ Let elementSize be the Element Size value specified in Table 62 for arrayTypeName.
+ Let indexedPosition be (ℝ(index) × elementSize) + offset.
+ Let elementType be the Element Type value in Table 62 for arrayTypeName.
+ Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue, true, Unordered).
+ Return NormalCompletion(undefined).
+
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [align-detached-buffer-semantics-with-web-reality, BigInt, Reflect, TypedArray]
+---*/
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var ta = new TA([17n]);
+
+ var desc = {
+ value: {
+ valueOf() {
+ $DETACHBUFFER(ta.buffer);
+ return 42n;
+ }
+ }
+ };
+
+ assert.sameValue(
+ Reflect.defineProperty(ta, 0, desc),
+ true,
+ 'Reflect.defineProperty(ta, 0, {value: {valueOf() {$DETACHBUFFER(ta.buffer); return 42n;}}}) must return true'
+ );
+
+ assert.sameValue(ta[0], undefined, 'The value of ta[0] is expected to equal `undefined`');
+});
+
+reportCompare(0, 0);