OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 | 6 |
7 class A { | 7 class A { |
8 A() { | 8 A() {} |
9 } | |
10 int x; | 9 int x; |
11 | 10 |
12 foo() { | 11 foo() { |
13 x = 42; | 12 x = 42; |
14 Expect.equals(42, x); | 13 Expect.equals(42, x); |
15 x = 0; | 14 x = 0; |
16 Expect.equals(0, x); | 15 Expect.equals(0, x); |
17 } | 16 } |
18 } | 17 } |
19 | 18 |
20 class B extends A { | 19 class B extends A {} |
21 } | |
22 | 20 |
23 main() { | 21 main() { |
24 A a = new A(); | 22 A a = new A(); |
25 a.foo(); | 23 a.foo(); |
26 Expect.equals(0, a.x); | 24 Expect.equals(0, a.x); |
27 a.x = 4; | 25 a.x = 4; |
28 Expect.equals(4, a.x); | 26 Expect.equals(4, a.x); |
29 a.x += 1; | 27 a.x += 1; |
30 Expect.equals(5, a.x); | 28 Expect.equals(5, a.x); |
31 | 29 |
32 B b = new B(); | 30 B b = new B(); |
33 b.foo(); | 31 b.foo(); |
34 Expect.equals(0, b.x); | 32 Expect.equals(0, b.x); |
35 } | 33 } |
OLD | NEW |