Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: test/mjsunit/harmony/rest-params.js

Issue 1018043003: [es6] generate rest parameters correctly for subclass constructors (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Test that rest params have same elements as arguments object, too Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/x64/full-codegen-x64.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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) {
189 this.base = a;
190 assertEquals(arguments.length, a.length);
191 var args = [];
192 for (var i = 0; i < arguments.length; ++i) {
193 args.push(arguments[i]);
194 }
195 assertEquals(args, a);
196 }
197 }
198 class Child extends Base {
199 constructor(...b) {
200 super(1, 2, 3);
201 this.child = b;
202 assertEquals(arguments.length, b.length);
203 var args = [];
204 for (var i = 0; i < arguments.length; ++i) {
205 args.push(arguments[i]);
206 }
207 assertEquals(args, b);
208 }
209 }
210
211 var c = new Child(1, 2, 3);
212 assertEquals([1, 2, 3], c.child);
213 assertEquals([1, 2, 3], c.base);
214 })();
OLDNEW
« no previous file with comments | « src/x64/full-codegen-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698