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

Unified Diff: tests/language/try_finally_regress_25333_test.dart

Issue 1569523002: Fix VM bug with try-catch inside of try-finally. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: added comment Created 4 years, 11 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/parser.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/try_finally_regress_25333_test.dart
diff --git a/tests/language/try_finally_regress_25333_test.dart b/tests/language/try_finally_regress_25333_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..1feb510d1fc145cfb7f836f448d997d3e4110bb1
--- /dev/null
+++ b/tests/language/try_finally_regress_25333_test.dart
@@ -0,0 +1,65 @@
+// Copyright (c) 2016, 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.
+
+// Test correct handling of try-catch inside try-finally.
+
+import "package:expect/expect.dart";
+
+void main() {
+ print("== test1 ==");
+ bool caught = false;
+ try {
+ test1();
+ print("Unexpected 1"); // should never go here
+ Expect.isTrue(false);
+ } catch (e) {
+ caught = true;
+ print("main catch 1: $e");
+ Expect.equals(e, "Ball");
+ }
+ Expect.isTrue(caught);
+ print("== test2 ==");
+ caught = false;
+ try {
+ test2();
+ print("Unexpected 2"); // should never go here
+ Expect.isTrue(false);
+ } catch (e) {
+ caught = true;
+ print("main catch 2: $e");
+ Expect.equals(e, "Ball");
+ }
+ Expect.isTrue(caught);
+}
+
+void test1() {
+ try {
+ throw "Ball";
+ } finally {
+ try {
+ throw "Frisbee";
+ } catch(e) {
+ print("test 1 catch: $e");
+ Expect.equals(e, "Frisbee");
+ }
+ }
+}
+
+void test2() {
+ try {
+ throwError(); // call a method that throws an error
+ } finally {
+ try {
+ throw "Frisbee";
+ } catch(e) {
+ print("test 2 catch: $e");
+ Expect.equals(e, "Frisbee");
+ }
+ }
+}
+
+
+void throwError() {
+ throw "Ball";
+}
« no previous file with comments | « runtime/vm/parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698