diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/BigInt | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/BigInt')
16 files changed, 594 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/BigInt/browser.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/BigInt/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/BigInt/browser.js diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/BigInt/detached-buffer-key-is-not-numeric-index.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/BigInt/detached-buffer-key-is-not-numeric-index.js new file mode 100644 index 0000000000..e8296d36f4 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/BigInt/detached-buffer-key-is-not-numeric-index.js @@ -0,0 +1,30 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-integer-indexed-exotic-objects-get-p-receiver +description: > + Does not throw on an instance with a detached buffer if key is not a number +info: | + 9.4.5.4 [[Get]] (P, Receiver) + + ... + 2. If Type(P) is String, then + a. Let numericIndex be ! CanonicalNumericIndexString(P). + b. If numericIndex is not undefined, then + ... + 3. Return ? OrdinaryGet(O, P, Receiver +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n]); + sample.foo = "test262"; + + $DETACHBUFFER(sample.buffer); + + assert.sameValue(sample.undef, undefined); + assert.sameValue(sample.foo, "test262"); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/BigInt/detached-buffer-key-is-symbol.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/BigInt/detached-buffer-key-is-symbol.js new file mode 100644 index 0000000000..a0316ccb2f --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/BigInt/detached-buffer-key-is-symbol.js @@ -0,0 +1,30 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-integer-indexed-exotic-objects-get-p-receiver +description: > + Does not throw on an instance with a detached buffer if key is a Symbol +info: | + 9.4.5.4 [[Get]] (P, Receiver) + + ... + 2. If Type(P) is String, then + ... + 3. Return ? OrdinaryGet(O, P, Receiver). +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n]); + $DETACHBUFFER(sample.buffer); + + var s = Symbol("1"); + + assert.sameValue(sample[s], undefined); + + sample[s] = "test262"; + assert.sameValue(sample[s], "test262"); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/BigInt/detached-buffer-realm.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/BigInt/detached-buffer-realm.js new file mode 100644 index 0000000000..f979db1546 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/BigInt/detached-buffer-realm.js @@ -0,0 +1,38 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-integer-indexed-exotic-objects-get-p-receiver +description: > + Returns undefined if key has a numeric index and object has a detached + buffer (honoring the Realm of the current execution context) +info: | + [[Get]] ( P, Receiver ) + + If Type(P) is String, then + Let numericIndex be ! CanonicalNumericIndexString(P). + If numericIndex is not undefined, then + Return ! IntegerIndexedElementGet(O, numericIndex). + + IntegerIndexedElementGet ( O, index ) + + Assert: O is an Integer-Indexed exotic object. + Assert: Type(index) is Number. + Let buffer be O.[[ViewedArrayBuffer]]. + If IsDetachedBuffer(buffer) is true, return undefined. + ... +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] +features: [align-detached-buffer-semantics-with-web-reality, BigInt, cross-realm, TypedArray] +---*/ + +let other = $262.createRealm().global; + +testWithBigIntTypedArrayConstructors(function(TA) { + let OtherTA = other[TA.name]; + let sample = new OtherTA(1); + + $DETACHBUFFER(sample.buffer); + + assert.sameValue(sample[0], undefined, 'The value of sample[0] is expected to equal `undefined`'); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/BigInt/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/BigInt/detached-buffer.js new file mode 100644 index 0000000000..b7ee084085 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/BigInt/detached-buffer.js @@ -0,0 +1,38 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-integer-indexed-exotic-objects-get-p-receiver +description: > + Returns undefined if key has a numeric index and object has a detached buffer +info: | + [[Get]] ( P, Receiver ) + + If Type(P) is String, then + Let numericIndex be ! CanonicalNumericIndexString(P). + If numericIndex is not undefined, then + Return ! IntegerIndexedElementGet(O, numericIndex). + + IntegerIndexedElementGet ( O, index ) + + Assert: O is an Integer-Indexed exotic object. + Assert: Type(index) is Number. + Let buffer be O.[[ViewedArrayBuffer]]. + If IsDetachedBuffer(buffer) is true, return undefined. + +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] +features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + let sample = new TA(1); + $DETACHBUFFER(sample.buffer); + + assert.sameValue(sample[0], undefined, 'The value of sample[0] is expected to equal `undefined`'); + assert.sameValue(sample["1.1"], undefined, 'The value of sample["1.1"] is expected to equal `undefined`'); + assert.sameValue(sample["-0"], undefined, 'The value of sample["-0"] is expected to equal `undefined`'); + assert.sameValue(sample["-1"], undefined, 'The value of sample["-1"] is expected to equal `undefined`'); + assert.sameValue(sample["1"], undefined, 'The value of sample["1"] is expected to equal `undefined`'); + assert.sameValue(sample["2"], undefined, 'The value of sample["2"] is expected to equal `undefined`'); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/BigInt/indexed-value-sab.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/BigInt/indexed-value-sab.js new file mode 100644 index 0000000000..c3eac9165f --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/BigInt/indexed-value-sab.js @@ -0,0 +1,31 @@ +// |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally +// Copyright (C) 2016 the V8 project authors. 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-get-p-receiver +description: > + Return value from valid numeric index, with SharedArrayBuffer +includes: [testBigIntTypedArray.js] +features: [BigInt, TypedArray, SharedArrayBuffer] +---*/ + +var proto = TypedArray.prototype; +var throwDesc = { + get: function() { + throw new Test262Error("OrdinaryGet was called! Ref: 9.1.8.1 3.c"); + } +}; +Object.defineProperty(proto, "0", throwDesc); +Object.defineProperty(proto, "1", throwDesc); + +testWithBigIntTypedArrayConstructors(function(TA) { + var sab = new SharedArrayBuffer(TA.BYTES_PER_ELEMENT * 2); + var sample = new TA(sab); + sample.set([42n, 1n]); + + assert.sameValue(sample["0"], 42n); + assert.sameValue(sample["1"], 1n); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/BigInt/indexed-value.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/BigInt/indexed-value.js new file mode 100644 index 0000000000..4c54b6f3d8 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/BigInt/indexed-value.js @@ -0,0 +1,36 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-integer-indexed-exotic-objects-get-p-receiver +description: > + Return value from valid numeric index +info: | + 9.4.5.4 [[Get]] (P, Receiver) + + ... + 2. If Type(P) is String, then + a. Let numericIndex be ! CanonicalNumericIndexString(P). + b. If numericIndex is not undefined, then + i. Return ? IntegerIndexedElementGet(O, numericIndex). + ... +includes: [testBigIntTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var proto = TypedArray.prototype; +var throwDesc = { + get: function() { + throw new Test262Error("OrdinaryGet was called! Ref: 9.1.8.1 3.c"); + } +}; +Object.defineProperty(proto, "0", throwDesc); +Object.defineProperty(proto, "1", throwDesc); + +testWithBigIntTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 1n]); + + assert.sameValue(sample["0"], 42n); + assert.sameValue(sample["1"], 1n); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/BigInt/infinity-detached-buffer.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/BigInt/infinity-detached-buffer.js new file mode 100644 index 0000000000..b1c9e74b09 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/BigInt/infinity-detached-buffer.js @@ -0,0 +1,40 @@ +// Copyright (C) 2017 André Bargull. 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, test with access on detached buffer. +info: | + 9.4.5.4 [[Get]] ( P, Receiver ) + ... + 2. If Type(P) is String, then + a. Let numericIndex be ! CanonicalNumericIndexString(P). + b. If numericIndex is not undefined, then + i. Return ? IntegerIndexedElementGet(O, numericIndex). + ... + + 7.1.16 CanonicalNumericIndexString ( argument ) + ... + 3. Let n be ! ToNumber(argument). + 4. If SameValue(! ToString(n), argument) is false, return undefined. + 5. Return n. + + 9.4.5.8 IntegerIndexedElementGet ( O, index ) + ... + 3. Let buffer be O.[[ViewedArrayBuffer]]. + 4. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... + +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] +features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + let sample = new TA(0); + $DETACHBUFFER(sample.buffer); + + assert.sameValue(sample.Infinity, undefined, 'The value of sample.Infinity is expected to equal `undefined`'); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/BigInt/key-is-not-canonical-index.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/BigInt/key-is-not-canonical-index.js new file mode 100644 index 0000000000..115b604b18 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/BigInt/key-is-not-canonical-index.js @@ -0,0 +1,63 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-integer-indexed-exotic-objects-get-p-receiver +description: > + Use OrdinaryGet if numeric key is not a CanonicalNumericIndex +info: | + 9.4.5.4 [[Get]] (P, Receiver) + + ... + 2. If Type(P) is String, then + a. Let numericIndex be ! CanonicalNumericIndexString(P). + b. If numericIndex is not undefined, then + ... + 3. Return ? OrdinaryGet(O, P, Receiver). +includes: [testBigIntTypedArray.js] +features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] +---*/ + +var keys = [ + "1.0", + "+1", + "1000000000000000000000", + "0.0000001" +]; + +testWithBigIntTypedArrayConstructors(function(TA) { + keys.forEach(function(key) { + var sample = new TA(); + + assert.sameValue( + sample[key], undefined, + "return undefined for inexistent properties [" + key + "]" + ); + + TypedArray.prototype[key] = "test262"; + + assert.sameValue( + sample[key], + "test262", + "return value from inherited key [" + key + "]" + ); + + sample[key] = "bar"; + assert.sameValue( + sample[key], "bar", + "return value from own key [" + key + "]" + ); + + Object.defineProperty(sample, key, { + get: function() { return "baz"; } + }); + + assert.sameValue( + sample[key], "baz", + "return value from get accessor [" + key + "]" + ); + + delete TypedArray.prototype[key]; + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/BigInt/key-is-not-integer.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/BigInt/key-is-not-integer.js new file mode 100644 index 0000000000..251231fc65 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/BigInt/key-is-not-integer.js @@ -0,0 +1,39 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-integer-indexed-exotic-objects-get-p-receiver +description: > + Return undefined if key is numeric index is not an integer. +info: | + 9.4.5.4 [[Get]] (P, Receiver) + + ... + 2. If Type(P) is String, then + a. Let numericIndex be ! CanonicalNumericIndexString(P). + b. If numericIndex is not undefined, then + i. Return ? IntegerIndexedElementGet(O, numericIndex). + ... + + 9.4.5.8 IntegerIndexedElementGet ( O, index ) + + ... + 5. If IsInteger(index) is false, return undefined. + ... +includes: [testBigIntTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var proto = TypedArray.prototype; +Object.defineProperty(proto, "1.1", { + get: function() { + throw new Test262Error("OrdinaryGet was called! Ref: 9.1.8.1 3.c"); + } +}); + +testWithBigIntTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n]); + + assert.sameValue(sample["1.1"], undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/BigInt/key-is-not-minus-zero.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/BigInt/key-is-not-minus-zero.js new file mode 100644 index 0000000000..99d6d4f7af --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/BigInt/key-is-not-minus-zero.js @@ -0,0 +1,39 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-integer-indexed-exotic-objects-get-p-receiver +description: > + Return undefined if key is numeric index is -0. +info: | + 9.4.5.4 [[Get]] (P, Receiver) + + ... + 2. If Type(P) is String, then + a. Let numericIndex be ! CanonicalNumericIndexString(P). + b. If numericIndex is not undefined, then + i. Return ? IntegerIndexedElementGet(O, numericIndex). + ... + + 9.4.5.8 IntegerIndexedElementGet ( O, index ) + + ... + 6. If index = -0, return undefined. + ... +includes: [testBigIntTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var proto = TypedArray.prototype; +Object.defineProperty(proto, "-0", { + get: function() { + throw new Test262Error("OrdinaryGet was called! Ref: 9.1.8.1 3.c"); + } +}); + +testWithBigIntTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n]); + + assert.sameValue(sample["-0"], undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/BigInt/key-is-not-numeric-index-get-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/BigInt/key-is-not-numeric-index-get-throws.js new file mode 100644 index 0000000000..9073ee159a --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/BigInt/key-is-not-numeric-index-get-throws.js @@ -0,0 +1,40 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-integer-indexed-exotic-objects-get-p-receiver +description: > + Returns abrupt from OrdinaryGet when key is not a numeric index +info: | + 9.4.5.4 [[Get]] (P, Receiver) + + ... + 2. If Type(P) is String, then + a. Let numericIndex be ! CanonicalNumericIndexString(P). + b. If numericIndex is not undefined, then + ... + 3. Return ? OrdinaryGet(O, P, Receiver). + + 9.1.8.1 OrdinaryGet (O, P, Receiver) + + ... + 8. Return ? Call(getter, Receiver). + ... +includes: [testBigIntTypedArray.js] +features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + var sample = new TA(1); + + Object.defineProperty(sample, "test262", { + get: function() { + throw new Test262Error(); + } + }); + + assert.throws(Test262Error, function() { + sample.test262; + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/BigInt/key-is-not-numeric-index.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/BigInt/key-is-not-numeric-index.js new file mode 100644 index 0000000000..7d4e873e52 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/BigInt/key-is-not-numeric-index.js @@ -0,0 +1,41 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-integer-indexed-exotic-objects-get-p-receiver +description: > + Use OrdinaryGet if key is not a CanonicalNumericIndex +info: | + 9.4.5.4 [[Get]] (P, Receiver) + + ... + 2. If Type(P) is String, then + a. Let numericIndex be ! CanonicalNumericIndexString(P). + b. If numericIndex is not undefined, then + ... + 3. Return ? OrdinaryGet(O, P, Receiver). +includes: [testBigIntTypedArray.js] +features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] +---*/ + +TypedArray.prototype.baz = "test262"; + +testWithBigIntTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n]); + + assert.sameValue( + sample.foo, undefined, + "return undefined for inexistent properties" + ); + + sample.foo = "bar"; + assert.sameValue(sample.foo, "bar", "return value"); + + Object.defineProperty(sample, "bar", { + get: function() { return "baz"; } + }); + assert.sameValue(sample.bar, "baz", "return value from get accessor"); + + assert.sameValue(sample.baz, "test262", "return value from inherited key"); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/BigInt/key-is-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/BigInt/key-is-out-of-bounds.js new file mode 100644 index 0000000000..30ccf64286 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/BigInt/key-is-out-of-bounds.js @@ -0,0 +1,45 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-integer-indexed-exotic-objects-get-p-receiver +description: > + Return undefined if key is numeric index < 0 or index ≥ [[ArrayLength]]. +info: | + 9.4.5.4 [[Get]] (P, Receiver) + + ... + 2. If Type(P) is String, then + a. Let numericIndex be ! CanonicalNumericIndexString(P). + b. If numericIndex is not undefined, then + i. Return ? IntegerIndexedElementGet(O, numericIndex). + ... + + 9.4.5.8 IntegerIndexedElementGet ( O, index ) + + ... + 7. Let length be the value of O's [[ArrayLength]] internal slot. + 8. If index < 0 or index ≥ length, return undefined. + ... +includes: [testBigIntTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var proto = TypedArray.prototype; +var throwDesc = { + get: function() { + throw new Test262Error("OrdinaryGet was called! Ref: 9.1.8.1 3.c"); + } +}; +Object.defineProperty(proto, "-1", throwDesc); +Object.defineProperty(proto, "2", throwDesc); +Object.defineProperty(proto, "3", throwDesc); + +testWithBigIntTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n]); + + assert.sameValue(sample["-1"], undefined); + assert.sameValue(sample["2"], undefined); + assert.sameValue(sample["3"], undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/BigInt/key-is-symbol.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/BigInt/key-is-symbol.js new file mode 100644 index 0000000000..0ef9bee129 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/BigInt/key-is-symbol.js @@ -0,0 +1,42 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-integer-indexed-exotic-objects-get-p-receiver +description: > + Use OrdinaryGet if key is a Symbol +info: | + 9.4.5.4 [[Get]] (P, Receiver) + + ... + 2. If Type(P) is String, then + ... + 3. Return ? OrdinaryGet(O, P, Receiver). +includes: [testBigIntTypedArray.js] +features: [align-detached-buffer-semantics-with-web-reality, BigInt, Symbol, TypedArray] +---*/ + +var parentKey = Symbol("2"); +TypedArray.prototype[parentKey] = "test262"; + +testWithBigIntTypedArrayConstructors(function(TA) { + var sample = new TA([42n]); + + var s1 = Symbol("1"); + + assert.sameValue( + sample[s1], undefined, + "return undefined if not property is present" + ); + + sample[s1] = "foo"; + assert.sameValue(sample[s1], "foo", "return value"); + + Object.defineProperty(sample, s1, { + get: function() { return "bar"; } + }); + assert.sameValue(sample[s1], "bar", "return value from get accessor"); + + assert.sameValue(sample[parentKey], "test262", "value from parent key"); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/BigInt/shell.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/BigInt/shell.js new file mode 100644 index 0000000000..90ee9c114d --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/internals/Get/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; + } + } +} |