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