| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011, 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 // Await within a loop with a break statement. | |
| 6 | |
| 7 #import("await_test_helper.dart"); | |
| 8 | |
| 9 main() { | |
| 10 var x = 0; | |
| 11 while (x < 3) { | |
| 12 final f = futureOf(1); | |
| 13 final t = await f; | |
| 14 if (x == 2) { | |
| 15 break; | |
| 16 } | |
| 17 x += t; | |
| 18 } | |
| 19 Expect.equals(x, 2); | |
| 20 } | |
| 21 | |
| 22 // This is roughly equivalent to: | |
| 23 // main() { | |
| 24 // final _ret = new Completer(); | |
| 25 // var x = 0; | |
| 26 // _after_loop_1() { | |
| 27 // Expect.equals(x, 2); | |
| 28 // _ret.complete(null); | |
| 29 // } | |
| 30 // _loop_1() { | |
| 31 // while (x < 3) { | |
| 32 // final f = futureOf(1); | |
| 33 // f.then((t) { | |
| 34 // if (x == 2) { | |
| 35 // _after_loop_1(); | |
| 36 // return; | |
| 37 // } | |
| 38 // x += t; | |
| 39 // _loop_1(); | |
| 40 // }); | |
| 41 // Futures.propagateError(f, _ret); | |
| 42 // return; | |
| 43 // } | |
| 44 // _after_loop_1(); | |
| 45 // }(); | |
| 46 // return _ret; | |
| 47 // } | |
| OLD | NEW |