| 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 Helper { | 13 class Helper { |
| 14 Helper() : i = 0 { } | 14 Helper() : i = 0 {} |
| 15 | 15 |
| 16 int f1() { | 16 int f1() { |
| 17 int j = 0; | 17 int j = 0; |
| 18 try { | 18 try { |
| 19 j = func(); | 19 j = func(); |
| 20 } catch (exception) { | 20 } catch (exception) { |
| 21 i = i + 100; | 21 i = i + 100; |
| 22 print(exception.message_); | 22 print(exception.message_); |
| 23 } finally { | 23 } finally { |
| 24 i = i + 1000; | 24 i = i + 1000; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 36 i++; | 36 i++; |
| 37 } | 37 } |
| 38 if (i > 0) { | 38 if (i > 0) { |
| 39 throw new MyException1("Test for MyException1 being thrown"); | 39 throw new MyException1("Test for MyException1 being thrown"); |
| 40 } | 40 } |
| 41 } finally { | 41 } finally { |
| 42 i = 800; | 42 i = 800; |
| 43 } | 43 } |
| 44 return i; | 44 return i; |
| 45 } | 45 } |
| 46 |
| 46 int i; | 47 int i; |
| 47 } | 48 } |
| 48 | 49 |
| 49 class Throw6Test { | 50 class Throw6Test { |
| 50 static testMain() { | 51 static testMain() { |
| 51 Expect.equals(1900, new Helper().f1()); | 52 Expect.equals(1900, new Helper().f1()); |
| 52 } | 53 } |
| 53 } | 54 } |
| 54 | 55 |
| 55 main() { | 56 main() { |
| 56 Throw6Test.testMain(); | 57 Throw6Test.testMain(); |
| 57 } | 58 } |
| OLD | NEW |