Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(844)

Unified Diff: tests/language/await_exceptions_test.dart

Issue 542893004: Bubble up exceptions throw async/await. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: addressed comments Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/symbols.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/await_exceptions_test.dart
diff --git a/tests/language/await_exceptions_test.dart b/tests/language/await_exceptions_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..cb3aca3b5d5eb86ef358843dd9ce7a660ba73db9
--- /dev/null
+++ b/tests/language/await_exceptions_test.dart
@@ -0,0 +1,80 @@
+// 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);
+
+test0_1() async {
+ throw 1;
+}
+
+test0() async {
+ try {
+ await test0_1();
+ } catch (e) {
+ Expect.equals(1, e);
+ }
+}
+
+test1_1() async {
+ throw 1;
+}
+
+test1_2() async {
+ try {
+ await test1_1();
+ } catch (e) {
+ throw e+1;
+ }
+}
+
+test1() async {
+ try {
+ await test1_2();
+ } catch (e) {
+ Expect.equals(2, e);
+ }
+}
+
+test2() async {
+ var x;
+ var test2_1 = () async {
+ try {
+ throw 'a';
+ } catch (e) {
+ throw e + 'b';
+ }
+ };
+ try {
+ try {
+ await test2_1();
+ } catch (e) {
+ var y = await bar(e + 'c');
+ throw y;
+ }
+ } catch (e) {
+ x = e + 'd';
+ return '?';
+ } finally {
+ return x;
+ }
+ return '!';
+}
+
+main() async {
+ var result;
+ for (int i = 0; i < 10; i++) {
+ await test0();
+ await test1();
+ result = await test2();
+ Expect.equals('abcd', result);
+ }
+}
« no previous file with comments | « runtime/vm/symbols.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698