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

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

Issue 2986973002: Add support for initializers in constructor invocation (Closed)
Patch Set: Apply review comments Created 3 years, 4 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/object_field_initializers_test.dart
diff --git a/pkg/kernel/testcases/interpreter/object_field_initializers_test.dart b/pkg/kernel/testcases/interpreter/object_field_initializers_test.dart
index 7910a338d4d66a9602e365425c0c0f67cc364e87..8c9c7893f06dac44aefac37c7434210999f117e4 100644
--- a/pkg/kernel/testcases/interpreter/object_field_initializers_test.dart
+++ b/pkg/kernel/testcases/interpreter/object_field_initializers_test.dart
@@ -10,6 +10,7 @@ library object_field_initializers_test;
/// The static function `fieldInitializer` is used to ensure the fields are
/// intialized in the correct order by tracking the order of side effects.
void main() {
+ print('Create instance of A');
var a1 = new A.withoutArguments();
print(a1.foo1);
print(a1.foo2);
@@ -19,11 +20,18 @@ void main() {
print(a2.foo2);
print(a2.foo3);
+ print('Create instance of B');
var b = new B(fieldInitializer(1, 'bar1'), fieldInitializer(2, 'bar2'));
print(b.foo1);
print(b.foo2);
print(b.foo3);
print(b.foo4);
+
+ print('Create instance of C');
+ var c = new C(fieldInitializer(1, 'bar1'), fieldInitializer(2, 'bar2'));
+ print(c.foo1);
+ print(c.foo2);
+ print(c.foo3);
}
class A {
@@ -51,6 +59,16 @@ class B {
}
}
+class C {
+ String foo1 = fieldInitializer(1, 'foo1');
+ String foo2;
+ String foo3 = fieldInitializer(2, 'foo3');
+
+ C(this.foo1, this.foo2) {
+ foo3 = fieldInitializer(3, 'foo3');
+ }
+}
+
String fieldInitializer(int f, String s) {
print('$s: $f');
return '$s: $f';

Powered by Google App Engine
This is Rietveld 408576698