OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 --no-background-compilation | 4 // VMOptions=--optimization-counter-threshold=10 --no-background-compilation |
5 | 5 |
6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
7 | 7 |
8 // Test correct dead phi elimination with try catch. | 8 // Test correct dead phi elimination with try catch. |
9 | 9 |
10 List<Object> a = [1,2,3,4,5]; | 10 List<Object> a = [1, 2, 3, 4, 5]; |
11 | 11 |
12 class MyError { } | 12 class MyError {} |
13 | 13 |
14 class M { | 14 class M { |
15 maythrow(i) { | 15 maythrow(i) { |
16 try { | 16 try { |
17 if (i <= 5) throw new MyError(); | 17 if (i <= 5) throw new MyError(); |
18 } catch(e) { throw e; } | 18 } catch (e) { |
| 19 throw e; |
| 20 } |
19 } | 21 } |
20 } | 22 } |
21 | 23 |
22 loop_test() { | 24 loop_test() { |
23 bool failed = false; | 25 bool failed = false; |
24 M m = new M(); | 26 M m = new M(); |
25 for (Object i in a) { | 27 for (Object i in a) { |
26 try { | 28 try { |
27 String res = m.maythrow(i); | 29 String res = m.maythrow(i); |
28 failed = true; | 30 failed = true; |
29 } on MyError catch(e) { } | 31 } on MyError catch (e) {} |
30 if (!identical(failed, false)) { | 32 if (!identical(failed, false)) { |
31 Expect.fail(""); | 33 Expect.fail(""); |
32 } | 34 } |
33 } | 35 } |
34 } | 36 } |
35 | 37 |
36 main() { | 38 main() { |
37 for (var i = 0; i < 20; i++) loop_test(); | 39 for (var i = 0; i < 20; i++) loop_test(); |
38 } | 40 } |
39 | |
40 | |
41 | |
OLD | NEW |