OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 var global = 0; | 7 var global = 0; |
8 | 8 |
9 effect() { | 9 effect() { |
10 global = 1; | 10 global = 1; |
11 } | 11 } |
12 baz(b) { return b; } | 12 |
| 13 baz(b) { |
| 14 return b; |
| 15 } |
13 | 16 |
14 foo(b) { | 17 foo(b) { |
15 if (b) { | 18 if (b) { |
16 // do nothing | 19 // do nothing |
17 } else { | 20 } else { |
18 effect(); | 21 effect(); |
19 } | 22 } |
20 return baz(b); | 23 return baz(b); |
21 } | 24 } |
22 | 25 |
23 foo2(b) { | 26 foo2(b) { |
24 if (b) { | 27 if (b) { |
25 // do nothing (but implicit return may get inlined up here) | 28 // do nothing (but implicit return may get inlined up here) |
26 } else { | 29 } else { |
27 effect(); | 30 effect(); |
28 } | 31 } |
29 } | 32 } |
30 | 33 |
31 main() { | 34 main() { |
32 global = 0; | 35 global = 0; |
33 Expect.equals(true, foo(true)); | 36 Expect.equals(true, foo(true)); |
34 Expect.equals(0, global); | 37 Expect.equals(0, global); |
35 | 38 |
36 global = 0; | 39 global = 0; |
37 Expect.equals(false, foo(false)); | 40 Expect.equals(false, foo(false)); |
38 Expect.equals(1, global); | 41 Expect.equals(1, global); |
39 | 42 |
40 global = 0; | 43 global = 0; |
41 foo2(true); | 44 foo2(true); |
42 Expect.equals(0, global); | 45 Expect.equals(0, global); |
43 | 46 |
44 global = 0; | 47 global = 0; |
45 foo2(false); | 48 foo2(false); |
46 Expect.equals(1, global); | 49 Expect.equals(1, global); |
47 } | 50 } |
OLD | NEW |