| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 // Dart test program for testing throw statement | 4 // Dart test program for testing throw statement |
| 5 | 5 |
| 6 interface TestException { | 6 interface TestException { |
| 7 String getMessage(); | 7 String getMessage(); |
| 8 } | 8 } |
| 9 | 9 |
| 10 class MyException implements TestException { | 10 class MyException implements TestException { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 const MyException3([String message = ""]) : message_ = message; | 23 const MyException3([String message = ""]) : message_ = message; |
| 24 String getMessage() { return message_; } | 24 String getMessage() { return message_; } |
| 25 final String message_; | 25 final String message_; |
| 26 } | 26 } |
| 27 | 27 |
| 28 class Helper { | 28 class Helper { |
| 29 static int f1(int i) { | 29 static int f1(int i) { |
| 30 try { | 30 try { |
| 31 int j; | 31 int j; |
| 32 j = func(); | 32 j = func(); |
| 33 } catch (MyException3 exception) { | 33 } on MyException3 catch (exception) { |
| 34 i = 100; | 34 i = 100; |
| 35 print(exception.getMessage()); | 35 print(exception.getMessage()); |
| 36 } catch (MyException2 exception) { | 36 } on MyException2 catch (exception) { |
| 37 try { | 37 try { |
| 38 i = func2(); | 38 i = func2(); |
| 39 i = 200; | 39 i = 200; |
| 40 } catch (TestException exception) { | 40 } on TestException catch (exception) { |
| 41 i = 50; | 41 i = 50; |
| 42 } | 42 } |
| 43 print(exception.getMessage()); | 43 print(exception.getMessage()); |
| 44 } catch (MyException exception) { | 44 } on MyException catch (exception) { |
| 45 i = func2(); | 45 i = func2(); |
| 46 print(exception.getMessage()); | 46 print(exception.getMessage()); |
| 47 } finally { | 47 } finally { |
| 48 i = i + 800; | 48 i = i + 800; |
| 49 } | 49 } |
| 50 return i; | 50 return i; |
| 51 } | 51 } |
| 52 | 52 |
| 53 static int func() { | 53 static int func() { |
| 54 int i = 0; | 54 int i = 0; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 75 | 75 |
| 76 class Throw2Test { | 76 class Throw2Test { |
| 77 static testMain() { | 77 static testMain() { |
| 78 Expect.equals(850, Helper.f1(1)); | 78 Expect.equals(850, Helper.f1(1)); |
| 79 } | 79 } |
| 80 } | 80 } |
| 81 | 81 |
| 82 main() { | 82 main() { |
| 83 Throw2Test.testMain(); | 83 Throw2Test.testMain(); |
| 84 } | 84 } |
| OLD | NEW |