| 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 "native_testing.dart"; | 5 import "dart:_js_helper"; |
| 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 @Native("A") | 13 @Native("A") |
| 13 class A { | 14 class A { |
| 14 foo([a = 100]) native ; | 15 foo([a = 100]) native ; |
| 15 } | 16 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 function D(){} | 52 function D(){} |
| 52 inherits(D, C); | 53 inherits(D, C); |
| 53 | 54 |
| 54 A.prototype.foo = function(a){return 'A.foo(' + a + ')';} | 55 A.prototype.foo = function(a){return 'A.foo(' + a + ')';} |
| 55 C.prototype.foo = function(z){return 'C.foo(' + z + ')';} | 56 C.prototype.foo = function(z){return 'C.foo(' + z + ')';} |
| 56 | 57 |
| 57 makeA = function(){return new A}; | 58 makeA = function(){return new A}; |
| 58 makeB = function(){return new B}; | 59 makeB = function(){return new B}; |
| 59 makeC = function(){return new C}; | 60 makeC = function(){return new C}; |
| 60 makeD = function(){return new D}; | 61 makeD = function(){return new D}; |
| 61 | |
| 62 self.nativeConstructor(A); | |
| 63 self.nativeConstructor(B); | |
| 64 self.nativeConstructor(C); | |
| 65 self.nativeConstructor(D); | |
| 66 """; | 62 """; |
| 67 | 63 |
| 68 main() { | 64 main() { |
| 69 nativeTesting(); | |
| 70 setup(); | 65 setup(); |
| 71 | 66 |
| 72 var a = makeA(); | 67 var a = makeA(); |
| 73 var b = makeB(); | 68 var b = makeB(); |
| 74 var c = makeC(); | 69 var c = makeC(); |
| 75 var d = makeD(); | 70 var d = makeD(); |
| 76 | 71 |
| 77 Expect.equals('A.foo(100)', b.foo()); | 72 Expect.equals('A.foo(100)', b.foo()); |
| 78 Expect.equals('C.foo(300)', d.foo()); | 73 Expect.equals('C.foo(300)', d.foo()); |
| 79 // If the above line fails with C.foo(100) then the dispatch to fill in the | 74 // If the above line fails with C.foo(100) then the dispatch to fill in the |
| 80 // default got the wrong one, followed by a second dispatch that resolved to | 75 // default got the wrong one, followed by a second dispatch that resolved to |
| 81 // the correct native method. | 76 // the correct native method. |
| 82 | 77 |
| 83 Expect.equals('A.foo(1)', a.foo(1)); | 78 Expect.equals('A.foo(1)', a.foo(1)); |
| 84 Expect.equals('A.foo(2)', b.foo(2)); | 79 Expect.equals('A.foo(2)', b.foo(2)); |
| 85 Expect.equals('C.foo(3)', c.foo(3)); | 80 Expect.equals('C.foo(3)', c.foo(3)); |
| 86 Expect.equals('C.foo(4)', d.foo(4)); | 81 Expect.equals('C.foo(4)', d.foo(4)); |
| 87 } | 82 } |
| OLD | NEW |