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 "native_testing.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. |
(...skipping 13 matching lines...) Expand all Loading... |
24 | 24 |
25 @Native("D") | 25 @Native("D") |
26 class D extends C {} | 26 class D extends C {} |
27 | 27 |
28 makeA() native; | 28 makeA() native; |
29 makeB() native; | 29 makeB() native; |
30 makeC() native; | 30 makeC() native; |
31 makeD() native; | 31 makeD() native; |
32 | 32 |
33 void setup() native """ | 33 void setup() native """ |
34 // This code is all inside 'setup' and so not accesible from the global scope. | 34 // This code is all inside 'setup' and so not accessible from the global scope. |
35 function inherits(child, parent) { | 35 function inherits(child, parent) { |
36 if (child.prototype.__proto__) { | 36 if (child.prototype.__proto__) { |
37 child.prototype.__proto__ = parent.prototype; | 37 child.prototype.__proto__ = parent.prototype; |
38 } else { | 38 } else { |
39 function tmp() {}; | 39 function tmp() {}; |
40 tmp.prototype = parent.prototype; | 40 tmp.prototype = parent.prototype; |
41 child.prototype = new tmp(); | 41 child.prototype = new tmp(); |
42 child.prototype.constructor = child; | 42 child.prototype.constructor = child; |
43 } | 43 } |
44 } | 44 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 Expect.equals('C.foo(300)', d.foo()); | 78 Expect.equals('C.foo(300)', d.foo()); |
79 // If the above line fails with C.foo(100) then the dispatch to fill in the | 79 // 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 | 80 // default got the wrong one, followed by a second dispatch that resolved to |
81 // the correct native method. | 81 // the correct native method. |
82 | 82 |
83 Expect.equals('A.foo(1)', a.foo(1)); | 83 Expect.equals('A.foo(1)', a.foo(1)); |
84 Expect.equals('A.foo(2)', b.foo(2)); | 84 Expect.equals('A.foo(2)', b.foo(2)); |
85 Expect.equals('C.foo(3)', c.foo(3)); | 85 Expect.equals('C.foo(3)', c.foo(3)); |
86 Expect.equals('C.foo(4)', d.foo(4)); | 86 Expect.equals('C.foo(4)', d.foo(4)); |
87 } | 87 } |
OLD | NEW |