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