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

Side by Side Diff: test/mjsunit/harmony/classes-experimental.js

Issue 867153003: new classes: special construct stub for derived classs and TDZ for `this`. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: CHECK_OK fixed Created 5 years, 10 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: --experimental-classes --harmony-classes 5 // Flags: --experimental-classes --harmony-classes
6 6
7 'use strict'; 7 'use strict';
8 8
9 class Base { 9 class Base {
10 constructor() { 10 constructor(a, b) {
11 let o = new Object(); 11 let o = new Object();
12 o.prp = 1; 12 o.prp = a + b;
13 return o; 13 return o;
14 } 14 }
15 } 15 }
16 16
17 class Subclass extends Base { 17 class Subclass extends Base {
18 constructor() { 18 constructor(a, b) {
19 var exn;
19 try { 20 try {
20 this.prp1 = 3; 21 this.prp1 = 3;
21 } catch (e) { 22 } catch (e) {
22 // TODO(dslomov): actually test the exception once TDZ is implemented. 23 exn = e;
23 } 24 }
24 super(); 25 assertTrue(exn instanceof ReferenceError);
25 assertSame(1, this.prp); 26 super(a, b);
27 assertSame(a + b, this.prp);
26 assertSame(undefined, this.prp1); 28 assertSame(undefined, this.prp1);
27 assertFalse(this.hasOwnProperty("prp1")); 29 assertFalse(this.hasOwnProperty("prp1"));
28 return this; 30 return this;
29 } 31 }
30 } 32 }
31 33
32 let s = new Subclass(); 34 let b = new Base(1, 2);
35 assertSame(3, b.prp);
36
37 let s = new Subclass(2, -1);
33 assertSame(1, s.prp); 38 assertSame(1, s.prp);
34 assertSame(undefined, s.prp1); 39 assertSame(undefined, s.prp1);
35 assertFalse(s.hasOwnProperty("prp1")); 40 assertFalse(s.hasOwnProperty("prp1"));
41
42 class Subclass2 extends Base {
43 constructor() {
44 super(1,2);
45
46 let called = false;
47 function tmp() { called = true; return 3; }
48 var exn = null;
49 try {
50 super(tmp(),4);
51 } catch(e) { exn = e; }
52 assertTrue(exn !== null);
53 assertFalse(called);
54 }
55 }
56
57 new Subclass2();
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