From 8dd16259287f58f9273002717ec4d27e97127719 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 07:43:14 +0200 Subject: Merging upstream version 127.0. Signed-off-by: Daniel Baumann --- .../index-compared-against-initial-length.js | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 js/src/tests/test262/built-ins/TypedArray/prototype/includes/index-compared-against-initial-length.js (limited to 'js/src/tests/test262/built-ins/TypedArray/prototype/includes/index-compared-against-initial-length.js') diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/index-compared-against-initial-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/index-compared-against-initial-length.js new file mode 100644 index 0000000000..572381275e --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/index-compared-against-initial-length.js @@ -0,0 +1,50 @@ +// |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options +// Copyright (C) 2024 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-%typedarray%.prototype.includes +description: > + Index is compared against the initial length. +info: | + %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) + + ... + 2. Let taRecord be ? ValidateTypedArray(O, seq-cst). + 3. Let len be TypedArrayLength(taRecord). + ... + 5. Let n be ? ToIntegerOrInfinity(fromIndex). + ... + 9. If n ≥ 0, then + a. Let k be n. + ... + 11. Repeat, while k < len, + ... + +features: [TypedArray, resizable-arraybuffer] +---*/ + +let rab = new ArrayBuffer(4, {maxByteLength: 20}); +let ta = new Int8Array(rab); + +let index = { + valueOf() { + // Shrink buffer to zero. + rab.resize(0); + + // Index is larger than the initial length. + return 10; + } +}; + +// Auto-length is correctly tracked. +assert.sameValue(ta.length, 4); + +let result = ta.includes(undefined, index); + +// Auto-length is correctly set to zero. +assert.sameValue(ta.length, 0); + +assert.sameValue(result, false); + +reportCompare(0, 0); -- cgit v1.2.3