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

Side by Side Diff: test/mjsunit/harmony/spread-call-new-class.js

Issue 938443002: [es6] implement spread calls (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Remove --harmony-spread flag 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
OLDNEW
(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-spreadcalls --harmony-sloppy --harmony-classes
arv (Not doing code reviews) 2015/03/30 22:19:49 --harmony-classes can be removed
6 // Flags: --harmony-rest-parameters
7
8
9 (function testConstructClassStrict() {
10 "use strict";
11 class Base {
12 constructor(...args) {
13 this.baseArgs = args;
14 }
15 method() { return this.baseArgs; }
16 }
17
18 class Child extends Base {
19 constructor(...args) {
20 super(...args);
arv (Not doing code reviews) 2015/03/30 22:19:49 Maybe also add a case with `super(x, ...y)`
arv (Not doing code reviews) 2015/03/30 22:19:49 Awesome!
caitp (gmail) 2015/03/30 22:38:12 Acknowledged.
21 this.childArgs = args;
22 }
23 }
24
25 var c = new Base(...[1, 2, 3]);
26 assertInstanceof(c, Base);
27 assertEquals([1, 2, 3], c.method());
28 assertEquals([1, 2, 3], c.baseArgs);
29
30 c = new Child(...[1, 2, 3]);
31 assertInstanceof(c, Child);
32 assertInstanceof(c, Base);
33 assertEquals([1, 2, 3], c.method());
34 assertEquals([1, 2, 3], c.baseArgs);
35 assertEquals([1, 2, 3], c.childArgs);
36 })();
37
38
39 (function testConstructSloppy() {
40 class Base {
41 constructor(...args) {
42 this.baseArgs = args;
43 }
44 method() { return this.baseArgs; }
45 }
46
47 class Child extends Base {
48 constructor(...args) {
49 super(...args);
50 this.childArgs = args;
51 }
52 }
53
54 var c = new Base(...[1, 2, 3]);
55 assertInstanceof(c, Base);
56 assertEquals([1, 2, 3], c.method());
57 assertEquals([1, 2, 3], c.baseArgs);
58
59 c = new Child(...[1, 2, 3]);
60 assertInstanceof(c, Child);
61 assertInstanceof(c, Base);
62 assertEquals([1, 2, 3], c.method());
63 assertEquals([1, 2, 3], c.baseArgs);
64 assertEquals([1, 2, 3], c.childArgs);
65 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698