| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 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 | 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 class A native "*A" { | 5 class A native "*A" { |
| 6 bar() => 42; | |
| 7 } | 6 } |
| 8 | 7 |
| 9 class B native "*B" { | 8 class B extends A native "*B" { |
| 10 foo() => 42; | 9 foo() native; |
| 11 } | 10 } |
| 12 | 11 |
| 13 makeA() native; | 12 makeA() native; |
| 13 makeB() native; |
| 14 | 14 |
| 15 setup() native """ | 15 setup() native """ |
| 16 function inherits(child, parent) { |
| 17 if (child.prototype.__proto__) { |
| 18 child.prototype.__proto__ = parent.prototype; |
| 19 } else { |
| 20 function tmp() {}; |
| 21 tmp.prototype = parent.prototype; |
| 22 child.prototype = new tmp(); |
| 23 child.prototype.constructor = child; |
| 24 } |
| 25 } |
| 16 function A() {} | 26 function A() {} |
| 27 function B() {} |
| 28 inherits(B, A); |
| 17 makeA = function() { return new A; } | 29 makeA = function() { return new A; } |
| 30 makeB = function() { return new B; } |
| 31 B.prototype.foo = function() { return 42; } |
| 18 """; | 32 """; |
| 19 | 33 |
| 20 main() { | 34 main() { |
| 21 setup(); | 35 setup(); |
| 22 var a = makeA(); | 36 var a = makeA(); |
| 23 a.bar(); | |
| 24 var exception; | 37 var exception; |
| 25 try { | 38 try { |
| 26 a.foo(); | 39 a.foo(); |
| 27 } catch (NoSuchMethodException e) { | 40 } catch (NoSuchMethodException e) { |
| 28 exception = e; | 41 exception = e; |
| 29 } | 42 } |
| 30 Expect.isNotNull(exception); | 43 Expect.isNotNull(exception); |
| 44 |
| 45 var b = makeB(); |
| 46 Expect.equals(42, b.foo()); |
| 31 } | 47 } |
| OLD | NEW |