| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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:_js_helper"; | 5 import "native_testing.dart"; |
| 6 import "package:expect/expect.dart"; | |
| 7 | 6 |
| 8 makeCC() native ; | 7 makeCC() native ; |
| 9 | 8 |
| 10 void setup() native """ | 9 void setup() native """ |
| 11 function CC() {} | 10 function CC() {} |
| 12 makeCC = function() { return new CC; } | 11 makeCC = function() { return new CC; } |
| 12 self.nativeConstructor(CC); |
| 13 """; | 13 """; |
| 14 | 14 |
| 15 @Native("CC") | 15 @Native("CC") |
| 16 class ClickCounter { | 16 class ClickCounter { |
| 17 var status; | 17 var status; |
| 18 | 18 |
| 19 var foo; | 19 var foo; |
| 20 | 20 |
| 21 init() { | 21 init() { |
| 22 foo = wrap(g); | 22 foo = wrap(g); |
| 23 } | 23 } |
| 24 | 24 |
| 25 g(val) => "### $val ###"; | 25 g(val) => "### $val ###"; |
| 26 } | 26 } |
| 27 | 27 |
| 28 wrap(cb) { | 28 wrap(cb) { |
| 29 return (val) { | 29 return (val) { |
| 30 return cb("!!! $val !!!"); | 30 return cb("!!! $val !!!"); |
| 31 }; | 31 }; |
| 32 } | 32 } |
| 33 | 33 |
| 34 main() { | 34 main() { |
| 35 nativeTesting(); |
| 35 setup(); | 36 setup(); |
| 36 var c = makeCC(); | 37 var c = makeCC(); |
| 37 c.init(); | 38 c.init(); |
| 38 // `foo` contains a closure. Make sure that invoking foo through an | 39 // `foo` contains a closure. Make sure that invoking foo through an |
| 39 // interceptor works. | 40 // interceptor works. |
| 40 Expect.equals("### !!! 499 !!! ###", c.foo(499)); | 41 Expect.equals("### !!! 499 !!! ###", c.foo(499)); |
| 41 } | 42 } |
| OLD | NEW |