| 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 'native_testing.dart'; |
| 6 | 6 |
| 7 // Additional Dart code may be 'placed on' hidden native classes. | 7 // Additional Dart code may be 'placed on' hidden native classes. |
| 8 | 8 |
| 9 @Native("A") | 9 @Native("A") |
| 10 class A { | 10 class A { |
| 11 var _field; | 11 var _field; |
| 12 | 12 |
| 13 int get X => _field; | 13 int get X => _field; |
| 14 void set X(int x) { | 14 void set X(int x) { |
| 15 _field = x; | 15 _field = x; |
| 16 } | 16 } |
| 17 | 17 |
| 18 int method(int z) => _field + z; | 18 int method(int z) => _field + z; |
| 19 } | 19 } |
| 20 | 20 |
| 21 A makeA() native; | 21 A makeA() native; |
| 22 | 22 |
| 23 void setup() native """ | 23 void setup() { |
| 24 function A() {} | 24 JS('', r""" |
| 25 makeA = function(){return new A;}; | 25 (function(){ |
| 26 self.nativeConstructor(A); | 26 function A() {} |
| 27 """; | 27 makeA = function(){return new A()}; |
| 28 self.nativeConstructor(A); |
| 29 })()"""); |
| 30 } |
| 28 | 31 |
| 29 main() { | 32 main() { |
| 30 nativeTesting(); | 33 nativeTesting(); |
| 31 setup(); | 34 setup(); |
| 32 | 35 |
| 33 var a = makeA(); | 36 var a = makeA(); |
| 34 | 37 |
| 35 a.X = 100; | 38 a.X = 100; |
| 36 Expect.equals(100, a.X); | 39 Expect.equals(100, a.X); |
| 37 Expect.equals(150, a.method(50)); | 40 Expect.equals(150, a.method(50)); |
| 38 } | 41 } |
| OLD | NEW |