diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/detached-buffer-during-fromIndex-returns-false-for-zero.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/detached-buffer-during-fromIndex-returns-false-for-zero.js')
-rw-r--r-- | js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/detached-buffer-during-fromIndex-returns-false-for-zero.js | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/detached-buffer-during-fromIndex-returns-false-for-zero.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/detached-buffer-during-fromIndex-returns-false-for-zero.js new file mode 100644 index 0000000000..323885aee8 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/detached-buffer-during-fromIndex-returns-false-for-zero.js @@ -0,0 +1,48 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.includes +description: Returns -1 if buffer is detached after ValidateTypedArray +info: | + %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) + + The interpretation and use of the arguments of %TypedArray%.prototype.includes are the same as for Array.prototype.includes as defined in 22.1.3.13. + + When the includes method is called with one or two arguments, the following steps are taken: + + Let O be the this value. + Perform ? ValidateTypedArray(O). + Let len be O.[[ArrayLength]]. + If len is 0, return false. + Let n be ? ToIntegerOrInfinity(fromIndex). + Assert: If fromIndex is undefined, then n is 0. + If n is +∞, return false. + Else if n is -∞, set n to 0. + If n ≥ 0, then + Let k be n. + Else, + Let k be len + n. + If k < 0, set k to 0. + Repeat, while k < len, + Let elementK be the result of ! Get(O, ! ToString(F(k))). + If SameValueZero(searchElement, elementK) is true, return true. + Set k to k + 1. + Return false. + +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] +features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + const sample = new TA(1); + const fromIndex = { + valueOf() { + $DETACHBUFFER(sample.buffer); + return 0; + } + }; + + assert.sameValue(sample.includes(0n, fromIndex), false); +}); + +reportCompare(0, 0); |