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 "dart:_js_helper"; |
| 6 import "package:expect/expect.dart"; |
6 | 7 |
7 // Additional Dart code may be 'placed on' hidden native classes. With | 8 // Additional Dart code may be 'placed on' hidden native classes. With |
8 // 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 |
9 // subclass. | 10 // subclass. |
10 | 11 |
11 @Native("A") | 12 @Native("A") |
12 class A { | 13 class A { |
13 var _field; | 14 var _field; |
14 | 15 |
15 int get X => _field; | 16 int get X => _field; |
(...skipping 29 matching lines...) Expand all Loading... |
45 child.prototype = new tmp(); | 46 child.prototype = new tmp(); |
46 child.prototype.constructor = child; | 47 child.prototype.constructor = child; |
47 } | 48 } |
48 } | 49 } |
49 | 50 |
50 function A(){} | 51 function A(){} |
51 function B(){} | 52 function B(){} |
52 inherits(B, A); | 53 inherits(B, A); |
53 makeA = function(){return new A;}; | 54 makeA = function(){return new A;}; |
54 makeB = function(){return new B;}; | 55 makeB = function(){return new B;}; |
55 | |
56 self.nativeConstructor(A); | |
57 self.nativeConstructor(B); | |
58 """; | 56 """; |
59 | 57 |
60 testBasicA_dynamic() { | 58 testBasicA_dynamic() { |
61 setup(); // Fresh constructors. | 59 setup(); // Fresh constructors. |
62 | 60 |
63 var a = [makeA()][0]; | 61 var a = [makeA()][0]; |
64 | 62 |
65 a.X = 100; | 63 a.X = 100; |
66 Expect.equals(100, a._field); | 64 Expect.equals(100, a._field); |
67 Expect.equals(100, a.X); | 65 Expect.equals(100, a.X); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 b._field = 1; | 138 b._field = 1; |
141 b._field2 = 2; | 139 b._field2 = 2; |
142 b.X = 123; | 140 b.X = 123; |
143 Expect.equals(1, b._field); | 141 Expect.equals(1, b._field); |
144 Expect.equals(123, b._field2); | 142 Expect.equals(123, b._field2); |
145 Expect.equals(123, b.X); | 143 Expect.equals(123, b.X); |
146 Expect.equals(200, b.method(77)); | 144 Expect.equals(200, b.method(77)); |
147 } | 145 } |
148 | 146 |
149 main() { | 147 main() { |
150 nativeTesting(); | |
151 testBasicA_dynamic(); | 148 testBasicA_dynamic(); |
152 testBasicA_typed(); | 149 testBasicA_typed(); |
153 testBasicB_dynamic(); | 150 testBasicB_dynamic(); |
154 testBasicB_typed(); | 151 testBasicB_typed(); |
155 testAB_dynamic(); | 152 testAB_dynamic(); |
156 testAB_typed(); | 153 testAB_typed(); |
157 } | 154 } |
OLD | NEW |