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

Side by Side Diff: tests/language/src/ConstructorTest.dart

Issue 10248007: test rename overhaul: step 8 - language tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011, 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 // Dart test program for constructors and initializers.
5
6 class A extends B {
7 A(x, y) : super(y), a = x { }
8
9 var a;
10 }
11
12
13 class B {
14 var b;
15
16 B(x) : b = x { }
17
18 B.namedB(var x) : b = x {}
19 }
20
21
22 // Test the order of initialization: first the instance variable then
23 // the super constructor.
24 class Alpha {
25 Alpha(v) {
26 this.foo(v);
27 }
28 }
29
30 class Beta extends Alpha {
31 Beta(v) : super(v), b = 1 {}
32
33 foo(v) {
34 // Check that 'b' was initialized.
35 Expect.equals(1, b);
36 b = v;
37 }
38
39 var b;
40 }
41
42 class ConstructorTest {
43 static testMain() {
44 var o = new A(10, 2);
45 Expect.equals(10, o.a);
46 Expect.equals(2, o.b);
47
48 var o1 = new B.namedB(10);
49 Expect.equals(10, o1.b);
50
51 Expect.equals(22, o.a + o.b + o1.b);
52
53 var beta = new Beta(3);
54 Expect.equals(3, beta.b);
55 }
56 }
57
58 main() {
59 ConstructorTest.testMain();
60 }
OLDNEW
« no previous file with comments | « tests/language/src/ConstructorSetterNegativeTest.dart ('k') | tests/language/src/Context2Test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698