From 563dd6006f986100611ee39994e41a3e475cc82c Mon Sep 17 00:00:00 2001 From: Tobias Wienand Date: Fri, 20 Sep 2024 11:29:28 +0200 Subject: [PATCH] Implements test cases for arrays with spreading --- .../FuzzilliTests/CompilerTests/spreading.js | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/Tests/FuzzilliTests/CompilerTests/spreading.js b/Tests/FuzzilliTests/CompilerTests/spreading.js index 33cfaa8e..bdf5cd84 100644 --- a/Tests/FuzzilliTests/CompilerTests/spreading.js +++ b/Tests/FuzzilliTests/CompilerTests/spreading.js @@ -6,7 +6,7 @@ function foo(a, b, c) { output(c); } -let a = [1,2,3,4]; +let a = [1, 2, 3, 4]; foo(...a); foo(100, ...a); @@ -24,4 +24,27 @@ o.foo(100, ...a); o.foo(100, 101, ...a); o.foo(100, 101, 102, ...a); -// TODO also add tests for spreading in array literals +// Array spreading tests +let array1 = [10, 20, 30]; +let array2 = [...array1]; + +output(array1); +output(array2); + +array1[0] = 100; +output(array1); +output(array2); + +let combinedArray = [5, ...array1, 50]; +output(combinedArray); + +// Spread with array-like objects +function testArguments() { + let argsArray = [...arguments]; + output(argsArray); +} + +testArguments(1, 2, 3); + +let nestedArray = [...[...[1, 2, 3]], ...[4, 5]]; +output(nestedArray);