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

Side by Side Diff: tests/compiler/dart2js_native/native_field_invocation5_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) 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 "package:expect/expect.dart"; 6 import "package:expect/expect.dart";
6 7
7 makeCC() native; 8 makeCC() native;
8 nativeFirst(x, y) native; 9 nativeFirst(x, y) native;
9 10
10 void setup() native """ 11 void setup() native """
11 function CC() {} 12 function CC() {}
12 makeCC = function() { return new CC; } 13 makeCC = function() { return new CC; }
13 nativeFirst = function(x, y) { return x; } 14 nativeFirst = function(x, y) { return x; }
14 """; 15 """;
15 16
16 class C { 17 class C {
17 foo(x) => x; 18 foo(x) => x;
18 } 19 }
19 20
20 class ClickCounter native "CC" { 21 @Native("CC")
22 class ClickCounter {
21 var status; 23 var status;
22 24
23 var foo; 25 var foo;
24 26
25 init() { 27 init() {
26 foo = wrap(g); 28 foo = wrap(g);
27 } 29 }
28 30
29 g(val) => "### $val ###"; 31 g(val) => "### $val ###";
30 } 32 }
31 33
32 wrap(cb) { 34 wrap(cb) {
33 return (val) { 35 return (val) {
34 return cb("!!! $val !!!"); 36 return cb("!!! $val !!!");
35 }; 37 };
36 } 38 }
37 39
38 main() { 40 main() {
39 setup(); 41 setup();
40 var c = makeCC(); 42 var c = makeCC();
41 c.init(); 43 c.init();
42 var c2 = new C(); 44 var c2 = new C();
43 c = nativeFirst(c, c2); 45 c = nativeFirst(c, c2);
44 // After the `nativeFirst` invocation dart2js doesn't know if c is a 46 // After the `nativeFirst` invocation dart2js doesn't know if c is a
45 // ClickCounter or C. It must go through the interceptor and call the foo$1 47 // ClickCounter or C. It must go through the interceptor and call the foo$1
46 // invocation. 48 // invocation.
47 Expect.equals("### !!! 499 !!! ###", c.foo(499)); 49 Expect.equals("### !!! 499 !!! ###", c.foo(499));
48 } 50 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698