OLD | NEW |
| (Empty) |
1 // Copyright (c) 2016, 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 // Tests of reading and writing to variables. | |
6 | |
7 import 'expect.dart'; | |
8 | |
9 test0() { | |
10 var x0 = 0, x1; | |
11 Expect.isTrue(x0 == 0); | |
12 Expect.isTrue(x1 == null); | |
13 x0 = 1; | |
14 Expect.isTrue(x0 == 1); | |
15 Expect.isTrue((x0 = 2) == 2); | |
16 Expect.isTrue(x0 == 2); | |
17 } | |
18 | |
19 var x2 = 0, x3; | |
20 | |
21 test1() { | |
22 Expect.isTrue(x2 == 0); | |
23 Expect.isTrue(x3 == null); | |
24 x2 = 1; | |
25 Expect.isTrue(x2 == 1); | |
26 Expect.isTrue((x2 = 2) == 2); | |
27 Expect.isTrue(x2 == 2); | |
28 } | |
29 | |
30 class C { | |
31 static var x4 = 0; | |
32 static var x5; | |
33 } | |
34 | |
35 test3() { | |
36 Expect.isTrue(C.x4 == 0); | |
37 Expect.isTrue(C.x5 == null); | |
38 C.x4 = 1; | |
39 Expect.isTrue(C.x4 == 1); | |
40 Expect.isTrue((C.x4 = 2) == 2); | |
41 Expect.isTrue(C.x4 == 2); | |
42 } | |
43 | |
44 class D { | |
45 var x6 = 0; | |
46 var x7; | |
47 } | |
48 | |
49 test4() { | |
50 var d = new D(); | |
51 Expect.isTrue(d.x6 == 0); | |
52 Expect.isTrue(d.x7 == null); | |
53 d.x6 = 1; | |
54 Expect.isTrue(d.x6 == 1); | |
55 Expect.isTrue((d.x6 = 2) == 2); | |
56 Expect.isTrue(d.x6 == 2); | |
57 } | |
58 | |
59 main() { | |
60 test0(); | |
61 test1(); | |
62 test3(); | |
63 test4(); | |
64 } | |
OLD | NEW |