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

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: rebase + clang-format Created 5 years, 8 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 2015 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-rest-parameters
6
7
8 (function testConstructClassStrict() {
9 "use strict";
10 class Base {
11 constructor(...args) {
12 this.baseArgs = args;
13 }
14 method() { return this.baseArgs; }
15 }
16
17 class Child extends Base {
18 constructor(...args) {
19 super(...args);
20 this.childArgs = args;
21 }
22 }
23
24 class Child2 extends Base {
25 constructor(...args) {
26 super("extra", ...args);
27 this.childArgs = args;
28 }
29 }
30
31 var c = new Base(...[1, 2, 3]);
32 assertInstanceof(c, Base);
33 assertEquals([1, 2, 3], c.method());
34 assertEquals([1, 2, 3], c.baseArgs);
35
36 c = new Child(...[1, 2, 3]);
37 assertInstanceof(c, Child);
38 assertInstanceof(c, Base);
39 assertEquals([1, 2, 3], c.method());
40 assertEquals([1, 2, 3], c.baseArgs);
41 assertEquals([1, 2, 3], c.childArgs);
42
43 c = new Child2(...[1, 2, 3]);
44 assertInstanceof(c, Child2);
45 assertInstanceof(c, Base);
46 assertEquals(["extra", 1, 2, 3], c.method());
47 assertEquals(["extra", 1, 2, 3], c.baseArgs);
48 assertEquals([1, 2, 3], c.childArgs);
49 })();
50
51
52 (function testConstructSloppy() {
53 class Base {
54 constructor(...args) {
55 this.baseArgs = args;
56 }
57 method() { return this.baseArgs; }
58 }
59
60 class Child extends Base {
61 constructor(...args) {
62 super(...args);
63 this.childArgs = args;
64 }
65 }
66
67 class Child2 extends Base {
68 constructor(...args) {
69 super("extra", ...args);
70 this.childArgs = args;
71 }
72 }
73
74 var c = new Base(...[1, 2, 3]);
75 assertInstanceof(c, Base);
76 assertEquals([1, 2, 3], c.method());
77 assertEquals([1, 2, 3], c.baseArgs);
78
79 c = new Child(...[1, 2, 3]);
80 assertInstanceof(c, Child);
81 assertInstanceof(c, Base);
82 assertEquals([1, 2, 3], c.method());
83 assertEquals([1, 2, 3], c.baseArgs);
84 assertEquals([1, 2, 3], c.childArgs);
85
86 c = new Child2(...[1, 2, 3]);
87 assertInstanceof(c, Child2);
88 assertInstanceof(c, Base);
89 assertEquals(["extra", 1, 2, 3], c.method());
90 assertEquals(["extra", 1, 2, 3], c.baseArgs);
91 assertEquals([1, 2, 3], c.childArgs);
92 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698