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 "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
6 | 7 |
7 // Test to see if resolving a hidden native class's method interferes with | 8 // Test to see if resolving a hidden native class's method interferes with |
8 // subsequent resolving the subclass's method. This might happen if the | 9 // subsequent resolving the subclass's method. This might happen if the |
9 // superclass caches the method in the prototype, so shadowing the dispatcher | 10 // superclass caches the method in the prototype, so shadowing the dispatcher |
10 // stored on Object.prototype. | 11 // stored on Object.prototype. |
11 | 12 |
12 // Version 1: It might be possible to call foo directly. | 13 // Version 1: It might be possible to call foo directly. |
13 class A1 native "A1" { | 14 @Native("A1") |
| 15 class A1 { |
14 foo() native; | 16 foo() native; |
15 } | 17 } |
16 | 18 |
17 class B1 extends A1 native "B1" { | 19 @Native("B1") |
| 20 class B1 extends A1 { |
18 foo() native; | 21 foo() native; |
19 } | 22 } |
20 | 23 |
21 makeA1() native; | 24 makeA1() native; |
22 makeB1() native; | 25 makeB1() native; |
23 | 26 |
24 | 27 |
25 // Version 2: foo needs some kind of trampoline. | 28 // Version 2: foo needs some kind of trampoline. |
26 class A2 native "A2" { | 29 @Native("A2") |
| 30 class A2 { |
27 foo([a=99]) native; | 31 foo([a=99]) native; |
28 } | 32 } |
29 | 33 |
30 class B2 extends A2 native "B2" { | 34 @Native("B2") |
| 35 class B2 extends A2 { |
31 foo([z=1000]) native; | 36 foo([z=1000]) native; |
32 } | 37 } |
33 | 38 |
34 makeA2() native; | 39 makeA2() native; |
35 makeB2() native; | 40 makeB2() native; |
36 | 41 |
37 void setup() native """ | 42 void setup() native """ |
38 // This code is all inside 'setup' and so not accesible from the global scope. | 43 // This code is all inside 'setup' and so not accesible from the global scope. |
39 function inherits(child, parent) { | 44 function inherits(child, parent) { |
40 if (child.prototype.__proto__) { | 45 if (child.prototype.__proto__) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 caught = false; | 99 caught = false; |
95 try { | 100 try { |
96 var x = 123; | 101 var x = 123; |
97 x.foo(20); | 102 x.foo(20); |
98 } catch (ex) { | 103 } catch (ex) { |
99 caught = true; | 104 caught = true; |
100 Expect.isTrue(ex is NoSuchMethodError); | 105 Expect.isTrue(ex is NoSuchMethodError); |
101 } | 106 } |
102 Expect.isTrue(caught, "x.foo(20) should throw"); | 107 Expect.isTrue(caught, "x.foo(20) should throw"); |
103 } | 108 } |
OLD | NEW |