| 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 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
| 7 | 7 |
| 8 class MyException1 { | 8 class MyException1 { |
| 9 const MyException1([String message = "1"]) : message_ = message; | 9 const MyException1([String message = "1"]) : message_ = message; |
| 10 final String message_; | 10 final String message_; |
| 11 } | 11 } |
| 12 | 12 |
| 13 class MyException2 { | 13 class MyException2 { |
| 14 const MyException2([String message = "2"]) : message_ = message; | 14 const MyException2([String message = "2"]) : message_ = message; |
| 15 final String message_; | 15 final String message_; |
| 16 } | 16 } |
| 17 | 17 |
| 18 class MyException3 { | 18 class MyException3 { |
| 19 const MyException3([String message = "3"]) : message_ = message; | 19 const MyException3([String message = "3"]) : message_ = message; |
| 20 final String message_; | 20 final String message_; |
| 21 } | 21 } |
| 22 | 22 |
| 23 class Helper { | 23 class Helper { |
| 24 Helper() : i = 0 { } | 24 Helper() : i = 0 {} |
| 25 | 25 |
| 26 int f1() { | 26 int f1() { |
| 27 int j = 0; | 27 int j = 0; |
| 28 try { | 28 try { |
| 29 j = func(); | 29 j = func(); |
| 30 } on MyException3 catch (exception) { | 30 } on MyException3 catch (exception) { |
| 31 i = i + 300; | 31 i = i + 300; |
| 32 print(exception.message_); | 32 print(exception.message_); |
| 33 } on MyException2 catch (exception) { | 33 } on MyException2 catch (exception) { |
| 34 i = i + 200; | 34 i = i + 200; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 58 i = 300; | 58 i = 300; |
| 59 print(exception.message_); | 59 print(exception.message_); |
| 60 } on MyException2 catch (exception) { | 60 } on MyException2 catch (exception) { |
| 61 i = 200; | 61 i = 200; |
| 62 print(exception.message_); | 62 print(exception.message_); |
| 63 } finally { | 63 } finally { |
| 64 i = 800; | 64 i = 800; |
| 65 } | 65 } |
| 66 return i; | 66 return i; |
| 67 } | 67 } |
| 68 |
| 68 int i; | 69 int i; |
| 69 } | 70 } |
| 70 | 71 |
| 71 class Throw4Test { | 72 class Throw4Test { |
| 72 static testMain() { | 73 static testMain() { |
| 73 Expect.equals(1900, new Helper().f1()); | 74 Expect.equals(1900, new Helper().f1()); |
| 74 } | 75 } |
| 75 } | 76 } |
| 76 | 77 |
| 77 main() { | 78 main() { |
| 78 Throw4Test.testMain(); | 79 Throw4Test.testMain(); |
| 79 } | 80 } |
| OLD | NEW |