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 // VMOptions=--optimization-counter-threshold=10 | 4 // VMOptions=--optimization-counter-threshold=10 |
5 | 5 |
6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
7 | 7 |
8 class MyException { } | 8 class MyException { } |
9 | 9 |
10 class MyException1 extends MyException { } | 10 class MyException1 extends MyException { } |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 try { | 131 try { |
132 throw "up"; | 132 throw "up"; |
133 } on String { | 133 } on String { |
134 e = "s"; | 134 e = "s"; |
135 } on int { | 135 } on int { |
136 e = "i"; | 136 e = "i"; |
137 } | 137 } |
138 Expect.equals("s", e); | 138 Expect.equals("s", e); |
139 } | 139 } |
140 | 140 |
| 141 static void test10() { |
| 142 try { |
| 143 throw "up"; |
| 144 } on String catch (e) { |
| 145 var e = 1; // ok, shadows exception variable. |
| 146 Expect.equals(1, e); |
| 147 } |
| 148 } |
| 149 |
141 static void testMain() { | 150 static void testMain() { |
142 test1(); | 151 test1(); |
143 test2(); | 152 test2(); |
144 test3(); | 153 test3(); |
145 test4(); | 154 test4(); |
146 test5(); | 155 test5(); |
147 test6(); | 156 test6(); |
148 test7(); | 157 test7(); |
149 test8(); | 158 test8(); |
150 test9(); | 159 test9(); |
| 160 test10(); |
151 } | 161 } |
152 } | 162 } |
153 | 163 |
154 main() { | 164 main() { |
155 for (var i = 0; i < 20; i++) { | 165 for (var i = 0; i < 20; i++) { |
156 TryCatchTest.testMain(); | 166 TryCatchTest.testMain(); |
157 } | 167 } |
158 } | 168 } |
OLD | NEW |