1 // Copyright (C) 2021 Igalia, S.L. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
5 esid: sec-array.prototype.with
7 Array.prototype.with adds length to index if it's negative.
9 Array.prototype.with ( index, value )
12 2. Let len be ? LengthOfArrayLike(O).
13 3. Let relativeIndex be ? ToIntegerOrInfinity(index).
14 4. If index >= 0, let actualIndex be relativeIndex.
15 5. Else, let actualIndex be len + relativeIndex.
17 features: [change-array-by-copy]
18 includes: [compareArray.js]
23 assert.compareArray(arr.with(-1, 4), [0, 1, 4]);
24 assert.compareArray(arr.with(-3, 4), [4, 1, 2]);
27 assert.compareArray(arr.with(-0, 4), [4, 1, 2]);