| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 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 | 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 // VMOptions=--enable_async --optimization-counter-threshold=5 | 5 // VMOptions=--enable_async --optimization-counter-threshold=5 |
| 6 | 6 |
| 7 import 'package:expect/expect.dart'; | 7 import 'package:expect/expect.dart'; |
| 8 | 8 |
| 9 import 'dart:async'; | 9 import 'dart:async'; |
| 10 | 10 |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 }; | 147 }; |
| 148 var k = 0; | 148 var k = 0; |
| 149 do { | 149 do { |
| 150 do { | 150 do { |
| 151 k++; | 151 k++; |
| 152 } while (0 < (await decI())); | 152 } while (0 < (await decI())); |
| 153 } while((await decJ()) > 0); | 153 } while((await decJ()) > 0); |
| 154 return k; | 154 return k; |
| 155 } | 155 } |
| 156 | 156 |
| 157 awaitFor() async { |
| 158 var asyncInc = (p) async => p+1; |
| 159 var k = 0; |
| 160 for (int j = (await bar(0)), i = (await bar(1)); |
| 161 j < (await bar(5)); |
| 162 j = (await asyncInc(j)), i = (await asyncInc(i))) { |
| 163 k += i; |
| 164 k += j; |
| 165 } |
| 166 return k; |
| 167 } |
| 168 |
| 169 awaitForIn() async { |
| 170 var list = ['a', 'b', 'c']; |
| 171 var k = ''; |
| 172 for (var c in (await bar(list))) { |
| 173 k += c; |
| 174 } |
| 175 return k; |
| 176 } |
| 177 |
| 157 main() async { | 178 main() async { |
| 158 var result; | 179 var result; |
| 159 for (int i = 0; i < 10; i++) { | 180 for (int i = 0; i < 10; i++) { |
| 160 result = await foo(); | 181 result = await foo(); |
| 161 Expect.equals(30, result); | 182 Expect.equals(30, result); |
| 162 result = await quaz(17); | 183 result = await quaz(17); |
| 163 Expect.equals(17, result); | 184 Expect.equals(17, result); |
| 164 result = await quazz(); | 185 result = await quazz(); |
| 165 Expect.equals(2, result); | 186 Expect.equals(2, result); |
| 166 result = await nesting(); | 187 result = await nesting(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 182 result = await awaitElseIf(6); | 203 result = await awaitElseIf(6); |
| 183 Expect.equals("p>5", result); | 204 Expect.equals("p>5", result); |
| 184 result = await awaitElseIf(4); | 205 result = await awaitElseIf(4); |
| 185 Expect.equals("p<5", result); | 206 Expect.equals("p<5", result); |
| 186 result = await awaitElseIf(5); | 207 result = await awaitElseIf(5); |
| 187 Expect.equals("p==5", result); | 208 Expect.equals("p==5", result); |
| 188 result = await awaitNestedWhile(5,3); | 209 result = await awaitNestedWhile(5,3); |
| 189 Expect.equals(15, result); | 210 Expect.equals(15, result); |
| 190 result = await awaitNestedWhile(4,6); | 211 result = await awaitNestedWhile(4,6); |
| 191 Expect.equals(24, result); | 212 Expect.equals(24, result); |
| 213 result = await awaitFor(); |
| 214 Expect.equals(25, result); |
| 215 result = await awaitForIn(); |
| 216 Expect.equals('abc', result); |
| 192 } | 217 } |
| 193 } | 218 } |
| OLD | NEW |