Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(124)

Side by Side Diff: tests/compiler/dart2js_native/native_no_such_method_exception5_frog_test.dart

Issue 383413003: Add @Native(...) annotation for native class names. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "dart:_js_helper";
6 import "package:expect/expect.dart"; 7 import "package:expect/expect.dart";
7 8
8 class GetName { 9 class GetName {
9 foo(x, [y]) => "foo"; 10 foo(x, [y]) => "foo";
10 baz(x, y, z) => "baz"; 11 baz(x, y, z) => "baz";
11 } 12 }
12 13
13 String getName(im) => reflect(new GetName()).delegate(im); 14 String getName(im) => reflect(new GetName()).delegate(im);
14 15
15 class A native "A" { 16 @Native("A")
17 class A {
16 bar() => 42; 18 bar() => 42;
17 noSuchMethod(x) => "native(${getName(x)}:${x.positionalArguments})"; 19 noSuchMethod(x) => "native(${getName(x)}:${x.positionalArguments})";
18 } 20 }
19 21
20 class B native "B" { 22 @Native("B")
23 class B {
21 baz() => 42; 24 baz() => 42;
22 } 25 }
23 26
24 class C { 27 class C {
25 static create() => new C(); 28 static create() => new C();
26 noSuchMethod(x) => "${getName(x)}:${x.positionalArguments}"; 29 noSuchMethod(x) => "${getName(x)}:${x.positionalArguments}";
27 } 30 }
28 31
29 makeA() native; 32 makeA() native;
30 33
31 setup() native """ 34 setup() native """
32 function A() {} 35 function A() {}
33 makeA = function() { return new A; } 36 makeA = function() { return new A; }
34 """; 37 """;
35 38
36 main() { 39 main() {
37 setup(); 40 setup();
38 var a = makeA(); 41 var a = makeA();
39 a.bar(); 42 a.bar();
40 Expect.equals("native(foo:[1, 2])", a.foo(1, 2)); 43 Expect.equals("native(foo:[1, 2])", a.foo(1, 2));
41 Expect.equals("native(baz:[3, 4, 5])", a.baz(3, 4, 5)); 44 Expect.equals("native(baz:[3, 4, 5])", a.baz(3, 4, 5));
42 var c = C.create(); 45 var c = C.create();
43 Expect.equals("foo:[6]", c.foo(6)); 46 Expect.equals("foo:[6]", c.foo(6));
44 } 47 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698