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 // Dart test program testing top-level variables. | 4 // Dart test program testing top-level variables. |
5 | 5 |
6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
7 | 7 |
8 | |
9 var a, b; | 8 var a, b; |
10 | 9 |
11 | |
12 class TopLevelVarTest { | 10 class TopLevelVarTest { |
13 static testMain() { | 11 static testMain() { |
14 Expect.equals(null, a); | 12 Expect.equals(null, a); |
15 Expect.equals(null, b); | 13 Expect.equals(null, b); |
16 a = b = 100; | 14 a = b = 100; |
17 b++; | 15 b++; |
18 Expect.equals(100, a); | 16 Expect.equals(100, a); |
19 Expect.equals(101, b); | 17 Expect.equals(101, b); |
20 | 18 |
21 Expect.equals(111, x); | 19 Expect.equals(111, x); |
22 Expect.equals(112, y); | 20 Expect.equals(112, y); |
23 } | 21 } |
24 } | 22 } |
25 | 23 |
26 | |
27 // Ensure that initializers work for both const and non-const variables. | 24 // Ensure that initializers work for both const and non-const variables. |
28 const int x = 2 * 55 + 1; | 25 const int x = 2 * 55 + 1; |
29 int y = x + 1; | 26 int y = x + 1; |
30 | 27 |
31 | |
32 main() { | 28 main() { |
33 TopLevelVarTest.testMain(); | 29 TopLevelVarTest.testMain(); |
34 } | 30 } |
OLD | NEW |