OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 abstract class TestException { | 8 abstract class TestException { |
9 String getMessage(); | 9 String getMessage(); |
10 } | 10 } |
11 | 11 |
12 class MyException implements TestException { | 12 class MyException implements TestException { |
13 const MyException([String message = ""]) : message_ = message; | 13 const MyException([String message = ""]) : message_ = message; |
14 String getMessage() { return message_; } | 14 String getMessage() { |
| 15 return message_; |
| 16 } |
| 17 |
15 final String message_; | 18 final String message_; |
16 } | 19 } |
17 | 20 |
18 class MyException2 implements TestException { | 21 class MyException2 implements TestException { |
19 const MyException2([String message = ""]) : message_ = message; | 22 const MyException2([String message = ""]) : message_ = message; |
20 String getMessage() { return message_; } | 23 String getMessage() { |
| 24 return message_; |
| 25 } |
| 26 |
21 final String message_; | 27 final String message_; |
22 } | 28 } |
23 | 29 |
24 class MyException3 implements TestException { | 30 class MyException3 implements TestException { |
25 const MyException3([String message = ""]) : message_ = message; | 31 const MyException3([String message = ""]) : message_ = message; |
26 String getMessage() { return message_; } | 32 String getMessage() { |
| 33 return message_; |
| 34 } |
| 35 |
27 final String message_; | 36 final String message_; |
28 } | 37 } |
29 | 38 |
30 class Helper { | 39 class Helper { |
31 static int f1(int i) { | 40 static int f1(int i) { |
32 try { | 41 try { |
33 int j; | 42 int j; |
34 j = func(); | 43 j = func(); |
35 } on MyException3 catch (exception) { | 44 } on MyException3 catch (exception) { |
36 i = 100; | 45 i = 100; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 | 86 |
78 class Throw2Test { | 87 class Throw2Test { |
79 static testMain() { | 88 static testMain() { |
80 Expect.equals(850, Helper.f1(1)); | 89 Expect.equals(850, Helper.f1(1)); |
81 } | 90 } |
82 } | 91 } |
83 | 92 |
84 main() { | 93 main() { |
85 Throw2Test.testMain(); | 94 Throw2Test.testMain(); |
86 } | 95 } |
OLD | NEW |