Chromium Code Reviews| 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..e5db7eed9f9ea56470c2ca696ff2c3bd713762f6 |
| --- /dev/null |
| +++ b/tests/language/try_finally_regress_25333_test.dart |
| @@ -0,0 +1,59 @@ |
| +// 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 =="); |
| + try { |
| + test1(); |
| + print("Unexpected 1"); // should never go here |
| + Expect.isTrue(false); |
| + } catch (e) { |
| + print("main catch 1: $e"); |
| + Expect.equals(e, "Ball"); |
| + } |
|
Ivan Posva
2016/01/06 16:35:47
Please add some state verifying that the catch cla
Florian Schneider
2016/01/06 16:40:06
Done.
|
| + print("== test2 =="); |
| + try { |
| + test2(); |
| + print("Unexpected 2"); // should never go here |
| + Expect.isTrue(false); |
| + } catch (e) { |
| + print("main catch 2: $e"); |
| + Expect.equals(e, "Ball"); |
| + } |
|
Ivan Posva
2016/01/06 16:35:47
ditto.
Florian Schneider
2016/01/06 16:40:07
Done.
|
| +} |
| + |
| +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"; |
| +} |