Index: test/mjsunit/harmony/class-fields-super.js |
diff --git a/test/mjsunit/harmony/class-fields-super.js b/test/mjsunit/harmony/class-fields-super.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..969019bcf19b9a1722855a9a9ef8b9871c8e8bb3 |
--- /dev/null |
+++ b/test/mjsunit/harmony/class-fields-super.js |
@@ -0,0 +1,147 @@ |
+// Copyright 2016 the V8 project authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+// Flags: --harmony-class-fields |
+ |
+{ |
+ class Base { |
+ a = 0; |
+ } |
+ |
+ class Derived extends Base { |
+ b = 1; |
+ } |
+ |
+ let c = new Derived; |
+ assertTrue(c.hasOwnProperty('a')); |
+ assertEquals(0, c.a); |
+ assertTrue(c.hasOwnProperty('b')); |
+ assertEquals(1, c.b); |
+} |
+ |
+{ |
+ class Base { |
+ a = 0; |
+ } |
+ |
+ class Derived extends Base { |
+ b = 1; |
+ constructor() { |
+ super(); |
+ } |
+ } |
+ |
+ let c = new Derived; |
+ assertTrue(c.hasOwnProperty('a')); |
+ assertEquals(0, c.a); |
+ assertTrue(c.hasOwnProperty('b')); |
+ assertEquals(1, c.b); |
+} |
+ |
+{ |
+ class Base { |
+ a = 0; |
+ } |
+ |
+ class Derived extends Base { |
+ a; |
+ } |
+ |
+ let c = new Derived; |
+ assertTrue(c.hasOwnProperty('a')); |
+ assertEquals(undefined, c.a); |
+} |
+ |
+{ |
+ class Base { |
+ a = 0; |
+ } |
+ |
+ class Derived extends Base { |
+ a; |
+ constructor() { |
+ super(); |
+ } |
+ } |
+ |
+ let c = new Derived; |
+ assertTrue(c.hasOwnProperty('a')); |
+ assertEquals(undefined, c.a); |
+} |
+ |
+{ |
+ class Base { |
+ a() { |
+ return 0; |
+ } |
+ } |
+ |
+ class Derived extends Base { |
+ a = () => eval("super.a()"); |
+ } |
+ |
+ let c = new Derived; |
+ assertEquals(0, c.a()); |
+} |
+ |
+{ |
+ class Base { |
+ a() { |
+ return 0; |
+ } |
+ } |
+ |
+ class Derived extends Base { |
+ a = () => eval("super.a()"); |
+ constructor() { |
+ super(); |
+ } |
+ } |
+ |
+ let c = new Derived; |
+ assertEquals(0, c.a()); |
+} |
+ |
+{ |
+ class Base { |
+ static a() { |
+ return 0; |
+ } |
+ } |
+ |
+ class Derived extends Base { |
+ static a = () => eval("super.a()"); |
+ } |
+ |
+ assertEquals(0, Derived.a()); |
+} |
+ |
+{ |
+ let deferred; |
+ let hit = false; |
+ |
+ class Base { |
+ a = (hit = true, 0); |
+ constructor() { |
+ hit = true; |
+ this.b = (assertEquals(0, this.a), 1); |
+ } |
+ } |
+ |
+ class Derived extends Base { |
+ c = (hit = true, assertEquals(1, this.b), 2); |
+ constructor() { |
+ deferred = () => super(); |
+ } |
+ } |
+ assertFalse(hit); |
+ |
+ let thrown = false; |
+ assertThrows(() => new Derived); |
+ |
+ let c = deferred(); |
+ assertEquals(0, c.a); |
+ assertEquals(1, c.b); |
+ assertEquals(2, c.c); |
+} |