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

Unified Diff: pkg/kernel/testcases/interpreter/constructor_test.dart

Issue 2880343002: Add support for execution of constructor body (Closed)
Patch Set: Refactor Created 3 years, 7 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: pkg/kernel/testcases/interpreter/constructor_test.dart
diff --git a/pkg/kernel/testcases/interpreter/constructor_test.dart b/pkg/kernel/testcases/interpreter/constructor_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..5e3d19b9c911a63bddf2c64dcbc1b3b9ea25e5fb
--- /dev/null
+++ b/pkg/kernel/testcases/interpreter/constructor_test.dart
@@ -0,0 +1,36 @@
+// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library constructor_test;
+
+void main() {
+ var a = new A();
+ print(a.foo);
+ print('******************');
+
+ var b = new B();
+ print(b.foo);
+ print(b.bar);
+}
+
+class A {
+ String foo = fieldInitializer(0, 'A.foo');
+
+ A() : foo = fieldInitializer(1, 'A.foo') {
+ foo = fieldInitializer(2, 'A.foo');
+ }
+}
+
+class B extends A {
+ String bar = fieldInitializer(0, 'B.bar');
+
+ B() : bar = fieldInitializer(1, 'B.bar') {
+ bar = fieldInitializer(2, 'B.bar');
+ }
+}
+
+String fieldInitializer(int f, String s) {
+ print('$s: $f');
+ return '$s: $f';
+}

Powered by Google App Engine
This is Rietveld 408576698