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

Unified Diff: test/mjsunit/harmony/class-fields-evaluation-order.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
Index: test/mjsunit/harmony/class-fields-evaluation-order.js
diff --git a/test/mjsunit/harmony/class-fields-evaluation-order.js b/test/mjsunit/harmony/class-fields-evaluation-order.js
new file mode 100644
index 0000000000000000000000000000000000000000..4f2f0d405bc5cb45a68c9da5ed3048dbee6bbe6e
--- /dev/null
+++ b/test/mjsunit/harmony/class-fields-evaluation-order.js
@@ -0,0 +1,104 @@
+// 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
+
+{
+ let effects = [];
+ class C {
+ a = (effects.push(0), 0);
+ a = (effects.push(1), 1);
+ }
+
+ let c = new C;
+ assertArrayEquals([0, 1], effects);
+ assertEquals(1, c.a);
+}
+
+{
+ let effects = [];
+ class C {
+ a = (effects.push(0), 0);
+ ['a'] = (effects.push(1), 1);
+ }
+
+ let c = new C;
+ assertArrayEquals([0, 1], effects);
+ assertEquals(1, c.a);
+}
+
+{
+ let effects = [];
+ class C {
+ static a = (effects.push(0), 0);
+ static a = (effects.push(1), 1);
+ }
+
+ assertArrayEquals([0, 1], effects);
+ assertEquals(1, C.a);
+}
+
+{
+ class C {
+ a = 0;
+ b = assertEquals(0, this.a);
+ }
+
+ new C;
+}
+
+{
+ let effects = [];
+
+ class C {
+ static [effects.push(0)] = effects.push(1);
+ [effects.push(2)] = effects.push(13);
+ static [effects.push(3)];
+ [effects.push(4)];
+ static [effects.push(5)](){}
+ [effects.push(6)](){}
+ static [effects.push(7)](){}
+ [effects.push(8)];
+ static [effects.push(9)];
+ [effects.push(10)] = effects.push(14);
+ static [effects.push(11)] = effects.push(12);
+
+ constructor() {
+ effects.push(15);
+ }
+ }
+ assertArrayEquals([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], effects);
+
+ new C;
+ assertArrayEquals([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], effects);
+}
+
+{
+ let effects = [];
+
+ class Base {
+ a = (effects.push(1), 0);
+
+ constructor() {
+ effects.push(2);
+ assertEquals(undefined, this.c);
+ assertEquals(0, this.a);
+ this.b = 1;
+ }
+ }
+
+ class Derived extends Base {
+ c = (assertEquals(0, this.a), assertEquals(1, this.b), effects.push(3), 2);
+
+ constructor() {
+ effects.push(0);
+ super();
+ effects.push(4);
+ assertEquals(2, this.c);
+ }
+ }
+
+ new Derived;
+ assertArrayEquals([0, 1, 2, 3, 4], effects);
+}
« no previous file with comments | « test/mjsunit/harmony/class-fields-attributes.js ('k') | test/mjsunit/harmony/class-fields-function-name-inference.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698