| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 var a = things[inscrutable(0)]; | 69 var a = things[inscrutable(0)]; |
| 70 var b = things[inscrutable(1)]; | 70 var b = things[inscrutable(1)]; |
| 71 | 71 |
| 72 Expect.equals(25, a.op(50)); | 72 Expect.equals(25, a.op(50)); |
| 73 Expect.equals(123, b.op('hello')); | 73 Expect.equals(123, b.op('hello')); |
| 74 Expect.equals(666, b.code); | 74 Expect.equals(666, b.code); |
| 75 | 75 |
| 76 bool threw = false; | 76 bool threw = false; |
| 77 try { | 77 try { |
| 78 var x = a.op(51); | 78 var x = a.op(51); |
| 79 } catch (var e) { | 79 } catch (e) { |
| 80 threw = true; | 80 threw = true; |
| 81 Expect.equals(100, e.code); | 81 Expect.equals(100, e.code); |
| 82 Expect.isTrue(e is E); | 82 Expect.isTrue(e is E); |
| 83 } | 83 } |
| 84 Expect.isTrue(threw); | 84 Expect.isTrue(threw); |
| 85 | 85 |
| 86 // Again, but with statically typed receivers. | 86 // Again, but with statically typed receivers. |
| 87 A aa = a; | 87 A aa = a; |
| 88 B bb = b; | 88 B bb = b; |
| 89 | 89 |
| 90 Expect.equals(25, aa.op(50)); | 90 Expect.equals(25, aa.op(50)); |
| 91 Expect.equals(123, bb.op('hello')); | 91 Expect.equals(123, bb.op('hello')); |
| 92 Expect.equals(666, bb.code); | 92 Expect.equals(666, bb.code); |
| 93 | 93 |
| 94 threw = false; | 94 threw = false; |
| 95 try { | 95 try { |
| 96 var x = aa.op(51); | 96 var x = aa.op(51); |
| 97 } catch (E e) { | 97 } on E catch (e) { |
| 98 threw = true; | 98 threw = true; |
| 99 Expect.equals(100, e.code); | 99 Expect.equals(100, e.code); |
| 100 Expect.isTrue(e is E); | 100 Expect.isTrue(e is E); |
| 101 } | 101 } |
| 102 Expect.isTrue(threw); | 102 Expect.isTrue(threw); |
| 103 } | 103 } |
| OLD | NEW |