[test262] Add a new staging test for Array.p.flatMap

Bug: v8:14306
Change-Id: Ibc7a04288a0c31bfcf601aa864e02b6c067045c2
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5259306
Reviewed-by: Shu-yu Guo <syg@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/main@{#92174}
This commit is contained in:
Igor Sheludko 2024-02-02 12:01:56 -08:00 committed by test262-pr-bot
parent 3e7938c1f5
commit f742eb092d
1 changed files with 28 additions and 0 deletions

View File

@ -0,0 +1,28 @@
// Copyright (C) 2024 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-array.prototype.flatMap
description: >
Array.prototype.flatMap is given a callback that modifies the array being
iterated.
includes: [compareArray.js]
---*/
(function TestGrow() {
let array = [0,1,2,3];
function f(e) {
array[4] = 42;
return e;
}
assert.compareArray(array.flatMap(f), [0,1,2,3]);
})();
(function TestShrink() {
let array = [0,1,2,3];
function f(e) {
array.length = 3;
return e;
}
assert.compareArray(array.flatMap(f), [0,1,2]);
})();