OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 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: --harmony-rest-parameters --min-preparse-length=0 |
| 6 |
| 7 function variadic(co, ...values) { |
| 8 var sum = 0; |
| 9 while (values.length) { |
| 10 sum += co * values.pop(); |
| 11 } |
| 12 return sum; |
| 13 } |
| 14 |
| 15 assertEquals(90, variadic(2, 1, 2, 3, 4, 5, 6, 7, 8, 9)); |
| 16 assertEquals(74, variadic(2, 1, 2, 3, 4, 5, 6, 7, 9)); |
| 17 assertEquals(110, variadic(2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)); |
OLD | NEW |