| 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 class A native "*A" { | 12 class A native "A" { |
| 13 foo([a=100]) native; | 13 foo([a=100]) native; |
| 14 } | 14 } |
| 15 | 15 |
| 16 class B extends A native "*B" { | 16 class B extends A native "B" { |
| 17 } | 17 } |
| 18 | 18 |
| 19 class C extends B native "*C" { | 19 class C extends B native "C" { |
| 20 foo([z=300]) native; | 20 foo([z=300]) native; |
| 21 } | 21 } |
| 22 | 22 |
| 23 class D extends C native "*D" { | 23 class D extends C native "D" { |
| 24 } | 24 } |
| 25 | 25 |
| 26 makeA() native; | 26 makeA() native; |
| 27 makeB() native; | 27 makeB() native; |
| 28 makeC() native; | 28 makeC() native; |
| 29 makeD() native; | 29 makeD() native; |
| 30 | 30 |
| 31 void setup() native """ | 31 void setup() native """ |
| 32 // This code is all inside 'setup' and so not accesible from the global scope. | 32 // This code is all inside 'setup' and so not accesible from the global scope. |
| 33 function inherits(child, parent) { | 33 function inherits(child, parent) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 Expect.equals('C.foo(300)', d.foo()); | 71 Expect.equals('C.foo(300)', d.foo()); |
| 72 // If the above line fails with C.foo(100) then the dispatch to fill in the | 72 // If the above line fails with C.foo(100) then the dispatch to fill in the |
| 73 // default got the wrong one, followed by a second dispatch that resolved to | 73 // default got the wrong one, followed by a second dispatch that resolved to |
| 74 // the correct native method. | 74 // the correct native method. |
| 75 | 75 |
| 76 Expect.equals('A.foo(1)', a.foo(1)); | 76 Expect.equals('A.foo(1)', a.foo(1)); |
| 77 Expect.equals('A.foo(2)', b.foo(2)); | 77 Expect.equals('A.foo(2)', b.foo(2)); |
| 78 Expect.equals('C.foo(3)', c.foo(3)); | 78 Expect.equals('C.foo(3)', c.foo(3)); |
| 79 Expect.equals('C.foo(4)', d.foo(4)); | 79 Expect.equals('C.foo(4)', d.foo(4)); |
| 80 } | 80 } |
| OLD | NEW |