| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 import "package:expect/expect.dart"; |
| 6 |
| 7 var baz_clicks = 0; |
| 8 |
| 9 baz() { |
| 10 return ++baz_clicks; |
| 11 } |
| 12 |
| 13 var global = 0; |
| 14 |
| 15 increment_global() { |
| 16 ++global; |
| 17 return global <= 10; |
| 18 } |
| 19 |
| 20 foo(x, y) { |
| 21 var n = 0; |
| 22 while (true) { |
| 23 baz(); |
| 24 if (n >= x) { |
| 25 return n; |
| 26 } |
| 27 baz(); |
| 28 if (n >= y) { |
| 29 return n; |
| 30 } |
| 31 n = n + 1; |
| 32 } |
| 33 } |
| 34 |
| 35 bar() { |
| 36 while (increment_global()) { |
| 37 baz(); |
| 38 } |
| 39 return baz(); |
| 40 } |
| 41 |
| 42 main() { |
| 43 Expect.equals(10, foo(10, 20)); |
| 44 Expect.equals(10, foo(20, 10)); |
| 45 |
| 46 baz_clicks = 0; |
| 47 Expect.equals(11, bar()); |
| 48 } |
| OLD | NEW |