diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete')
43 files changed, 1940 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; + } + } +} diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/browser.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/browser.js diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/detached-buffer-key-is-not-numeric-index.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/detached-buffer-key-is-not-numeric-index.js new file mode 100644 index 0000000000..f204b58813 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/detached-buffer-key-is-not-numeric-index.js @@ -0,0 +1,36 @@ +// 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: [testTypedArray.js, detachArrayBuffer.js] +features: [align-detached-buffer-semantics-with-web-reality, TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TA) { + let sample = new TA(1); + let key = "key"; + sample.string = key; + + $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[key], true, 'The value of `delete sample.string` is true'); + assert.sameValue(delete sample["undef"], true, 'The value of `delete sample.undef` is true'); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/detached-buffer-key-is-symbol.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/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/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/detached-buffer-realm.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/detached-buffer-realm.js new file mode 100644 index 0000000000..05cc9e7246 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/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/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/detached-buffer.js new file mode 100644 index 0000000000..d55e8b15ee --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/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: [testTypedArray.js, detachArrayBuffer.js] +features: [align-detached-buffer-semantics-with-web-reality, TypedArray] +---*/ + +testWithTypedArrayConstructors(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/indexed-value-ab-non-strict.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/indexed-value-ab-non-strict.js new file mode 100644 index 0000000000..ac273ff0a6 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/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: [testTypedArray.js] +features: [align-detached-buffer-semantics-with-web-reality, TypedArray] +---*/ + +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 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/indexed-value-ab-strict-strict.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/indexed-value-ab-strict-strict.js new file mode 100644 index 0000000000..5ac3219bba --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/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: [testTypedArray.js] +features: [align-detached-buffer-semantics-with-web-reality, TypedArray] +---*/ + +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 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/indexed-value-sab-non-strict.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/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/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/indexed-value-sab-strict-strict.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/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/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/infinity-detached-buffer.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/infinity-detached-buffer.js new file mode 100644 index 0000000000..735673dcc1 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/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: [testTypedArray.js, detachArrayBuffer.js] +features: [align-detached-buffer-semantics-with-web-reality, TypedArray] +---*/ + +testWithTypedArrayConstructors(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/key-is-not-canonical-index-non-strict.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-not-canonical-index-non-strict.js new file mode 100644 index 0000000000..9cd26b2c46 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/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: [testTypedArray.js] +features: [align-detached-buffer-semantics-with-web-reality, TypedArray] +---*/ + +testWithTypedArrayConstructors(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/key-is-not-canonical-index-strict-strict.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-not-canonical-index-strict-strict.js new file mode 100644 index 0000000000..acd52c7cce --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/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: [testTypedArray.js] +features: [align-detached-buffer-semantics-with-web-reality, TypedArray] +---*/ + +testWithTypedArrayConstructors(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/key-is-not-integer.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-not-integer.js new file mode 100644 index 0000000000..d8862bd99b --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-not-integer.js @@ -0,0 +1,44 @@ +// 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 ) + + ... + 5. If IsInteger(index) is false, return undefined. + ... +includes: [testTypedArray.js] +features: [align-detached-buffer-semantics-with-web-reality, TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TA) { + let proto = TypedArray.prototype; + Object.defineProperty(proto, "1.1", { + configurable: true, + get() { + throw new Test262Error("OrdinaryGet was called!"); + } + }); + let sample = new TA(1); + + assert.sameValue(delete sample["1.1"], true, 'The value of `delete sample["1.1"]` is true'); + assert.sameValue(delete sample[1.1], true, 'The value of `delete sample[1.1]` is true'); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-not-minus-zero-non-strict.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-not-minus-zero-non-strict.js new file mode 100644 index 0000000000..8a60a14c4c --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/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: [testTypedArray.js] +features: [align-detached-buffer-semantics-with-web-reality, TypedArray] +---*/ + +testWithTypedArrayConstructors(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/key-is-not-minus-zero-strict-strict.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-not-minus-zero-strict-strict.js new file mode 100644 index 0000000000..33bae05317 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/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: [testTypedArray.js] +features: [align-detached-buffer-semantics-with-web-reality, TypedArray] +---*/ + +testWithTypedArrayConstructors(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/key-is-not-numeric-index-get-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-not-numeric-index-get-throws.js new file mode 100644 index 0000000000..5035a5d733 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/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: [testTypedArray.js] +features: [align-detached-buffer-semantics-with-web-reality, TypedArray] +---*/ + +testWithTypedArrayConstructors(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/key-is-not-numeric-index-non-strict.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-not-numeric-index-non-strict.js new file mode 100644 index 0000000000..2b9d9a378e --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/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: [testTypedArray.js] +features: [align-detached-buffer-semantics-with-web-reality, TypedArray] +---*/ + +testWithTypedArrayConstructors(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/key-is-not-numeric-index-strict-strict.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-not-numeric-index-strict-strict.js new file mode 100644 index 0000000000..af6397a576 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/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: [testTypedArray.js] +features: [align-detached-buffer-semantics-with-web-reality, TypedArray] +---*/ + +testWithTypedArrayConstructors(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/key-is-out-of-bounds-non-strict.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-out-of-bounds-non-strict.js new file mode 100644 index 0000000000..63130f39a7 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/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: [testTypedArray.js] +features: [align-detached-buffer-semantics-with-web-reality, TypedArray] +---*/ + +testWithTypedArrayConstructors(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/key-is-out-of-bounds-strict-strict.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-out-of-bounds-strict-strict.js new file mode 100644 index 0000000000..c668f681c3 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/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: [testTypedArray.js] +features: [align-detached-buffer-semantics-with-web-reality, TypedArray] +---*/ + +testWithTypedArrayConstructors(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/key-is-symbol.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/key-is-symbol.js new file mode 100644 index 0000000000..6e25155282 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/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: [testTypedArray.js] +features: [align-detached-buffer-semantics-with-web-reality, Symbol, TypedArray] +---*/ + +testWithTypedArrayConstructors(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/shell.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/shell.js new file mode 100644 index 0000000000..f9aa35231b --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Delete/shell.js @@ -0,0 +1,142 @@ +// GENERATED, DO NOT EDIT +// file: detachArrayBuffer.js +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + A function used in the process of asserting correctness of TypedArray objects. + + $262.detachArrayBuffer is defined by a host. +defines: [$DETACHBUFFER] +---*/ + +function $DETACHBUFFER(buffer) { + if (!$262 || typeof $262.detachArrayBuffer !== "function") { + throw new Test262Error("No method available to detach an ArrayBuffer"); + } + $262.detachArrayBuffer(buffer); +} + +// file: testTypedArray.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 TypedArray objects. +defines: + - typedArrayConstructors + - floatArrayConstructors + - intArrayConstructors + - TypedArray + - testWithTypedArrayConstructors + - testWithAtomicsFriendlyTypedArrayConstructors + - testWithNonAtomicsFriendlyTypedArrayConstructors + - testTypedArrayConversions +---*/ + +/** + * Array containing every typed array constructor. + */ +var typedArrayConstructors = [ + Float64Array, + Float32Array, + Int32Array, + Int16Array, + Int8Array, + Uint32Array, + Uint16Array, + Uint8Array, + Uint8ClampedArray +]; + +var floatArrayConstructors = typedArrayConstructors.slice(0, 2); +var intArrayConstructors = typedArrayConstructors.slice(2, 7); + +/** + * The %TypedArray% intrinsic constructor function. + */ +var TypedArray = Object.getPrototypeOf(Int8Array); + +/** + * Callback for testing a typed array constructor. + * + * @callback typedArrayConstructorCallback + * @param {Function} Constructor the constructor object to test with. + */ + +/** + * 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 testWithTypedArrayConstructors(f, selected) { + var constructors = selected || typedArrayConstructors; + 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; + } + } +} + +/** + * Calls the provided function for every non-"Atomics Friendly" 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 testWithNonAtomicsFriendlyTypedArrayConstructors(f) { + testWithTypedArrayConstructors(f, [ + Float64Array, + Float32Array, + Uint8ClampedArray + ]); +} + +/** + * Calls the provided function for every "Atomics Friendly" 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 testWithAtomicsFriendlyTypedArrayConstructors(f) { + testWithTypedArrayConstructors(f, [ + Int32Array, + Int16Array, + Int8Array, + Uint32Array, + Uint16Array, + Uint8Array, + ]); +} + +/** + * Helper for conversion operations on TypedArrays, the expected values + * properties are indexed in order to match the respective value for each + * TypedArray constructor + * @param {Function} fn - the function to call for each constructor and value. + * will be called with the constructor, value, expected + * value, and a initial value that can be used to avoid + * a false positive with an equivalent expected value. + */ +function testTypedArrayConversions(byteConversionValues, fn) { + var values = byteConversionValues.values; + var expected = byteConversionValues.expected; + + testWithTypedArrayConstructors(function(TA) { + var name = TA.name.slice(0, -5); + + return values.forEach(function(value, index) { + var exp = expected[name][index]; + var initial = 0; + if (exp === 0) { + initial = 1; + } + fn(TA, value, exp, initial); + }); + }); +} |