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 | 4 |
5 // Test that hidden native exception classes can be marked as existing. | 5 // Test that hidden native exception classes can be marked as existing. |
6 // | 6 // |
7 // To infer which native hidden types exist, we need | 7 // To infer which native hidden types exist, we need |
8 // (1) return types of native methods and getters | 8 // (1) return types of native methods and getters |
9 // (2) argument types of callbacks | 9 // (2) argument types of callbacks |
10 // (3) exceptions thrown by the operation. | 10 // (3) exceptions thrown by the operation. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 var a = things[inscrutable(0)]; | 65 var a = things[inscrutable(0)]; |
66 var b = things[inscrutable(1)]; | 66 var b = things[inscrutable(1)]; |
67 | 67 |
68 Expect.equals(25, a.op(50)); | 68 Expect.equals(25, a.op(50)); |
69 Expect.equals(123, b.op('hello')); | 69 Expect.equals(123, b.op('hello')); |
70 Expect.equals(666, b.code); | 70 Expect.equals(666, b.code); |
71 | 71 |
72 bool threw = false; | 72 bool threw = false; |
73 try { | 73 try { |
74 var x = a.op(51); | 74 var x = a.op(51); |
75 } catch (var e) { | 75 } catch (e) { |
76 threw = true; | 76 threw = true; |
77 Expect.equals(100, e.code); | 77 Expect.equals(100, e.code); |
78 Expect.isTrue(e is E); | 78 Expect.isTrue(e is E); |
79 } | 79 } |
80 Expect.isTrue(threw); | 80 Expect.isTrue(threw); |
81 | 81 |
82 // Again, but with statically typed receivers. | 82 // Again, but with statically typed receivers. |
83 A aa = a; | 83 A aa = a; |
84 B bb = b; | 84 B bb = b; |
85 | 85 |
86 Expect.equals(25, aa.op(50)); | 86 Expect.equals(25, aa.op(50)); |
87 Expect.equals(123, bb.op('hello')); | 87 Expect.equals(123, bb.op('hello')); |
88 Expect.equals(666, bb.code); | 88 Expect.equals(666, bb.code); |
89 | 89 |
90 threw = false; | 90 threw = false; |
91 try { | 91 try { |
92 var x = aa.op(51); | 92 var x = aa.op(51); |
93 } catch (E e) { | 93 } on E catch (e) { |
94 threw = true; | 94 threw = true; |
95 Expect.equals(100, e.code); | 95 Expect.equals(100, e.code); |
96 Expect.isTrue(e is E); | 96 Expect.isTrue(e is E); |
97 } | 97 } |
98 Expect.isTrue(threw); | 98 Expect.isTrue(threw); |
99 } | 99 } |
OLD | NEW |