OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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:async"; | 5 import "dart:async"; |
6 import "package:async_helper/async_helper.dart"; | 6 import "package:async_helper/async_helper.dart"; |
7 import "native_testing.dart"; | 7 import "native_testing.dart"; |
8 | 8 |
9 typedef void Callback0(); | 9 typedef void Callback0(); |
10 | 10 |
11 @Native("A") | 11 @Native("A") |
12 class A { | 12 class A { |
13 foo(Callback0 f) native ; | 13 foo(Callback0 f) native; |
14 } | 14 } |
15 | 15 |
16 makeA() native ; | 16 makeA() native; |
17 | 17 |
18 void setup() native r""" | 18 void setup() native r""" |
19 function A() {} | 19 function A() {} |
20 A.prototype.foo = function(f) { return f(); }; | 20 A.prototype.foo = function(f) { return f(); }; |
21 makeA = function() { return new A; }; | 21 makeA = function() { return new A; }; |
22 self.nativeConstructor(A); | 22 self.nativeConstructor(A); |
23 """; | 23 """; |
24 | 24 |
25 main() { | 25 main() { |
26 nativeTesting(); | 26 nativeTesting(); |
(...skipping 15 matching lines...) Expand all Loading... |
42 }).whenComplete(asyncEnd); | 42 }).whenComplete(asyncEnd); |
43 | 43 |
44 Expect.equals(499, a.foo(() { | 44 Expect.equals(499, a.foo(() { |
45 events.add("closure to foo"); | 45 events.add("closure to foo"); |
46 return 499; | 46 return 499; |
47 })); | 47 })); |
48 | 48 |
49 events.add("after native call"); | 49 events.add("after native call"); |
50 Expect.listEquals(["closure to foo", "after native call"], events); | 50 Expect.listEquals(["closure to foo", "after native call"], events); |
51 } | 51 } |
OLD | NEW |