OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Flags: --harmony-rest-parameters | |
6 | |
7 (function testRestIndex() { | 5 (function testRestIndex() { |
8 assertEquals(5, (function(...args) { return args.length; })(1,2,3,4,5)); | 6 assertEquals(5, (function(...args) { return args.length; })(1,2,3,4,5)); |
9 assertEquals(4, (function(a, ...args) { return args.length; })(1,2,3,4,5)); | 7 assertEquals(4, (function(a, ...args) { return args.length; })(1,2,3,4,5)); |
10 assertEquals(3, (function(a, b, ...args) { return args.length; })(1,2,3,4,5)); | 8 assertEquals(3, (function(a, b, ...args) { return args.length; })(1,2,3,4,5)); |
11 assertEquals(2, (function(a, b, c, ...args) { | 9 assertEquals(2, (function(a, b, c, ...args) { |
12 return args.length; })(1,2,3,4,5)); | 10 return args.length; })(1,2,3,4,5)); |
13 assertEquals(1, (function(a, b, c, d, ...args) { | 11 assertEquals(1, (function(a, b, c, d, ...args) { |
14 return args.length; })(1,2,3,4,5)); | 12 return args.length; })(1,2,3,4,5)); |
15 assertEquals(0, (function(a, b, c, d, e, ...args) { | 13 assertEquals(0, (function(a, b, c, d, e, ...args) { |
16 return args.length; })(1,2,3,4,5)); | 14 return args.length; })(1,2,3,4,5)); |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 function(){ eval("(class{foo(...rest) {'use strict';}});") }, SyntaxError); | 210 function(){ eval("(class{foo(...rest) {'use strict';}});") }, SyntaxError); |
213 | 211 |
214 assertThrows( | 212 assertThrows( |
215 function(){ eval("function(a, ...rest){'use strict';}") }, SyntaxError); | 213 function(){ eval("function(a, ...rest){'use strict';}") }, SyntaxError); |
216 assertThrows( | 214 assertThrows( |
217 function(){ eval("(a, ...rest) => {'use strict';}") }, SyntaxError); | 215 function(){ eval("(a, ...rest) => {'use strict';}") }, SyntaxError); |
218 assertThrows( | 216 assertThrows( |
219 function(){ eval("(class{foo(a, ...rest) {'use strict';}});") }, | 217 function(){ eval("(class{foo(a, ...rest) {'use strict';}});") }, |
220 SyntaxError); | 218 SyntaxError); |
221 })(); | 219 })(); |
OLD | NEW |