diff options
Diffstat (limited to '')
21 files changed, 897 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/browser.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/browser.js diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/detached-buffer-key-is-not-numeric-index.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/detached-buffer-key-is-not-numeric-index.js new file mode 100644 index 0000000000..c39af7873f --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/detached-buffer-key-is-not-numeric-index.js @@ -0,0 +1,34 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-integer-indexed-exotic-objects-delete-p +description: > + Returns true when deleting any property if buffer is detached. +info: | + [[Delete]] (P) + + ... + Assert: IsPropertyKey(P) is true. + Assert: O is an Integer-Indexed exotic object. + If Type(P) is String, then + Let numericIndex be ! CanonicalNumericIndexString(P). + If numericIndex is not undefined, then + If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, return true. + ... + Return ? OrdinaryDelete(O, P) +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] +features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + var sample = new TA(1); + sample.string = "test262"; + + $DETACHBUFFER(sample.buffer); + + assert.sameValue(delete sample.string, true, 'The value of `delete sample.string` is true'); + assert.sameValue(delete sample.undef, true, 'The value of `delete sample.undef` is true'); + assert.sameValue(delete sample[0], true, 'The value of `delete sample[0]` is true'); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/detached-buffer-key-is-symbol.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/detached-buffer-key-is-symbol.js new file mode 100644 index 0000000000..ed0dddfd7b --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/detached-buffer-key-is-symbol.js @@ -0,0 +1,30 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-integer-indexed-exotic-objects-delete-p +description: > + Calls OrdinaryDelete when key is a Symbol. +info: | + [[Delete]] (P) + + ... + Assert: IsPropertyKey(P) is true. + Assert: O is an Integer-Indexed exotic object. + If Type(P) is String, then + ... + Return ? OrdinaryDelete(O, P). +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [align-detached-buffer-semantics-with-web-reality, Symbol, TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TA) { + let sample = new TA(1); + $DETACHBUFFER(sample.buffer); + + let s = Symbol("1"); + + sample[s] = 1; + assert.sameValue(delete sample[s], true, 'The value of `delete sample[s]` is true'); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/detached-buffer-realm.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/detached-buffer-realm.js new file mode 100644 index 0000000000..05cc9e7246 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/detached-buffer-realm.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-integer-indexed-exotic-objects-delete-p +description: > + Returns true when deleting any property if buffer is detached + (honoring the Realm of the current execution context) +info: | + [[Delete]] (P) + + ... + Assert: IsPropertyKey(P) is true. + Assert: O is an Integer-Indexed exotic object. + If Type(P) is String, then + Let numericIndex be ! CanonicalNumericIndexString(P). + If numericIndex is not undefined, then + If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, return true. + + ... +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [align-detached-buffer-semantics-with-web-reality, cross-realm, TypedArray] +---*/ + +var other = $262.createRealm().global; + +testWithTypedArrayConstructors(function(TA) { + var OtherTA = other[TA.name]; + var sample = new OtherTA(1); + + $DETACHBUFFER(sample.buffer); + + assert.sameValue(delete sample[0], true, 'The value of `delete sample[0]` is true'); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/detached-buffer.js new file mode 100644 index 0000000000..2879b0cc8f --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/detached-buffer.js @@ -0,0 +1,33 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-integer-indexed-exotic-objects-delete-p +description: > + Returns true when deleting any property if buffer is detached. +info: | + [[Delete]] (P) + + ... + Assert: IsPropertyKey(P) is true. + Assert: O is an Integer-Indexed exotic object. + If Type(P) is String, then + Let numericIndex be ! CanonicalNumericIndexString(P). + If numericIndex is not undefined, then + If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, return true. + ... +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] +features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.sameValue(delete sample[0], true, 'The value of `delete sample[0]` is true'); + assert.sameValue(delete sample["1.1"], true, 'The value of `delete sample["1.1"]` is true'); + assert.sameValue(delete sample["-0"], true, 'The value of `delete sample["-0"]` is true'); + assert.sameValue(delete sample["-1"], true, 'The value of `delete sample["-1"]` is true'); + assert.sameValue(delete sample["1"], true, 'The value of `delete sample["1"]` is true'); + assert.sameValue(delete sample["2"], true, 'The value of `delete sample["2"]` is true'); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/indexed-value-ab-non-strict.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/indexed-value-ab-non-strict.js new file mode 100644 index 0000000000..f42faf11d6 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/indexed-value-ab-non-strict.js @@ -0,0 +1,46 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-integer-indexed-exotic-objects-delete-p +description: > + Return value from valid numeric index +info: | + [[Delete]] (P) + + ... + Assert: IsPropertyKey(P) is true. + Assert: O is an Integer-Indexed exotic object. + If Type(P) is String, then + Let numericIndex be ! CanonicalNumericIndexString(P). + If numericIndex is not undefined, then + If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, return true. + If ! IsValidIntegerIndex(O, numericIndex) is false, return true. + Return false. + ... +flags: [noStrict] +includes: [testBigIntTypedArray.js] +features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + let proto = TypedArray.prototype; + let descriptorGetterThrows = { + configurable: true, + get() { + throw new Test262Error("OrdinaryGet was called!"); + } + }; + Object.defineProperties(proto, { + ["0"]: descriptorGetterThrows, + ["1"]: descriptorGetterThrows, + }); + + let sample = new TA(2); + + assert.sameValue(delete sample["0"], false, 'The value of `delete sample["0"]` is false'); + assert.sameValue(delete sample[0], false, 'The value of `delete sample[0]` is false'); + assert.sameValue(delete sample["1"], false, 'The value of `delete sample["1"]` is false'); + assert.sameValue(delete sample[1], false, 'The value of `delete sample[1]` is false'); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/indexed-value-ab-strict-strict.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/indexed-value-ab-strict-strict.js new file mode 100644 index 0000000000..b54d66cca8 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/indexed-value-ab-strict-strict.js @@ -0,0 +1,55 @@ +'use strict'; +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-integer-indexed-exotic-objects-delete-p +description: > + Return value from valid numeric index +info: | + [[Delete]] (P) + + ... + Assert: IsPropertyKey(P) is true. + Assert: O is an Integer-Indexed exotic object. + If Type(P) is String, then + Let numericIndex be ! CanonicalNumericIndexString(P). + If numericIndex is not undefined, then + If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, return true. + If ! IsValidIntegerIndex(O, numericIndex) is false, return true. + Return false. + ... +flags: [onlyStrict] +includes: [testBigIntTypedArray.js] +features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + let proto = TypedArray.prototype; + let descriptorGetterThrows = { + configurable: true, + get() { + throw new Test262Error("OrdinaryGet was called!"); + } + }; + Object.defineProperties(proto, { + ["0"]: descriptorGetterThrows, + ["1"]: descriptorGetterThrows, + }); + + let sample = new TA(2); + + assert.throws(TypeError, () => { + delete sample["0"]; + }, '`delete sample["0"]` throws TypeError'); + assert.throws(TypeError, () => { + delete sample["1"]; + }, '`delete sample["1"]` throws TypeError'); + assert.throws(TypeError, () => { + delete sample[0]; + }, '`delete sample[0]` throws TypeError'); + assert.throws(TypeError, () => { + delete sample[0]; + }, '`delete sample[0]` throws TypeError'); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/indexed-value-sab-non-strict.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/indexed-value-sab-non-strict.js new file mode 100644 index 0000000000..0f63640193 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/indexed-value-sab-non-strict.js @@ -0,0 +1,35 @@ +// |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// 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-delete-p +description: > + Return value from valid numeric index, with SharedArrayBuffer +flags: [noStrict] +includes: [testTypedArray.js] +features: [align-detached-buffer-semantics-with-web-reality, TypedArray, SharedArrayBuffer] +---*/ + +testWithTypedArrayConstructors(function(TA) { + let proto = TypedArray.prototype; + let descriptorGetterThrows = { + configurable: true, + get() { + throw new Test262Error("OrdinaryGet was called!"); + } + }; + Object.defineProperties(proto, { + ["0"]: descriptorGetterThrows, + ["1"]: descriptorGetterThrows, + }); + let sab = new SharedArrayBuffer(TA.BYTES_PER_ELEMENT * 2); + let sample = new TA(sab); + + assert.sameValue(delete sample["0"], false, 'The value of `delete sample["0"]` is false'); + assert.sameValue(delete sample[0], false, 'The value of `delete sample["0"]` is false'); + assert.sameValue(delete sample["1"], false, 'The value of `delete sample["1"]` is false'); + assert.sameValue(delete sample[1], false, 'The value of `delete sample["1"]` is false'); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/indexed-value-sab-strict-strict.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/indexed-value-sab-strict-strict.js new file mode 100644 index 0000000000..6677f96548 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/indexed-value-sab-strict-strict.js @@ -0,0 +1,44 @@ +// |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally +'use strict'; +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// 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-delete-p +description: > + Throws TypeError exception in strict mode. +flags: [onlyStrict] +includes: [testTypedArray.js] +features: [align-detached-buffer-semantics-with-web-reality, TypedArray, SharedArrayBuffer] +---*/ + +testWithTypedArrayConstructors(function(TA) { + let proto = TypedArray.prototype; + let descriptorGetterThrows = { + configurable: true, + get() { + throw new Test262Error("OrdinaryGet was called!"); + } + }; + Object.defineProperties(proto, { + ["0"]: descriptorGetterThrows, + ["1"]: descriptorGetterThrows, + }); + let sab = new SharedArrayBuffer(TA.BYTES_PER_ELEMENT * 2); + let sample = new TA(sab); + + assert.throws(TypeError, () => { + delete sample["0"]; + }); + assert.throws(TypeError, () => { + delete sample[0]; + }); + assert.throws(TypeError, () => { + delete sample["1"]; + }); + assert.throws(TypeError, () => { + delete sample[1]; + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/infinity-detached-buffer.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/infinity-detached-buffer.js new file mode 100644 index 0000000000..0600fa230f --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/infinity-detached-buffer.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-integerindexedelementget +description: > + "Infinity" is a canonical numeric string. Returns true when deleting any property if buffer is detached. +info: | + [[Delete]] ( P, Receiver ) + ... + Assert: IsPropertyKey(P) is true. + Assert: O is an Integer-Indexed exotic object. + If Type(P) is String, then + Let numericIndex be ! CanonicalNumericIndexString(P). + If numericIndex is not undefined, then + If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, return true. + + CanonicalNumericIndexString ( argument ) + ... + Let n be ! ToNumber(argument). + If SameValue(! ToString(n), argument) is false, return undefined. + Return n. + +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] +features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + + assert.sameValue(delete sample.Infinity, true, 'The value of `delete sample.Infinity` is true'); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-not-canonical-index-non-strict.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-not-canonical-index-non-strict.js new file mode 100644 index 0000000000..dbe5370153 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-not-canonical-index-non-strict.js @@ -0,0 +1,69 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-integer-indexed-exotic-objects-delete-p +description: > + Return true if key is not a CanonicalNumericIndex. +info: | + [[Delete]] (P) + + ... + Assert: IsPropertyKey(P) is true. + Assert: O is an Integer-Indexed exotic object. + If Type(P) is String, then + Let numericIndex be ! CanonicalNumericIndexString(P). + If numericIndex is not undefined, then + If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, return true. + If ! IsValidIntegerIndex(O, numericIndex) is false, return true. + Return false. + ... + Return ? OrdinaryDelete(O, P). +flags: [noStrict] +includes: [testBigIntTypedArray.js] +features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + var keys = [ + "1.0", + "+1", + "1000000000000000000000", + "0.0000001" + ]; + + keys.forEach((key) => { + var sample = new TA(); // <- intentionally empty + + assert.sameValue( + delete sample[key], true, + 'The value of `delete sample[key]` is true' + ); + + TypedArray.prototype[key] = key; + + assert.sameValue( + delete sample[key], + true, + 'The value of `delete sample[key]` is true' + ); + + sample[key] = key; + assert.sameValue( + delete sample[key], true, + 'The value of `delete sample[key]` is true' + ); + + Object.defineProperty(sample, key, { + get() { return key; } + }); + + assert.sameValue( + delete sample[key], false, + 'The value of `delete sample[key]` is false' + ); + + delete TypedArray.prototype[key]; + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-not-canonical-index-strict-strict.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-not-canonical-index-strict-strict.js new file mode 100644 index 0000000000..4435c4ac17 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-not-canonical-index-strict-strict.js @@ -0,0 +1,69 @@ +'use strict'; +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-integer-indexed-exotic-objects-delete-p +description: > + Return true if key is not a CanonicalNumericIndex. +info: | + [[Delete]] (P) + + ... + Assert: IsPropertyKey(P) is true. + Assert: O is an Integer-Indexed exotic object. + If Type(P) is String, then + Let numericIndex be ! CanonicalNumericIndexString(P). + If numericIndex is not undefined, then + If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, return true. + If ! IsValidIntegerIndex(O, numericIndex) is false, return true. + Return false. + ... + Return ? OrdinaryDelete(O, P). +flags: [onlyStrict] +includes: [testBigIntTypedArray.js] +features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + var keys = [ + "1.0", + "+1", + "1000000000000000000000", + "0.0000001" + ]; + + keys.forEach((key) => { + var sample = new TA(); // <- intentionally empty + + assert.sameValue( + delete sample[key], true, + 'The value of `delete sample[key]` is true' + ); + + TypedArray.prototype[key] = key; + + assert.sameValue( + delete sample[key], + true, + 'The value of `delete sample[key]` is true' + ); + + sample[key] = key; + assert.sameValue( + delete sample[key], true, + 'The value of `delete sample[key]` is true' + ); + + Object.defineProperty(sample, key, { + get() { return key; } + }); + + assert.throws(TypeError, () => { + delete sample[key]; + }, '`delete sample[key]` throws TypeError'); + + delete TypedArray.prototype[key]; + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-not-minus-zero-non-strict.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-not-minus-zero-non-strict.js new file mode 100644 index 0000000000..319764e862 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-not-minus-zero-non-strict.js @@ -0,0 +1,46 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-integer-indexed-exotic-objects-delete-p +description: > + Return true if key is a CanonicalNumericIndex and IsValidIntegerIndex(O, numericIndex) is false. +info: | + [[Delete]] (P) + + ... + Assert: IsPropertyKey(P) is true. + Assert: O is an Integer-Indexed exotic object. + If Type(P) is String, then + Let numericIndex be ! CanonicalNumericIndexString(P). + If numericIndex is not undefined, then + If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, return true. + If ! IsValidIntegerIndex(O, numericIndex) is false, return true. + Return false. + + ... + + IntegerIndexedElementGet ( O, index ) + + ... + If ! IsValidIntegerIndex(O, index) is false, return undefined. + ... +flags: [noStrict] +includes: [testBigIntTypedArray.js] +features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + let proto = TypedArray.prototype; + Object.defineProperty(proto, "-0", { + configurable: true, + get() { + throw new Test262Error("OrdinaryGet was called!"); + } + }); + let sample = new TA(1); + + assert.sameValue(delete sample["-0"], true, 'The value of `delete sample["-0"]` is true'); + assert.sameValue(delete sample[-0], false, 'The value of `delete sample[-0]` is false'); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-not-minus-zero-strict-strict.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-not-minus-zero-strict-strict.js new file mode 100644 index 0000000000..c0e42e745e --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-not-minus-zero-strict-strict.js @@ -0,0 +1,49 @@ +'use strict'; +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-integer-indexed-exotic-objects-delete-p +description: > + Return true if key is a CanonicalNumericIndex and IsValidIntegerIndex(O, numericIndex) is false. +info: | + [[Delete]] (P) + + ... + Assert: IsPropertyKey(P) is true. + Assert: O is an Integer-Indexed exotic object. + If Type(P) is String, then + Let numericIndex be ! CanonicalNumericIndexString(P). + If numericIndex is not undefined, then + If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, return true. + If ! IsValidIntegerIndex(O, numericIndex) is false, return true. + Return false. + + ... + + IntegerIndexedElementGet ( O, index ) + + ... + If ! IsValidIntegerIndex(O, index) is false, return undefined. + ... +flags: [onlyStrict] +includes: [testBigIntTypedArray.js] +features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + let proto = TypedArray.prototype; + Object.defineProperty(proto, "-0", { + configurable: true, + get() { + throw new Test262Error("OrdinaryGet was called!"); + } + }); + let sample = new TA(1); + + assert.sameValue(delete sample["-0"], true, 'The value of `delete sample["-0"]` is true'); + assert.throws(TypeError, () => { + delete sample[-0]; + }, '`delete sample[-0]` throws TypeError'); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-not-numeric-index-get-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-not-numeric-index-get-throws.js new file mode 100644 index 0000000000..2cd35158c4 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-not-numeric-index-get-throws.js @@ -0,0 +1,40 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-integer-indexed-exotic-objects-delete-p +description: > + Use OrdinaryDelete if key is not a CanonicalNumericIndex +info: | + [[Delete]] (P) + + ... + Assert: IsPropertyKey(P) is true. + Assert: O is an Integer-Indexed exotic object. + If Type(P) is String, then + Let numericIndex be ! CanonicalNumericIndexString(P). + If numericIndex is not undefined, then + If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, return true. + If ! IsValidIntegerIndex(O, numericIndex) is false, return true. + Return false. + ... + Return ? OrdinaryDelete(O, P). + +includes: [testBigIntTypedArray.js] +features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + let sample = new TA(1); + + Object.defineProperty(sample, "foo", { + get() { + throw new Test262Error(); + } + }); + + assert.throws(Test262Error, () => { + sample.foo; + }, '`sample.foo` throws Test262Error'); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-not-numeric-index-non-strict.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-not-numeric-index-non-strict.js new file mode 100644 index 0000000000..29c468caa7 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-not-numeric-index-non-strict.js @@ -0,0 +1,46 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-integer-indexed-exotic-objects-delete-p +description: > + Use OrdinaryDelete if key is not a CanonicalNumericIndex +info: | + [[Delete]] (P) + + ... + Assert: IsPropertyKey(P) is true. + Assert: O is an Integer-Indexed exotic object. + If Type(P) is String, then + Let numericIndex be ! CanonicalNumericIndexString(P). + If numericIndex is not undefined, then + If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, return true. + If ! IsValidIntegerIndex(O, numericIndex) is false, return true. + Return false. + ... + Return ? OrdinaryDelete(O, P). +flags: [noStrict] +includes: [testBigIntTypedArray.js] +features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + TypedArray.prototype.baz = "baz"; + let sample = new TA(1); + + assert.sameValue( + delete sample.foo, true, + 'The value of `delete sample.foo` is true' + ); + + sample.foo = "foo"; + assert.sameValue(delete sample.foo, true, 'The value of `delete sample.foo` is true'); + + Object.defineProperty(sample, "bar", { + get() { return "bar"; } + }); + + assert.sameValue(delete sample.bar, false, 'The value of `delete sample.bar` is false'); + assert.sameValue(delete sample.baz, true, 'The value of `delete sample.baz` is true'); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-not-numeric-index-strict-strict.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-not-numeric-index-strict-strict.js new file mode 100644 index 0000000000..2a9f7171e9 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-not-numeric-index-strict-strict.js @@ -0,0 +1,50 @@ +'use strict'; +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-integer-indexed-exotic-objects-delete-p +description: > + Use OrdinaryDelete if key is not a CanonicalNumericIndex +info: | + [[Delete]] (P) + + ... + Assert: IsPropertyKey(P) is true. + Assert: O is an Integer-Indexed exotic object. + If Type(P) is String, then + Let numericIndex be ! CanonicalNumericIndexString(P). + If numericIndex is not undefined, then + If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, return true. + If ! IsValidIntegerIndex(O, numericIndex) is false, return true. + Return false. + ... + Return ? OrdinaryDelete(O, P). +flags: [onlyStrict] +includes: [testBigIntTypedArray.js] +features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + TypedArray.prototype.baz = "baz"; + let sample = new TA(1); + + assert.sameValue( + delete sample.foo, true, + 'The value of `delete sample.foo` is true' + ); + + sample.foo = "foo"; + assert.sameValue(delete sample.foo, true, 'The value of `delete sample.foo` is true'); + + Object.defineProperty(sample, "bar", { + get() { return "bar"; } + }); + + assert.throws(TypeError, () => { + delete sample.bar; + }, '`delete sample.bar` throws TypeError'); + + assert.sameValue(delete sample.baz, true, 'The value of `delete sample.baz` is true'); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-out-of-bounds-non-strict.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-out-of-bounds-non-strict.js new file mode 100644 index 0000000000..ee352b1a40 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-out-of-bounds-non-strict.js @@ -0,0 +1,49 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-integer-indexed-exotic-objects-delete-p +description: > + Return true if IsValidIntegerIndex(O, numericIndex) is false. +info: | + [[Delete]] (P) + + ... + Assert: IsPropertyKey(P) is true. + Assert: O is an Integer-Indexed exotic object. + If Type(P) is String, then + Let numericIndex be ! CanonicalNumericIndexString(P). + If numericIndex is not undefined, then + If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, return true. + If ! IsValidIntegerIndex(O, numericIndex) is false, return true. + Return false. + ... + Return ? OrdinaryDelete(O, P). + +flags: [noStrict] +includes: [testBigIntTypedArray.js] +features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + let proto = TypedArray.prototype; + let descriptorGetterThrows = { + configurable: true, + get() { + throw new Test262Error("OrdinaryGet was called!"); + } + }; + Object.defineProperties(proto, { + ["-1"]: descriptorGetterThrows, + ["1"]: descriptorGetterThrows, + }); + + let sample = new TA(1); + assert.sameValue(delete sample["-1"], true, 'The value of `delete sample["-1"]` is true'); + assert.sameValue(delete sample[-1], true, 'The value of `delete sample[-1]` is true'); + assert.sameValue(delete sample["0"], false, 'The value of `delete sample["0"]` is false'); + assert.sameValue(delete sample[0], false, 'The value of `delete sample[0]` is false'); + assert.sameValue(delete sample["1"], true, 'The value of `delete sample["1"]` is true'); + assert.sameValue(delete sample[1], true, 'The value of `delete sample[1]` is true'); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-out-of-bounds-strict-strict.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-out-of-bounds-strict-strict.js new file mode 100644 index 0000000000..8d67ba003f --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-out-of-bounds-strict-strict.js @@ -0,0 +1,57 @@ +'use strict'; +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-integer-indexed-exotic-objects-delete-p +description: > + Return true if IsValidIntegerIndex(O, numericIndex) is false. +info: | + [[Delete]] (P) + + ... + Assert: IsPropertyKey(P) is true. + Assert: O is an Integer-Indexed exotic object. + If Type(P) is String, then + Let numericIndex be ! CanonicalNumericIndexString(P). + If numericIndex is not undefined, then + If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, return true. + If ! IsValidIntegerIndex(O, numericIndex) is false, return true. + Return false. + ... + Return ? OrdinaryDelete(O, P). + +flags: [onlyStrict] +includes: [testBigIntTypedArray.js] +features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + let proto = TypedArray.prototype; + let descriptorGetterThrows = { + configurable: true, + get() { + throw new Test262Error("OrdinaryGet was called!"); + } + }; + Object.defineProperties(proto, { + ["-1"]: descriptorGetterThrows, + ["1"]: descriptorGetterThrows, + }); + + let sample = new TA(1); + assert.sameValue(delete sample["-1"], true, 'The value of `delete sample["-1"]` is true'); + assert.sameValue(delete sample[-1], true, 'The value of `delete sample[-1]` is true'); + + assert.throws(TypeError, () => { + delete sample["0"]; + }, '`delete sample["0"]` throws TypeError'); + + assert.throws(TypeError, () => { + delete sample[0]; + }, '`delete sample[0]` throws TypeError'); + + assert.sameValue(delete sample["1"], true, 'The value of `delete sample["1"]` is true'); + assert.sameValue(delete sample[1], true, 'The value of `delete sample[1]` is true'); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-symbol.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-symbol.js new file mode 100644 index 0000000000..9d642c8c6b --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/key-is-symbol.js @@ -0,0 +1,33 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-integer-indexed-exotic-objects-delete-p +description: > + Use OrdinaryDelete if key is a Symbol +info: | + [[Delete]] (P) + + ... + Assert: IsPropertyKey(P) is true. + Assert: O is an Integer-Indexed exotic object. + If Type(P) is String, then + ... + Return ? OrdinaryDelete(O, P). + +includes: [testBigIntTypedArray.js] +features: [align-detached-buffer-semantics-with-web-reality, BigInt, Symbol, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + let sample = new TA(1); + let s = Symbol("1"); + + assert.sameValue(delete sample[s], true, 'The value of `delete sample[s]` is true'); + assert.sameValue(Reflect.has(sample, s), false, 'Reflect.has(sample, s) must return false'); + + sample[s] = ""; + assert.sameValue(delete sample[s], true, 'The value of `delete sample[s]` is true'); + assert.sameValue(Reflect.has(sample, s), false, 'Reflect.has(sample, s) must return false'); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/shell.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/BigInt/shell.js new file mode 100644 index 0000000000..90ee9c114d --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/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; + } + } +} |