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