| 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 }; | 151 }; |
| 152 var k = 0; | 152 var k = 0; |
| 153 do { | 153 do { |
| 154 do { | 154 do { |
| 155 k++; | 155 k++; |
| 156 } while (0 < (await decI())); | 156 } while (0 < (await decI())); |
| 157 } while((await decJ()) > 0); | 157 } while((await decJ()) > 0); |
| 158 return k; | 158 return k; |
| 159 } | 159 } |
| 160 | 160 |
| 161 awaitFor() async { |
| 162 var asyncInc = (p) async => p+1; |
| 163 var k = 0; |
| 164 for (int j = (await bar(0)), i = (await bar(1)); |
| 165 j < (await bar(5)); |
| 166 j = (await asyncInc(j)), i = (await asyncInc(i))) { |
| 167 k += i; |
| 168 k += j; |
| 169 } |
| 170 return k; |
| 171 } |
| 172 |
| 173 awaitForIn() async { |
| 174 var list = ['a', 'b', 'c']; |
| 175 var k = ''; |
| 176 for (var c in (await bar(list))) { |
| 177 k += c; |
| 178 } |
| 179 return k; |
| 180 } |
| 181 |
| 161 main() async { | 182 main() async { |
| 162 var result; | 183 var result; |
| 163 for (int i = 0; i < 10; i++) { | 184 for (int i = 0; i < 10; i++) { |
| 164 result = await foo(); | 185 result = await foo(); |
| 165 Expect.equals(30, result); | 186 Expect.equals(30, result); |
| 166 result = await quaz(17); | 187 result = await quaz(17); |
| 167 Expect.equals(17, result); | 188 Expect.equals(17, result); |
| 168 result = await quazz(); | 189 result = await quazz(); |
| 169 Expect.equals(2, result); | 190 Expect.equals(2, result); |
| 170 result = await nesting(); | 191 result = await nesting(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 188 result = await awaitElseIf(4); | 209 result = await awaitElseIf(4); |
| 189 Expect.equals("p<5", result); | 210 Expect.equals("p<5", result); |
| 190 result = await awaitElseIf(5); | 211 result = await awaitElseIf(5); |
| 191 Expect.equals("p==5", result); | 212 Expect.equals("p==5", result); |
| 192 result = await awaitNestedWhile(5,3); | 213 result = await awaitNestedWhile(5,3); |
| 193 Expect.equals(15, result); | 214 Expect.equals(15, result); |
| 194 result = await awaitNestedWhile(4,6); | 215 result = await awaitNestedWhile(4,6); |
| 195 Expect.equals(24, result); | 216 Expect.equals(24, result); |
| 196 result = await awaitAsUnary(bar(1), bar(2)); | 217 result = await awaitAsUnary(bar(1), bar(2)); |
| 197 Expect.equals(3, result); | 218 Expect.equals(3, result); |
| 219 result = await awaitFor(); |
| 220 Expect.equals(25, result); |
| 221 result = await awaitForIn(); |
| 222 Expect.equals('abc', result); |
| 198 } | 223 } |
| 199 } | 224 } |
| OLD | NEW |