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 // Make sure we can have a native with a name that is a JavaScript keyword. | 5 // Make sure we can have a native with a name that is a JavaScript keyword. |
6 | 6 |
7 import "package:expect/expect.dart"; | |
8 import 'native_metadata.dart'; | 7 import 'native_metadata.dart'; |
9 | 8 |
10 @Native("*A") | 9 @Native("*A") |
11 class A { | 10 class A { |
12 @native int delete(); | 11 @native int delete(); |
13 } | 12 } |
14 | 13 |
15 @native A makeA() { return new A(); } | 14 @native A makeA() { return new A(); } |
16 | 15 |
17 @Native(""" | 16 @Native(""" |
18 function A() {} | 17 function A() {} |
19 A.prototype.delete = function() { return 87; }; | 18 A.prototype.delete = function() { return 87; }; |
20 | 19 |
21 makeA = function(){return new A;}; | 20 makeA = function(){return new A;}; |
22 """) | 21 """) |
23 void setup(); | 22 void setup(); |
24 | 23 |
25 | 24 |
26 main() { | 25 main() { |
27 setup(); | 26 setup(); |
28 | 27 |
29 var a = makeA(); | 28 var a = makeA(); |
30 Expect.equals(87, a.delete()); | 29 Expect.equals(87, a.delete()); |
31 A aa = a; | 30 A aa = a; |
32 Expect.equals(87, aa.delete()); | 31 Expect.equals(87, aa.delete()); |
33 } | 32 } |
OLD | NEW |