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

Unified Diff: test/mjsunit/harmony/class-fields-super.js

Issue 2330473002: Class fields, part 3 (backends)
Patch Set: bytecode test Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/mjsunit/harmony/class-fields-scoping.js ('k') | test/mjsunit/harmony/class-fields-syntax.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
+}
« no previous file with comments | « test/mjsunit/harmony/class-fields-scoping.js ('k') | test/mjsunit/harmony/class-fields-syntax.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698