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