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

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

Issue 11419250: Add @JSName annotation for native fields and methods - second try. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 // A native method prevents other members from having that name, including 5 // A native method prevents other members from having that name, including
6 // fields. However, native fields keep their name. The implication: a getter 6 // fields. However, native fields keep their name. The implication: a getter
7 // for the field must be based on the field's name, not the field's jsname. 7 // for the field must be based on the field's name, not the field's jsname.
8 8
9 class A native "*A" { 9 class A native "*A" {
10 int key; // jsname is 'key' 10 int key; // jsname is 'key'
11 int getKey() => key; 11 int getKey() => key;
12 } 12 }
13 13
14 class B { 14 class B {
15 int key; // jsname is not 'key' 15 int key; // jsname is not 'key'
16 B([this.key = 222]); 16 B([this.key = 222]);
17 int getKey() => key; 17 int getKey() => key;
18 } 18 }
19 19
20 class X native "*X" { 20 class X native "*X" {
21 int native_key_method() native 'key'; 21 @JSName('key')
22 int native_key_method() native;
22 // This should cause B.key to be renamed, but not A.key. 23 // This should cause B.key to be renamed, but not A.key.
23 24
24 int key() native 'key'; 25 @JSName('key')
26 int key() native;
25 } 27 }
26 28
27 A makeA() native; 29 A makeA() native;
28 X makeX() native; 30 X makeX() native;
29 31
30 32
31 void setup() native """ 33 void setup() native """
32 // This code is all inside 'setup' and so not accesible from the global scope. 34 // This code is all inside 'setup' and so not accesible from the global scope.
33 function A(){ this.key = 111; } 35 function A(){ this.key = 111; }
34 A.prototype.getKey = function(){return this.key;}; 36 A.prototype.getKey = function(){return this.key;};
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 Expect.equals(111, a.getKey()); 72 Expect.equals(111, a.getKey());
71 Expect.equals(222, b.getKey()); 73 Expect.equals(222, b.getKey());
72 } 74 }
73 75
74 main() { 76 main() {
75 setup(); 77 setup();
76 78
77 testTyped(); 79 testTyped();
78 testDynamic(); 80 testDynamic();
79 } 81 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698