| 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 "dart:_js_helper"; |
| 6 import "package:expect/expect.dart"; |
| 6 | 7 |
| 7 @Native("NNative") | 8 @Native("NNative") |
| 8 class NNative { | 9 class NNative { |
| 9 var status; | 10 var status; |
| 10 | 11 |
| 11 var f; | 12 var f; |
| 12 | 13 |
| 14 ClickCounter() { |
| 15 f = wrap(g); |
| 16 } |
| 17 |
| 13 g(val) => "### $val ###"; | 18 g(val) => "### $val ###"; |
| 14 } | 19 } |
| 15 | 20 |
| 21 nativeId(x) native ; |
| 22 |
| 23 void setup() native """ |
| 24 nativeId = function(x) { return x; } |
| 25 """; |
| 26 |
| 16 class ClickCounter { | 27 class ClickCounter { |
| 17 var status; | 28 var status; |
| 18 | 29 |
| 19 var f; | 30 var f; |
| 20 | 31 |
| 21 ClickCounter() { | 32 ClickCounter() { |
| 22 f = wrap(g); | 33 f = wrap(g); |
| 23 } | 34 } |
| 24 | 35 |
| 25 g(val) => "### $val ###"; | 36 g(val) => "### $val ###"; |
| 26 } | 37 } |
| 27 | 38 |
| 28 wrap(cb) { | 39 wrap(cb) { |
| 29 return (val) { | 40 return (val) { |
| 30 return cb("!!! $val !!!"); | 41 return cb("!!! $val !!!"); |
| 31 }; | 42 }; |
| 32 } | 43 } |
| 33 | 44 |
| 34 nativeId(x) native ; | |
| 35 | |
| 36 void setup() native """ | |
| 37 nativeId = function(x) { return x; } | |
| 38 """; | |
| 39 | |
| 40 | |
| 41 main() { | 45 main() { |
| 42 setup(); | 46 setup(); |
| 43 // Make sure the ClickCounter class goes through interceptors. | 47 // Make sure the ClickCounter class goes through interceptors. |
| 44 Expect.equals("### !!! 42 !!! ###", nativeId(new ClickCounter()).f(42)); | 48 Expect.equals("### !!! 42 !!! ###", nativeId(new ClickCounter()).f(42)); |
| 45 // We are interested in the direct call, where the type is known. | 49 // We are interested in the direct call, where the type is known. |
| 46 Expect.equals("### !!! 499 !!! ###", new ClickCounter().f(499)); | 50 Expect.equals("### !!! 499 !!! ###", new ClickCounter().f(499)); |
| 47 } | 51 } |
| OLD | NEW |