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

Unified Diff: frog/tests/await/src/TryCatchTest.dart

Issue 9007053: await in frog: partial support for try-catch blocks (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: '' Created 9 years 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 | « frog/tests/await/src/TryCatchNegativeTest.dart ('k') | frog/tests/await/src/await_test_helper.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/tests/await/src/TryCatchTest.dart
diff --git a/frog/tests/await/src/TryCatchTest.dart b/frog/tests/await/src/TryCatchTest.dart
index 5652701d2d89ef9667b7d066b4ffb7692b369e2f..c1908982074a4586275c06649a6039accf88df88 100644
--- a/frog/tests/await/src/TryCatchTest.dart
+++ b/frog/tests/await/src/TryCatchTest.dart
@@ -2,33 +2,46 @@
// 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.
-// Await within a try-catch block:
+// Await within a try-catch block, no error occurs.
#import("await_test_helper.dart");
-main() {
+noerror() {
try {
- final f = futureOf(1);
- final t = await f;
+ final t = await futureOf(0);
return t;
- } catch (Ex1 ex) {
+ } catch (e) {
return -1;
}
}
-// This is roughly equivalent to:
-// main() {
+main() {
+ int t = await noerror();
+ Expect.equals(0, t);
+}
+
+// The transformation is roughly as follows:
+// noerror() {
// final _ret = new Completer();
-// final f = futureOf(1);
-// f.then((t) {
-// _ret.complete(t);
-// });
-// f.addExceptionHandler((ex) {
-// if (ex is Ex1) {
-// _ret.complete(-1);
-// return true;
-// }
-// return false;
-// });
-// Futures.propagateError(f, _ret);
+// _catch(Ex1 ex) {
+// _ret.complete(-1);
+// }
+// try {
+// final f = futureOf(0);
+// f.then((t) {
+// _ret.complete(t);
+// });
+// f.addExceptionHandler((ex) {
+// if (ex is Ex1) {
+// _catch(ex);
+// return true;
+// }
+// return false;
+// });
+// Futures.propagateError(f, _ret);
+// return _ret;
+// } catch(Ex1 ex) {
+// _catch(ex);
+// return _ret;
+// }
// }
« no previous file with comments | « frog/tests/await/src/TryCatchNegativeTest.dart ('k') | frog/tests/await/src/await_test_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698