| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2015, 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 import "package:async_helper/async_helper.dart"; | |
| 7 | |
| 8 // Two loop variables | |
| 9 test1() async { | |
| 10 var r = 0; | |
| 11 label: | |
| 12 for (var i = 1, | |
| 13 j = | |
| 14 await //# await_in_init: ok | |
| 15 10; | |
| 16 i < 10 && | |
| 17 j > | |
| 18 await //# await_in_condition: ok | |
| 19 -5; | |
| 20 j--, | |
| 21 i += | |
| 22 await //# await_in_update: ok | |
| 23 1) { | |
| 24 if (i < | |
| 25 await //# await_in_body: ok | |
| 26 5 || | |
| 27 j < -5) { | |
| 28 continue label; | |
| 29 } | |
| 30 r++; | |
| 31 } | |
| 32 Expect.equals(5, r); | |
| 33 } | |
| 34 | |
| 35 // One loop variable | |
| 36 test2() async { | |
| 37 var r = 0; | |
| 38 label: | |
| 39 for (var i = | |
| 40 await //# await_in_init: ok | |
| 41 0; | |
| 42 i < | |
| 43 await //# await_in_condition: ok | |
| 44 10; | |
| 45 i += | |
| 46 await //# await_in_update: ok | |
| 47 1) { | |
| 48 if (i < | |
| 49 await //# await_in_body: ok | |
| 50 5) { | |
| 51 continue label; | |
| 52 } | |
| 53 r++; | |
| 54 } | |
| 55 Expect.equals(5, r); | |
| 56 } | |
| 57 | |
| 58 // Variable not declared in initializer; | |
| 59 test3() async { | |
| 60 var r = 0, i, j; | |
| 61 label: | |
| 62 for (i = | |
| 63 await //# await_in_init: ok | |
| 64 0; | |
| 65 i < | |
| 66 await //# await_in_condition: ok | |
| 67 10; | |
| 68 i += | |
| 69 await //# await_in_update: ok | |
| 70 1) { | |
| 71 if (i < | |
| 72 await //# await_in_body: ok | |
| 73 5) { | |
| 74 continue label; | |
| 75 } | |
| 76 r++; | |
| 77 } | |
| 78 Expect.equals(5, r); | |
| 79 } | |
| 80 | |
| 81 // Nested loop | |
| 82 test4() async { | |
| 83 var r = 0; | |
| 84 label: | |
| 85 for (var i = | |
| 86 await //# await_in_init: ok | |
| 87 0; | |
| 88 i < | |
| 89 await //# await_in_condition: ok | |
| 90 10; | |
| 91 i += | |
| 92 await //# await_in_update: ok | |
| 93 1) { | |
| 94 if (i < | |
| 95 await //# await_in_body: ok | |
| 96 5) { | |
| 97 for (int i = 0; i < 10; i++) { | |
| 98 continue label; | |
| 99 } | |
| 100 } | |
| 101 r++; | |
| 102 } | |
| 103 Expect.equals(5, r); | |
| 104 } | |
| 105 | |
| 106 test() async { | |
| 107 await test1(); | |
| 108 await test2(); | |
| 109 await test3(); | |
| 110 await test4(); | |
| 111 } | |
| 112 | |
| 113 main() { | |
| 114 asyncStart(); | |
| 115 test().then((_) => asyncEnd()); | |
| 116 } | |
| OLD | NEW |