Skip to content

Commit

Permalink
Implements test cases for arrays with spreading
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiasWienand committed Sep 20, 2024
1 parent 8e4401c commit 563dd60
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions Tests/FuzzilliTests/CompilerTests/spreading.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);

0 comments on commit 563dd60

Please sign in to comment.