| 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 import "dart:_js_helper"; | 5 import "dart:_js_helper"; |
| 6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
| 7 | 7 |
| 8 // Test that hidden native exception classes can be marked as existing. | 8 // Test that hidden native exception classes can be marked as existing. |
| 9 // | 9 // |
| 10 // To infer which native hidden types exist, we need | 10 // To infer which native hidden types exist, we need |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 @Native("E") | 21 @Native("E") |
| 22 class E { | 22 class E { |
| 23 E._used() native; // Bogus native constructor, called only from fake body. | 23 E._used() native; // Bogus native constructor, called only from fake body. |
| 24 | 24 |
| 25 final int code; | 25 final int code; |
| 26 } | 26 } |
| 27 | 27 |
| 28 // Type with exception-throwing methods. | 28 // Type with exception-throwing methods. |
| 29 @Native("A") | 29 @Native("A") |
| 30 class A { | 30 class A { |
| 31 op(int x) native { | 31 // Exception class E is created. |
| 32 // Fake body calls constructor to mark the exception class (E) as used. | 32 @Creates("E") |
| 33 throw new E._used(); | 33 @Returns('int') |
| 34 } | 34 op(int x) native; |
| 35 } | 35 } |
| 36 | 36 |
| 37 // This class is here just so that a dynamic context is polymorphic. | 37 // This class is here just so that a dynamic context is polymorphic. |
| 38 class B { | 38 class B { |
| 39 int get code => 666; | 39 int get code => 666; |
| 40 op(String x) => 123; | 40 op(String x) => 123; |
| 41 } | 41 } |
| 42 | 42 |
| 43 makeA() native; | 43 makeA() native; |
| 44 | 44 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 threw = false; | 95 threw = false; |
| 96 try { | 96 try { |
| 97 var x = aa.op(51); | 97 var x = aa.op(51); |
| 98 } on E catch (e) { | 98 } on E catch (e) { |
| 99 threw = true; | 99 threw = true; |
| 100 Expect.equals(100, e.code); | 100 Expect.equals(100, e.code); |
| 101 Expect.isTrue(e is E); | 101 Expect.isTrue(e is E); |
| 102 } | 102 } |
| 103 Expect.isTrue(threw); | 103 Expect.isTrue(threw); |
| 104 } | 104 } |
| OLD | NEW |