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