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 "dart:_js_helper"; | 5 import "dart:_js_helper"; |
6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
7 | 7 |
8 // Additional Dart code may be 'placed on' hidden native classes. With | 8 // Additional Dart code may be 'placed on' hidden native classes. With |
9 // inheritance, the superclass method must not be reached by a call on the | 9 // inheritance, the superclass method must not be reached by a call on the |
10 // subclass. | 10 // subclass. |
(...skipping 11 matching lines...) Expand all Loading... |
22 @Native("B") | 22 @Native("B") |
23 class B extends A { | 23 class B extends A { |
24 var _field2; | 24 var _field2; |
25 | 25 |
26 int get X => _field2; | 26 int get X => _field2; |
27 void set X(int x) { _field2 = x; } | 27 void set X(int x) { _field2 = x; } |
28 | 28 |
29 int method(int z) => _field2 + z; | 29 int method(int z) => _field2 + z; |
30 } | 30 } |
31 | 31 |
32 A makeA() native { return new A(); } | 32 A makeA() native; |
33 B makeB() native { return new B(); } | 33 B makeB() native; |
34 | 34 |
35 void setup() native r""" | 35 void setup() native r""" |
36 function inherits(child, parent) { | 36 function inherits(child, parent) { |
37 if (child.prototype.__proto__) { | 37 if (child.prototype.__proto__) { |
38 child.prototype.__proto__ = parent.prototype; | 38 child.prototype.__proto__ = parent.prototype; |
39 } else { | 39 } else { |
40 function tmp() {}; | 40 function tmp() {}; |
41 tmp.prototype = parent.prototype; | 41 tmp.prototype = parent.prototype; |
42 child.prototype = new tmp(); | 42 child.prototype = new tmp(); |
43 child.prototype.constructor = child; | 43 child.prototype.constructor = child; |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 } | 141 } |
142 | 142 |
143 main() { | 143 main() { |
144 testBasicA_dynamic(); | 144 testBasicA_dynamic(); |
145 testBasicA_typed(); | 145 testBasicA_typed(); |
146 testBasicB_dynamic(); | 146 testBasicB_dynamic(); |
147 testBasicB_typed(); | 147 testBasicB_typed(); |
148 testAB_dynamic(); | 148 testAB_dynamic(); |
149 testAB_typed(); | 149 testAB_typed(); |
150 } | 150 } |
OLD | NEW |