| 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 import 'native_metadata.dart'; |
| 6 |
| 5 typedef void Callback0(); | 7 typedef void Callback0(); |
| 6 typedef void Callback1(arg1); | 8 typedef void Callback1(arg1); |
| 7 typedef void Callback2(arg1, arg2); | 9 typedef void Callback2(arg1, arg2); |
| 8 | 10 |
| 9 @native("*A") | 11 @Native("*A") |
| 10 class A { | 12 class A { |
| 11 @native("return closure();") | 13 @Native("return closure();") |
| 12 foo0(Callback0 closure); | 14 foo0(Callback0 closure); |
| 13 | 15 |
| 14 @native("return closure(arg1);") | 16 @Native("return closure(arg1);") |
| 15 foo1(Callback1 closure, arg1); | 17 foo1(Callback1 closure, arg1); |
| 16 | 18 |
| 17 @native("return closure(arg1, arg2);") | 19 @Native("return closure(arg1, arg2);") |
| 18 foo2(Callback2 closure, arg1, arg2); | 20 foo2(Callback2 closure, arg1, arg2); |
| 19 | 21 |
| 20 @native("return closure == (void 0) ? 42 : closure();") | 22 @Native("return closure == (void 0) ? 42 : closure();") |
| 21 foo3([Callback0 closure]); | 23 foo3([Callback0 closure]); |
| 22 } | 24 } |
| 23 | 25 |
| 24 @native makeA(); | 26 @native makeA(); |
| 25 | 27 |
| 26 @native(""" | 28 @Native(""" |
| 27 function A() {} | 29 function A() {} |
| 28 makeA = function(){return new A;}; | 30 makeA = function(){return new A;}; |
| 29 """) | 31 """) |
| 30 void setup(); | 32 void setup(); |
| 31 | 33 |
| 32 main() { | 34 main() { |
| 33 setup(); | 35 setup(); |
| 34 var a = makeA(); | 36 var a = makeA(); |
| 35 Expect.equals(42, a.foo0(() => 42)); | 37 Expect.equals(42, a.foo0(() => 42)); |
| 36 Expect.equals(43, a.foo1((arg1) => arg1, 43)); | 38 Expect.equals(43, a.foo1((arg1) => arg1, 43)); |
| 37 Expect.equals(44, a.foo2((arg1, arg2) => arg1 + arg2, 21, 23)); | 39 Expect.equals(44, a.foo2((arg1, arg2) => arg1 + arg2, 21, 23)); |
| 38 Expect.equals(42, a.foo3()); | 40 Expect.equals(42, a.foo3()); |
| 39 Expect.equals(43, a.foo3(() => 43)); | 41 Expect.equals(43, a.foo3(() => 43)); |
| 40 | 42 |
| 41 A aa = a; | 43 A aa = a; |
| 42 Expect.equals(42, aa.foo0(() => 42)); | 44 Expect.equals(42, aa.foo0(() => 42)); |
| 43 Expect.equals(43, aa.foo1((arg1) => arg1, 43)); | 45 Expect.equals(43, aa.foo1((arg1) => arg1, 43)); |
| 44 Expect.equals(44, aa.foo2((arg1, arg2) => arg1 + arg2, 21, 23)); | 46 Expect.equals(44, aa.foo2((arg1, arg2) => arg1 + arg2, 21, 23)); |
| 45 Expect.equals(42, aa.foo3()); | 47 Expect.equals(42, aa.foo3()); |
| 46 Expect.equals(43, aa.foo3(() => 43)); | 48 Expect.equals(43, aa.foo3(() => 43)); |
| 47 } | 49 } |
| OLD | NEW |