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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/language/language.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 class A {
6 var _x, _y;
7 A(x, [y = 10]): _x = x++, _y = y++ {
8 // Check that value of modified constructor parameters
9 // is remembered in the constructor body.
10 Expect.equals(x, _x + 1);
11 Expect.equals(y, _y + 1);
12 Expect.isFalse(?y);
13 }
14 }
15
16 class B extends A {
17 var _a, _b;
18 // The super call in the middle of the initializer list conceptually
19 // forces two super call chains, one for initializer list and a second
20 // one for the constructor bodies.
21 B(a, b): _a = a++, super(a + b++), _b = b++ {
22 Expect.equals(a, _a + 1);
23 Expect.equals(b, _b + 1);
24 Expect.equals(a + (b-2), _x);
25 }
26 }
27
28 main() {
29 var o = new B(3, 5);
30 Expect.equals(3, o._a);
31 Expect.equals(6, o._b);
32 Expect.equals(9, o._x);
33 Expect.equals(10, o._y);
34 o = new A(3);
35 Expect.equals(3, o._x);
36 Expect.equals(10, o._y);
37 }
OLDNEW
« 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