| 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 "dart:mirrors" show reflect; | 5 import "dart:mirrors" show reflect; |
| 6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
| 7 | 7 |
| 8 class GetName { | 8 class GetName { |
| 9 foo(x, [y]) => "foo"; | 9 foo(x, [y]) => "foo"; |
| 10 baz(x, y, z) => "baz"; | 10 baz(x, y, z) => "baz"; |
| 11 } | 11 } |
| 12 | 12 |
| 13 String getName(im) => reflect(new GetName()).delegate(im); | 13 String getName(im) => reflect(new GetName()).delegate(im); |
| 14 | 14 |
| 15 class A native "*A" { | 15 class A native "A" { |
| 16 bar() => 42; | 16 bar() => 42; |
| 17 noSuchMethod(x) => "native(${getName(x)}:${x.positionalArguments})"; | 17 noSuchMethod(x) => "native(${getName(x)}:${x.positionalArguments})"; |
| 18 } | 18 } |
| 19 | 19 |
| 20 class B native "*B" { | 20 class B native "B" { |
| 21 baz() => 42; | 21 baz() => 42; |
| 22 } | 22 } |
| 23 | 23 |
| 24 class C { | 24 class C { |
| 25 static create() => new C(); | 25 static create() => new C(); |
| 26 noSuchMethod(x) => "${getName(x)}:${x.positionalArguments}"; | 26 noSuchMethod(x) => "${getName(x)}:${x.positionalArguments}"; |
| 27 } | 27 } |
| 28 | 28 |
| 29 makeA() native; | 29 makeA() native; |
| 30 | 30 |
| 31 setup() native """ | 31 setup() native """ |
| 32 function A() {} | 32 function A() {} |
| 33 makeA = function() { return new A; } | 33 makeA = function() { return new A; } |
| 34 """; | 34 """; |
| 35 | 35 |
| 36 main() { | 36 main() { |
| 37 setup(); | 37 setup(); |
| 38 var a = makeA(); | 38 var a = makeA(); |
| 39 a.bar(); | 39 a.bar(); |
| 40 Expect.equals("native(foo:[1, 2])", a.foo(1, 2)); | 40 Expect.equals("native(foo:[1, 2])", a.foo(1, 2)); |
| 41 Expect.equals("native(baz:[3, 4, 5])", a.baz(3, 4, 5)); | 41 Expect.equals("native(baz:[3, 4, 5])", a.baz(3, 4, 5)); |
| 42 var c = C.create(); | 42 var c = C.create(); |
| 43 Expect.equals("foo:[6]", c.foo(6)); | 43 Expect.equals("foo:[6]", c.foo(6)); |
| 44 } | 44 } |
| OLD | NEW |