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

Unified Diff: tests/language/redirecting_constructor_initializer_test.dart

Issue 1129693006: Fix field initialization order for forwarding constructors. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Status Created 5 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
« no previous file with comments | « tests/language/language_dart2js.status ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/redirecting_constructor_initializer_test.dart
diff --git a/tests/language/redirecting_constructor_initializer_test.dart b/tests/language/redirecting_constructor_initializer_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..97c80057a515cbb5611f4ea4453f65a72ac3c381
--- /dev/null
+++ b/tests/language/redirecting_constructor_initializer_test.dart
@@ -0,0 +1,41 @@
+// Copyright (c) 2015, 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.
+
+import "package:expect/expect.dart";
+
+var string = '';
+
+append(x) {
+ string += x;
+ return x;
+}
+
+class A {
+ var x = append('x');
+ var y;
+ var z;
+
+ // Should append y but not yet x.
+ A() : this.foo(append('y'));
+
+ // Append x and z.
+ A.foo(this.y) : z = append('z');
+}
+
+class B extends A {
+ var w;
+
+ // Call the redirecting constructor using super.
+ B() : super(), w = append('w');
+}
+
+main() {
+ string = '';
+ new A();
+ Expect.equals('yxz', string);
+
+ string = '';
+ new B();
+ Expect.equals('yxzw', string);
+}
« no previous file with comments | « tests/language/language_dart2js.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698