| 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 13 matching lines...) Expand all Loading... |
| 24 // Type with exception-throwing methods. | 24 // Type with exception-throwing methods. |
| 25 class A native "*A" { | 25 class A native "*A" { |
| 26 op(int x) native { | 26 op(int x) native { |
| 27 // Fake body calls constructor to mark the exception class (E) as used. | 27 // Fake body calls constructor to mark the exception class (E) as used. |
| 28 throw new E._used(); | 28 throw new E._used(); |
| 29 } | 29 } |
| 30 } | 30 } |
| 31 | 31 |
| 32 // This class is here just so that a dynamic context is polymorphic. | 32 // This class is here just so that a dynamic context is polymorphic. |
| 33 class B { | 33 class B { |
| 34 int get code() => 666; | 34 int get code => 666; |
| 35 op(String x) => 123; | 35 op(String x) => 123; |
| 36 } | 36 } |
| 37 | 37 |
| 38 makeA() native; | 38 makeA() native; |
| 39 | 39 |
| 40 void setup1() native """ | 40 void setup1() native """ |
| 41 // Ensure we are not relying on global names 'A' and 'E'. | 41 // Ensure we are not relying on global names 'A' and 'E'. |
| 42 A = null; | 42 A = null; |
| 43 E = null; | 43 E = null; |
| 44 """; | 44 """; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 } catch (E 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 |