| 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=--optimization-counter-threshold=5 | 5 // VMOptions=--optimization-counter-threshold=5 |
| 6 | 6 |
| 7 import 'package:expect/expect.dart'; | 7 import 'package:expect/expect.dart'; |
| 8 import "package:async_helper/async_helper.dart"; |
| 8 | 9 |
| 9 import 'dart:async'; | 10 import 'dart:async'; |
| 10 | 11 |
| 11 // It does not matter where a future is generated. | 12 // It does not matter where a future is generated. |
| 12 bar(p) async => p; | 13 bar(p) async => p; |
| 13 baz(p) => new Future(() => p); | 14 baz(p) => new Future(() => p); |
| 14 | 15 |
| 15 foo() async { | 16 foo() async { |
| 16 var b = 0; | 17 var b = 0; |
| 17 for(int i = 0; i < 10; i++) { | 18 for(int i = 0; i < 10; i++) { |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 | 175 |
| 175 awaitForIn() async { | 176 awaitForIn() async { |
| 176 var list = ['a', 'b', 'c']; | 177 var list = ['a', 'b', 'c']; |
| 177 var k = ''; | 178 var k = ''; |
| 178 for (var c in (await bar(list))) { | 179 for (var c in (await bar(list))) { |
| 179 k += c; | 180 k += c; |
| 180 } | 181 } |
| 181 return k; | 182 return k; |
| 182 } | 183 } |
| 183 | 184 |
| 184 main() async { | 185 test() async { |
| 185 var result; | 186 var result; |
| 186 for (int i = 0; i < 10; i++) { | 187 for (int i = 0; i < 10; i++) { |
| 187 result = await foo(); | 188 result = await foo(); |
| 188 Expect.equals(30, result); | 189 Expect.equals(30, result); |
| 189 result = await faa(); | 190 result = await faa(); |
| 190 Expect.equals(3, result); | 191 Expect.equals(3, result); |
| 191 result = await quaz(17); | 192 result = await quaz(17); |
| 192 Expect.equals(17, result); | 193 Expect.equals(17, result); |
| 193 result = await quazz(); | 194 result = await quazz(); |
| 194 Expect.equals(2, result); | 195 Expect.equals(2, result); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 219 result = await awaitNestedWhile(4,6); | 220 result = await awaitNestedWhile(4,6); |
| 220 Expect.equals(24, result); | 221 Expect.equals(24, result); |
| 221 result = await awaitAsUnary(bar(1), bar(2)); | 222 result = await awaitAsUnary(bar(1), bar(2)); |
| 222 Expect.equals(3, result); | 223 Expect.equals(3, result); |
| 223 result = await awaitFor(); | 224 result = await awaitFor(); |
| 224 Expect.equals(25, result); | 225 Expect.equals(25, result); |
| 225 result = await awaitForIn(); | 226 result = await awaitForIn(); |
| 226 Expect.equals('abc', result); | 227 Expect.equals('abc', result); |
| 227 } | 228 } |
| 228 } | 229 } |
| 230 |
| 231 main() { |
| 232 asyncStart(); |
| 233 test().then((_) { |
| 234 asyncEnd(); |
| 235 }); |
| 236 } |
| OLD | NEW |