OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 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 | 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 // Tests of block scoping. | 5 // Tests of block scoping. |
6 | 6 |
7 import 'package:expect/expect.dart'; | 7 import 'package:expect/expect.dart'; |
8 | 8 |
9 bool oracle() => true; | 9 bool oracle() => true; |
10 | 10 |
11 test0() { | 11 test0() { |
12 var x = 'outer', y = x; | 12 var x = 'outer', y = x; |
13 Expect.isTrue(x == 'outer'); | 13 Expect.isTrue(x == 'outer'); |
14 Expect.isTrue(y == 'outer'); | 14 Expect.isTrue(y == 'outer'); |
15 { var x = 'inner'; | 15 { |
| 16 var x = 'inner'; |
16 Expect.isTrue(x == 'inner'); | 17 Expect.isTrue(x == 'inner'); |
17 Expect.isTrue(y == 'outer'); | 18 Expect.isTrue(y == 'outer'); |
18 } | 19 } |
19 Expect.isTrue(x == 'outer'); | 20 Expect.isTrue(x == 'outer'); |
20 Expect.isTrue(y == 'outer'); | 21 Expect.isTrue(y == 'outer'); |
21 | 22 |
22 if (oracle()) { | 23 if (oracle()) { |
23 var y = 'inner'; | 24 var y = 'inner'; |
24 Expect.isTrue(x == 'outer'); | 25 Expect.isTrue(x == 'outer'); |
25 Expect.isTrue(y == 'inner'); | 26 Expect.isTrue(y == 'inner'); |
26 } else { | 27 } else { |
27 Expect.isTrue(false); | 28 Expect.isTrue(false); |
28 } | 29 } |
29 Expect.isTrue(x == 'outer'); | 30 Expect.isTrue(x == 'outer'); |
30 Expect.isTrue(y == 'outer'); | 31 Expect.isTrue(y == 'outer'); |
31 } | 32 } |
32 | 33 |
33 var x = 'toplevel'; | 34 var x = 'toplevel'; |
34 | 35 |
35 test1() { | 36 test1() { |
36 var y = 'outer'; | 37 var y = 'outer'; |
37 Expect.isTrue(x == 'toplevel'); | 38 Expect.isTrue(x == 'toplevel'); |
38 Expect.isTrue(y == 'outer'); | 39 Expect.isTrue(y == 'outer'); |
39 { var x = 'inner'; | 40 { |
| 41 var x = 'inner'; |
40 Expect.isTrue(x == 'inner'); | 42 Expect.isTrue(x == 'inner'); |
41 Expect.isTrue(y == 'outer'); | 43 Expect.isTrue(y == 'outer'); |
42 } | 44 } |
43 Expect.isTrue(x == 'toplevel'); | 45 Expect.isTrue(x == 'toplevel'); |
44 Expect.isTrue(y == 'outer'); | 46 Expect.isTrue(y == 'outer'); |
45 | 47 |
46 if (oracle()) { | 48 if (oracle()) { |
47 var y = 'inner'; | 49 var y = 'inner'; |
48 Expect.isTrue(x == 'toplevel'); | 50 Expect.isTrue(x == 'toplevel'); |
49 Expect.isTrue(y == 'inner'); | 51 Expect.isTrue(y == 'inner'); |
50 } else { | 52 } else { |
51 Expect.isTrue(false); | 53 Expect.isTrue(false); |
52 } | 54 } |
53 Expect.isTrue(x == 'toplevel'); | 55 Expect.isTrue(x == 'toplevel'); |
54 Expect.isTrue(y == 'outer'); | 56 Expect.isTrue(y == 'outer'); |
55 } | 57 } |
56 | 58 |
57 main() { | 59 main() { |
58 test0(); | 60 test0(); |
59 test1(); | 61 test1(); |
60 } | 62 } |
OLD | NEW |