| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
| 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. | |
| 4 | |
| 5 // Test that we put native names and not Dart names into the dynamic | |
| 6 // dispatch table. | |
| 7 | |
| 8 class A native "*NativeA" { | |
| 9 foo() native; | |
| 10 } | |
| 11 | |
| 12 class B extends A native "*NativeB" { | |
| 13 } | |
| 14 | |
| 15 A makeA() native { return new A(); } | |
| 16 B makeB() native { return new B(); } | |
| 17 | |
| 18 void setup() native """ | |
| 19 function inherits(child, parent) { | |
| 20 if (child.prototype.__proto__) { | |
| 21 child.prototype.__proto__ = parent.prototype; | |
| 22 } else { | |
| 23 function tmp() {}; | |
| 24 tmp.prototype = parent.prototype; | |
| 25 child.prototype = new tmp(); | |
| 26 child.prototype.constructor = child; | |
| 27 } | |
| 28 } | |
| 29 function NativeA() {} | |
| 30 function NativeB() {} | |
| 31 inherits(NativeB, NativeA); | |
| 32 NativeA.prototype.foo = function() { return 42; }; | |
| 33 | |
| 34 makeA = function(){return new NativeA;}; | |
| 35 makeB = function(){return new NativeB;}; | |
| 36 """; | |
| 37 | |
| 38 | |
| 39 main() { | |
| 40 setup(); | |
| 41 | |
| 42 var a = makeA(); | |
| 43 Expect.equals(42, a.foo()); | |
| 44 A aa = a; | |
| 45 Expect.equals(42, aa.foo()); | |
| 46 | |
| 47 var b = makeB(); | |
| 48 Expect.equals(42, b.foo()); | |
| 49 B bb = b; | |
| 50 Expect.equals(42, bb.foo()); | |
| 51 } | |
| OLD | NEW |