| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 // Test correct handling of try-catch inside try-finally. | 5 // Test correct handling of try-catch inside try-finally. |
| 6 | 6 |
| 7 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
| 8 | 8 |
| 9 void main() { | 9 void main() { |
| 10 print("== test1 =="); | 10 print("== test1 =="); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 } | 32 } |
| 33 Expect.isTrue(caught); | 33 Expect.isTrue(caught); |
| 34 } | 34 } |
| 35 | 35 |
| 36 void test1() { | 36 void test1() { |
| 37 try { | 37 try { |
| 38 throw "Ball"; | 38 throw "Ball"; |
| 39 } finally { | 39 } finally { |
| 40 try { | 40 try { |
| 41 throw "Frisbee"; | 41 throw "Frisbee"; |
| 42 } catch(e) { | 42 } catch (e) { |
| 43 print("test 1 catch: $e"); | 43 print("test 1 catch: $e"); |
| 44 Expect.equals(e, "Frisbee"); | 44 Expect.equals(e, "Frisbee"); |
| 45 } | 45 } |
| 46 } | 46 } |
| 47 } | 47 } |
| 48 | 48 |
| 49 void test2() { | 49 void test2() { |
| 50 try { | 50 try { |
| 51 throwError(); // call a method that throws an error | 51 throwError(); // call a method that throws an error |
| 52 } finally { | 52 } finally { |
| 53 try { | 53 try { |
| 54 throw "Frisbee"; | 54 throw "Frisbee"; |
| 55 } catch(e) { | 55 } catch (e) { |
| 56 print("test 2 catch: $e"); | 56 print("test 2 catch: $e"); |
| 57 Expect.equals(e, "Frisbee"); | 57 Expect.equals(e, "Frisbee"); |
| 58 } | 58 } |
| 59 } | 59 } |
| 60 } | 60 } |
| 61 | 61 |
| 62 | |
| 63 void throwError() { | 62 void throwError() { |
| 64 throw "Ball"; | 63 throw "Ball"; |
| 65 } | 64 } |
| OLD | NEW |