Bug 1889091 - Part 3: Specialize calls to native functions with variadic parameters...
[gecko.git] / js / src / jit-test / tests / ion / apply-native-spreadnew-rest.js
blob58de8fa239fe0507fbc69c33319b6eb330518ee5
1 load(libdir + "array-compare.js");
3 const xs = [
4   // Zero arguments.
5   [],
7   // Single argument.
8   [1],
10   // Few arguments. Even number of arguments.
11   [1, 2],
13   // Few arguments. Odd number of arguments.
14   [1, 2, 3],
16   // Many arguments. Even number of arguments.
17   [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],
19   // Many arguments. Odd number of arguments.
20   [1, 2, 3, 4, 5, 6, 7, 8, 9],
23 function f(...x) {
24   // SpreadNew to a native function with rest-args.
25   return new Array(...x);
28 // Don't inline |f| into the top-level script.
29 with ({}) ;
31 for (let i = 0; i < 400; ++i) {
32   let x = xs[i % xs.length];
34   // NB: Array(1) creates the array `[,]`.
35   let expected = x.length !== 1 ? x : [,];
37   let result = f.apply(null, x);
38   assertEq(arraysEqual(result, expected), true);