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 import "native_testing.dart"; | 5 import "native_testing.dart"; |
6 | 6 |
7 @Native("A") | 7 @Native("A") |
8 class A {} | 8 class A {} |
9 | 9 |
10 @Native("B") | 10 @Native("B") |
11 class B extends A { | 11 class B extends A { |
12 foo() native ; | 12 foo() native; |
13 } | 13 } |
14 | 14 |
15 makeA() native ; | 15 makeA() native; |
16 makeB() native ; | 16 makeB() native; |
17 | 17 |
18 setup() native """ | 18 setup() native """ |
19 function inherits(child, parent) { | 19 function inherits(child, parent) { |
20 if (child.prototype.__proto__) { | 20 if (child.prototype.__proto__) { |
21 child.prototype.__proto__ = parent.prototype; | 21 child.prototype.__proto__ = parent.prototype; |
22 } else { | 22 } else { |
23 function tmp() {}; | 23 function tmp() {}; |
24 tmp.prototype = parent.prototype; | 24 tmp.prototype = parent.prototype; |
25 child.prototype = new tmp(); | 25 child.prototype = new tmp(); |
26 child.prototype.constructor = child; | 26 child.prototype.constructor = child; |
(...skipping 18 matching lines...) Expand all Loading... |
45 try { | 45 try { |
46 a.foo(); | 46 a.foo(); |
47 } on NoSuchMethodError catch (e) { | 47 } on NoSuchMethodError catch (e) { |
48 exception = e; | 48 exception = e; |
49 } | 49 } |
50 Expect.isNotNull(exception); | 50 Expect.isNotNull(exception); |
51 | 51 |
52 var b = makeB(); | 52 var b = makeB(); |
53 Expect.equals(42, b.foo()); | 53 Expect.equals(42, b.foo()); |
54 } | 54 } |
OLD | NEW |