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