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 | 5 // Flags: --harmony-rest-parameters --harmony-classes |
6 | 6 |
7 (function testRestIndex() { | 7 (function testRestIndex() { |
8 assertEquals(5, (function(...args) { return args.length; })(1,2,3,4,5)); | 8 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)); | 9 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)); | 10 assertEquals(3, (function(a, b, ...args) { return args.length; })(1,2,3,4,5)); |
11 assertEquals(2, (function(a, b, c, ...args) { | 11 assertEquals(2, (function(a, b, c, ...args) { |
12 return args.length; })(1,2,3,4,5)); | 12 return args.length; })(1,2,3,4,5)); |
13 assertEquals(1, (function(a, b, c, d, ...args) { | 13 assertEquals(1, (function(a, b, c, d, ...args) { |
14 return args.length; })(1,2,3,4,5)); | 14 return args.length; })(1,2,3,4,5)); |
15 assertEquals(0, (function(a, b, c, d, e, ...args) { | 15 assertEquals(0, (function(a, b, c, d, e, ...args) { |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
173 var fn = (a, b, ...c) => c; | 173 var fn = (a, b, ...c) => c; |
174 assertEquals([], fn()); | 174 assertEquals([], fn()); |
175 assertEquals([], fn(1, 2)); | 175 assertEquals([], fn(1, 2)); |
176 assertEquals([3], fn(1, 2, 3)); | 176 assertEquals([3], fn(1, 2, 3)); |
177 assertEquals([3, 4], fn(1, 2, 3, 4)); | 177 assertEquals([3, 4], fn(1, 2, 3, 4)); |
178 assertEquals([3, 4, 5], fn(1, 2, 3, 4, 5)); | 178 assertEquals([3, 4, 5], fn(1, 2, 3, 4, 5)); |
179 assertThrows("var x = ...y => y;", SyntaxError); | 179 assertThrows("var x = ...y => y;", SyntaxError); |
180 assertEquals([], ((...args) => args)()); | 180 assertEquals([], ((...args) => args)()); |
181 assertEquals([1,2,3], ((...args) => args)(1,2,3)); | 181 assertEquals([1,2,3], ((...args) => args)(1,2,3)); |
182 })();*/ | 182 })();*/ |
183 | |
184 | |
185 (function testRestParamsWithNewTarget() { | |
186 "use strict"; | |
187 class Base { | |
188 constructor(...a) { this.base = a; } | |
Dmitry Lomov (no reviews)
2015/03/20 08:32:46
Please add tests that validate 'arguments' behavi
caitp (gmail)
2015/03/20 13:28:40
You mean, assert that the arguments elements are i
Dmitry Lomov (no reviews)
2015/03/20 13:45:14
First part is what I meant - since you indirectly
| |
189 } | |
190 class Child extends Base { | |
191 constructor(...b) { super(1, 2, 3); this.child = b; } | |
192 } | |
193 | |
194 var c = new Child(1, 2, 3); | |
195 assertEquals([1, 2, 3], c.child); | |
196 assertEquals([1, 2, 3], c.base); | |
197 })(); | |
OLD | NEW |