From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../prototype/toSpliced/holes-not-preserved.js | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 js/src/tests/test262/built-ins/Array/prototype/toSpliced/holes-not-preserved.js (limited to 'js/src/tests/test262/built-ins/Array/prototype/toSpliced/holes-not-preserved.js') diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSpliced/holes-not-preserved.js b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/holes-not-preserved.js new file mode 100644 index 0000000000..3fb2e312a2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSpliced/holes-not-preserved.js @@ -0,0 +1,43 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced does not preserve holes in the array +info: | + Array.prototype.toSpliced ( start, deleteCount, ...items ) + + ... + 13. Let k be 0. + 14. Repeat, while k < actualStart, + a. Let Pk be ! ToString(𝔽(k)). + b. Let kValue be ? Get(O, Pk). + c. Perform ? CreateDataPropertyOrThrow(A, Pk, kValue). + d. Set k to k + 1. + ... + 16. Repeat, while k < newLen, + a. Let Pk be ! ToString(𝔽(k)). + b. Let from be ! ToString(𝔽(k + actualDeleteCount - insertCount)). + c. Let fromValue be ? Get(O, from). + d. Perform ? CreateDataPropertyOrThrow(A, Pk, fromValue). + e. Set k to k + 1. + ... +includes: [compareArray.js] +features: [change-array-by-copy] +---*/ + +var arr = [0, /* hole */, 2, /* hole */, 4]; +Array.prototype[3] = 3; + +var spliced = arr.toSpliced(0, 0); +assert.compareArray(spliced, [0, undefined, 2, 3, 4]); +assert(spliced.hasOwnProperty(1)); +assert(spliced.hasOwnProperty(3)); + +spliced = arr.toSpliced(0, 0, -1); +assert.compareArray(spliced, [-1, 0, undefined, 2, 3, 4]); +assert(spliced.hasOwnProperty(1)); +assert(spliced.hasOwnProperty(3)); + +reportCompare(0, 0); -- cgit v1.2.3