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..9811f37f171181069532add2933a3c9748fa6ce6 |
--- /dev/null |
+++ b/tests/language/await_future_test.dart |
@@ -0,0 +1,61 @@ |
+// 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; |
+ } |
+} |
+ |
+quazz() async { |
+ var x = 0; |
+ try { |
+ try { |
+ x = await bar(1); |
+ throw x; |
+ } catch (e1) { |
+ var y = await baz(e1 + 1); |
+ throw y; |
+ } |
+ } catch (e2) { |
+ return e2; |
+ } |
+} |
+ |
+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); |
+ result = await quazz(); |
+ Expect.equals(result, 2); |
+ } |
+} |