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 MyException { | 8 class MyException { |
9 const MyException([String message = ""]) : message_ = message; | 9 const MyException([String message = ""]) : message_ = message; |
10 final String message_; | 10 final String message_; |
(...skipping 19 matching lines...) Expand all Loading... |
30 try { | 30 try { |
31 int i = 0; | 31 int i = 0; |
32 while (i < 10) { | 32 while (i < 10) { |
33 i++; | 33 i++; |
34 } | 34 } |
35 if (i > 0) { | 35 if (i > 0) { |
36 throw new MyException("Test for exception being thrown"); | 36 throw new MyException("Test for exception being thrown"); |
37 } | 37 } |
38 } on MyException catch (ex) { | 38 } on MyException catch (ex) { |
39 print(ex.message_); | 39 print(ex.message_); |
40 rethrow; // Rethrow the exception. | 40 rethrow; // Rethrow the exception. |
41 } | 41 } |
42 return 10; | 42 return 10; |
43 } | 43 } |
44 } | 44 } |
45 | 45 |
46 class Throw3Test { | 46 class Throw3Test { |
47 static testMain() { | 47 static testMain() { |
48 Expect.equals(850, Helper.f1(1)); | 48 Expect.equals(850, Helper.f1(1)); |
49 } | 49 } |
50 } | 50 } |
51 | 51 |
52 main() { | 52 main() { |
53 Throw3Test.testMain(); | 53 Throw3Test.testMain(); |
54 } | 54 } |
OLD | NEW |