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

Unified Diff: tests/compiler/dart2js_extra/async_stacktrace_test.dart

Issue 945783002: Dart2js async-await. Propagate stacktraces from futures. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix status file Created 5 years, 10 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
Index: tests/compiler/dart2js_extra/async_stacktrace_test.dart
diff --git a/tests/compiler/dart2js_extra/async_stacktrace_test.dart b/tests/compiler/dart2js_extra/async_stacktrace_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..7960d04dabe0c46f35791d5f86648b49def94062
--- /dev/null
+++ b/tests/compiler/dart2js_extra/async_stacktrace_test.dart
@@ -0,0 +1,77 @@
+// Copyright (c) 2015, 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.
+
+import "dart:async";
+
+import "package:expect/expect.dart";
+import "package:async_helper/async_helper.dart";
+
+test1() async
+ * /// asyncStar: ok
+ {
+ var savedStackTrace;
+ try {
+ try {
+ throw "Error";
+ } catch (e, st) {
+ savedStackTrace = st;
+ }
+ await new Future.error("Error 2", savedStackTrace);
+ } catch (e, st) {
+ Expect.equals(savedStackTrace.toString(), st.toString());
floitsch 2015/02/20 12:36:05 Make sure this expect is reached. Same for the oth
sigurdm 2015/02/23 12:41:18 Done.
+ }
+}
+
+test2() {
+ var savedStackTrace;
+ foo() async
+ * /// asyncStar: continued
+ {
+ try {
+ // await 3;
+ throw "Error";
+ } catch (e, st) {
+ savedStackTrace = st;
+ }
+ await new Future.error("Error 2", savedStackTrace);
+ }
+ return foo()
+ .toList() /// asyncStar: continued
+ .catchError((e, st) {
+ Expect.equals(savedStackTrace.toString(), st.toString());
+ });
+}
+
+test3() {
+ var savedStackTrace;
+ foo() async
+ * /// asyncStar: continued
+ {
+ try {
+ throw "Error";
+ } catch (e, st) {
+ savedStackTrace = st;
+ rethrow;
+ }
+ }
+ return foo()
+ .toList() /// asyncStar: continued
+ .catchError((e, st) {
+ Expect.equals(savedStackTrace.toString(), st.toString());
+ });
+}
+
+runTests() async {
+ await test1()
+ .toList() /// asyncStar: continued
+ ;
+ await test2()
+ ;
floitsch 2015/02/20 12:36:05 move ";" to previous line. Same for test3.
sigurdm 2015/02/23 12:41:17 Done.
+ await test3()
+ ;
+}
+
+main() {
+ asyncTest(runTests);
+}

Powered by Google App Engine
This is Rietveld 408576698