| 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_testing.dart'; | 5 import 'native_testing.dart'; |
| 6 | 6 |
| 7 typedef void MyFunctionType(); | 7 typedef void MyFunctionType(); |
| 8 | 8 |
| 9 @Native("A") | 9 @Native("A") |
| 10 class A { | 10 class A { |
| 11 setClosure(MyFunctionType f) native; | 11 setClosure(MyFunctionType f) native; |
| 12 check(MyFunctionType f) native; | 12 check(MyFunctionType f) native; |
| 13 invoke() native; | 13 invoke() native; |
| 14 } | 14 } |
| 15 | 15 |
| 16 makeA() native; | 16 makeA() native; |
| 17 | 17 |
| 18 void setup() native """ | 18 void setup() { |
| 19 function A() {} | 19 JS('', r""" |
| 20 A.prototype.setClosure = function(f) { this.f = f; }; | 20 (function(){ |
| 21 A.prototype.check = function(f) { return this.f === f; }; | 21 function A() {} |
| 22 A.prototype.invoke = function() { return this.f(); }; | 22 A.prototype.setClosure = function(f) { this.f = f; }; |
| 23 makeA = function(){return new A;}; | 23 A.prototype.check = function(f) { return this.f === f; }; |
| 24 A.prototype.invoke = function() { return this.f(); }; |
| 25 makeA = function(){return new A()}; |
| 24 | 26 |
| 25 self.nativeConstructor(A); | 27 self.nativeConstructor(A); |
| 26 """; | 28 })()"""); |
| 29 } |
| 27 | 30 |
| 28 var staticClosure; | 31 var staticClosure; |
| 29 staticMethod() => 42; | 32 staticMethod() => 42; |
| 30 | 33 |
| 31 class B { | 34 class B { |
| 32 var instanceClosure; | 35 var instanceClosure; |
| 33 instanceMethod() => 43; | 36 instanceMethod() => 43; |
| 34 } | 37 } |
| 35 | 38 |
| 36 checkUntyped(a, closure) { | 39 checkUntyped(a, closure) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 67 | 70 |
| 68 checkUntyped(makeA(), b.instanceMethod); | 71 checkUntyped(makeA(), b.instanceMethod); |
| 69 checkTyped(makeA(), b.instanceMethod); | 72 checkTyped(makeA(), b.instanceMethod); |
| 70 | 73 |
| 71 checkUntyped(makeA(), closureStatement); | 74 checkUntyped(makeA(), closureStatement); |
| 72 checkTyped(makeA(), closureStatement); | 75 checkTyped(makeA(), closureStatement); |
| 73 | 76 |
| 74 checkUntyped(makeA(), closureExpression); | 77 checkUntyped(makeA(), closureExpression); |
| 75 checkTyped(makeA(), closureExpression); | 78 checkTyped(makeA(), closureExpression); |
| 76 } | 79 } |
| OLD | NEW |