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

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

Issue 885643004: new classes: assert that constructors are not callable and rewrite 'return;' (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix bit width 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/runtime/runtime-classes.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(a, b) { 10 constructor(a, b) {
(...skipping 16 matching lines...) Expand all
27 assertSame(a + b, this.prp); 27 assertSame(a + b, this.prp);
28 assertSame(undefined, this.prp1); 28 assertSame(undefined, this.prp1);
29 assertFalse(this.hasOwnProperty("prp1")); 29 assertFalse(this.hasOwnProperty("prp1"));
30 return this; 30 return this;
31 } 31 }
32 } 32 }
33 33
34 let b = new Base(1, 2); 34 let b = new Base(1, 2);
35 assertSame(3, b.prp); 35 assertSame(3, b.prp);
36 36
37
37 let s = new Subclass(2, -1); 38 let s = new Subclass(2, -1);
38 assertSame(1, s.prp); 39 assertSame(1, s.prp);
39 assertSame(undefined, s.prp1); 40 assertSame(undefined, s.prp1);
40 assertFalse(s.hasOwnProperty("prp1")); 41 assertFalse(s.hasOwnProperty("prp1"));
41 42
42 class Subclass2 extends Base { 43 class Subclass2 extends Base {
43 constructor() { 44 constructor(x) {
44 super(1,2); 45 super(1,2);
45 46
47 if (x < 0) return;
48
46 let called = false; 49 let called = false;
47 function tmp() { called = true; return 3; } 50 function tmp() { called = true; return 3; }
48 var exn = null; 51 var exn = null;
49 try { 52 try {
50 super(tmp(),4); 53 super(tmp(),4);
51 } catch(e) { exn = e; } 54 } catch(e) { exn = e; }
52 assertTrue(exn !== null); 55 assertTrue(exn !== null);
53 assertFalse(called); 56 assertFalse(called);
54 } 57 }
55 } 58 }
56 59
57 new Subclass2(); 60 var s2 = new Subclass2(1);
61 assertSame(3, s2.prp);
62
63 var s3 = new Subclass2(-1);
64 assertSame(3, s3.prp);
65
66 assertThrows(function() { Subclass.call(new Object(), 1, 2); }, TypeError);
67 assertThrows(function() { Base.call(new Object(), 1, 2); }, TypeError);
OLDNEW
« no previous file with comments | « src/runtime/runtime-classes.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698