OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Flags: --allow-natives-syntax --turbo |
| 6 |
| 7 (function Rest0Params() { |
| 8 |
| 9 function f(x, y) { |
| 10 return x+y; |
| 11 } |
| 12 |
| 13 function test(...rest) { |
| 14 return [rest, f.apply(null, rest)]; |
| 15 } |
| 16 |
| 17 assertEquals(test(), [[], NaN]); |
| 18 assertEquals(test(1), [[1], NaN]) |
| 19 assertEquals(test(1, 2), [[1,2], 3]); |
| 20 assertEquals(test(1, 2, 3), [[1,2,3], 3]); |
| 21 |
| 22 %OptimizeFunctionOnNextCall(test); |
| 23 |
| 24 assertEquals(test(), [[], NaN]); |
| 25 assertEquals(test(1), [[1], NaN]) |
| 26 assertEquals(test(1, 2), [[1,2], 3]); |
| 27 assertEquals(test(1, 2, 3), [[1,2,3], 3]); |
| 28 })(); |
| 29 |
| 30 (function Rest1Params() { |
| 31 |
| 32 function f(x, y) { |
| 33 return x+y |
| 34 } |
| 35 |
| 36 function test(a, ...rest) { |
| 37 return [rest, a, f.apply(null, rest)]; |
| 38 } |
| 39 |
| 40 assertEquals(test(), [[], undefined, NaN]); |
| 41 assertEquals(test(1), [[], 1, NaN]); |
| 42 assertEquals(test(1, 2), [[2], 1, NaN]); |
| 43 assertEquals(test(1, 2, 3), [[2,3], 1, 5]); |
| 44 assertEquals(test(1, 2, 3, 4), [[2,3,4], 1, 5]); |
| 45 |
| 46 %OptimizeFunctionOnNextCall(test); |
| 47 |
| 48 assertEquals(test(), [[], undefined, NaN]); |
| 49 assertEquals(test(1), [[], 1, NaN]); |
| 50 assertEquals(test(1, 2), [[2], 1, NaN]); |
| 51 assertEquals(test(1, 2, 3), [[2,3], 1, 5]); |
| 52 assertEquals(test(1, 2, 3, 4), [[2,3,4], 1, 5]); |
| 53 |
| 54 })(); |
OLD | NEW |