Backed out 2 changesets (bug 1888310, bug 1884625) for causing failures on browser_ap...
[gecko.git] / js / src / tests / test262 / staging / built-ins / Array / prototype / flatMap / callback-with-side-effects.js
blob83d205762378e3305c5a3c7a4c6e7017269cc9f1
1 // Copyright (C) 2024 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
4 /*---
5 esid: sec-array.prototype.flatMap
6 description: >
7   Array.prototype.flatMap is given a callback that modifies the array being
8   iterated.
9 includes: [compareArray.js]
10 ---*/
12 (function TestGrow() {
13   let array = [0,1,2,3];
14   function f(e) {
15     array[4] = 42;
16     return e;
17   }
18   assert.compareArray(array.flatMap(f), [0,1,2,3]);
19 })();
21 (function TestShrink() {
22   let array = [0,1,2,3];
23   function f(e) {
24     array.length = 3;
25     return e;
26   }
27   assert.compareArray(array.flatMap(f), [0,1,2]);
28 })();
30 reportCompare(0, 0);