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

Unified Diff: tests/language/constructor_initializer_test.dart

Issue 13181004: Add constructor test (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 9 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 | « no previous file | tests/language/language.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/constructor_initializer_test.dart
===================================================================
--- tests/language/constructor_initializer_test.dart (revision 0)
+++ tests/language/constructor_initializer_test.dart (revision 0)
@@ -0,0 +1,34 @@
+// Copyright (c) 2013, 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.
+
+class A {
+ var _x, _y;
+ A(x, [y = 10]): _x = x++, _y = y++ {
+ // Check that value of modified constructor parameters
+ // is remembered in the constructor body.
+ Expect.equals(x, _x + 1);
+ Expect.equals(y, _y + 1);
+ Expect.isFalse(?y);
+ }
+}
+
+class B extends A {
+ var _a, _b;
+ // The super call in the middle of the initializer list conceptually
+ // forces two super call chains, one for initializer list and a second
+ // one for the constructor bodies.
+ B(a, b): _a = a++, super(a + b++), _b = b++ {
+ Expect.equals(a, _a + 1);
+ Expect.equals(b, _b + 1);
+ Expect.equals(a + (b-2), _x);
+ }
+}
+
+main() {
+ var o = new B(3, 5);
Ivan Posva 2013/03/28 17:46:27 Please make sure that calling A on its own also ge
hausner 2013/03/28 20:06:47 Done.
+ Expect.equals(3, o._a);
+ Expect.equals(6, o._b);
+ Expect.equals(9, o._x);
+ Expect.equals(10, o._y);
+}
« no previous file with comments | « no previous file | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698