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 counter = 0; | 7 var counter = 0; |
8 var global = 0; | 8 var global = 0; |
9 | 9 |
10 test() { | 10 test() { |
11 ++counter; | 11 ++counter; |
12 return counter <= 2; | 12 return counter <= 2; |
13 } | 13 } |
14 | 14 |
15 first() { | 15 first() { |
16 global = global + 1; | 16 global = global + 1; |
17 } | 17 } |
| 18 |
18 second() { | 19 second() { |
19 global = global * 2; | 20 global = global * 2; |
20 } | 21 } |
21 | 22 |
22 foo() { | 23 foo() { |
23 while (test()) { | 24 while (test()) { |
24 first(); | 25 first(); |
25 second(); | 26 second(); |
26 } | 27 } |
27 } | 28 } |
28 | 29 |
29 main() { | 30 main() { |
30 foo(); | 31 foo(); |
31 Expect.equals(6, global); | 32 Expect.equals(6, global); |
32 } | 33 } |
OLD | NEW |