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 try/catch statement without any exceptions | 4 // Dart test program for testing try/catch statement without any exceptions |
5 // being thrown. | 5 // being thrown. |
6 // VMOptions=--optimization-counter-threshold=10 | 6 // VMOptions=--optimization-counter-threshold=10 |
7 | 7 |
8 import "package:expect/expect.dart"; | 8 import "package:expect/expect.dart"; |
9 | 9 |
10 abstract class TestException { | 10 abstract class TestException { |
11 String getMessage(); | 11 String getMessage(); |
12 } | 12 } |
13 | 13 |
14 class MyException implements TestException { | 14 class MyException implements TestException { |
15 const MyException([String message = ""]) : this._message = message; | 15 const MyException([String message = ""]) : this._message = message; |
16 String getMessage() { return _message; } | 16 String getMessage() { |
| 17 return _message; |
| 18 } |
| 19 |
17 final String _message; | 20 final String _message; |
18 } | 21 } |
19 | 22 |
20 class MyParameterizedException<U, V> implements TestException { | 23 class MyParameterizedException<U, V> implements TestException { |
21 const MyParameterizedException([String message = ""]) | 24 const MyParameterizedException([String message = ""]) |
22 : this._message = message; | 25 : this._message = message; |
23 String getMessage() { return _message; } | 26 String getMessage() { |
| 27 return _message; |
| 28 } |
| 29 |
24 final String _message; | 30 final String _message; |
25 } | 31 } |
26 | 32 |
27 class StackTrace { | 33 class StackTrace { |
28 StackTrace() { } | 34 StackTrace() {} |
29 printStackTrace(TestException ex) { | 35 printStackTrace(TestException ex) { |
30 print(ex); | 36 print(ex); |
31 } | 37 } |
32 } | 38 } |
33 | 39 |
34 class Helper { | 40 class Helper { |
35 static int test1(int i) { | 41 static int test1(int i) { |
36 try { | 42 try { |
37 int j; | 43 int j; |
38 j = f2(); | 44 j = f2(); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 static testMain() { | 117 static testMain() { |
112 Expect.equals(900, Helper.test1(1)); | 118 Expect.equals(900, Helper.test1(1)); |
113 } | 119 } |
114 } | 120 } |
115 | 121 |
116 main() { | 122 main() { |
117 for (var i = 0; i < 20; i++) { | 123 for (var i = 0; i < 20; i++) { |
118 TryCatchTest.testMain(); | 124 TryCatchTest.testMain(); |
119 } | 125 } |
120 } | 126 } |
OLD | NEW |