Index: tests/language/await_future_test.dart |
diff --git a/tests/language/await_future_test.dart b/tests/language/await_future_test.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c9fd32f9853659b7bfa9c1c687ee41998fa08b39 |
--- /dev/null |
+++ b/tests/language/await_future_test.dart |
@@ -0,0 +1,44 @@ |
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
+// for details. All rights reserved. Use of this source code is governed by a |
+// BSD-style license that can be found in the LICENSE file. |
+ |
+// VMOptions=--enable_async --optimization-counter-threshold=5 |
+ |
+import 'package:expect/expect.dart'; |
+ |
+import 'dart:async'; |
+ |
+// It does not matter where a future is generated. |
+bar(p) async => p; |
+baz(p) => new Future(() => p); |
+ |
+foo() async { |
+ var b = 0; |
+ for(int i = 0; i < 10; i++) { |
+ b += (await bar(1)) + (await baz(2)); |
+ } |
+ return b; |
+} |
+ |
+quaz(p) async { |
+ var x = 0; |
+ try { |
+ for (var j = 0; j < 10; j++) { |
+ x += await baz(j); |
+ } |
+ return x; |
+ } finally { |
+ Expect.equals(x, 45); |
+ return p; |
+ } |
+} |
+ |
+main() async { |
+ var result; |
+ for (int i = 0; i < 10; i++) { |
+ result = await foo(); |
+ Expect.equals(result, 30); |
+ } |
+ result = await quaz(17); |
+ Expect.equals(result, 17); |
+} |