Bug 1889091 - Part 3: Specialize calls to native functions with variadic parameters...
[gecko.git] / js / src / jit-test / tests / ion / apply-native-spreadnew-array.js
blob5c716f48b468b33959c920c299f44ceea2fa462d
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 an array.
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(x);
38   assertEq(arraysEqual(result, expected), true);