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

Side by Side Diff: dart/tests/compiler/dart2js_foreign/native_field_rename_2_test.dart

Issue 10823423: Change dart2js_foreign suite to use metadata. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 4 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) 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 interface I { 9 interface I {
10 int key; 10 int key;
11 } 11 }
12 12
13 class A implements I native "*A" { 13 @native("*A")
14 class A implements I {
14 int key; // jsname is 'key' 15 int key; // jsname is 'key'
15 int getKey() => key; 16 int getKey() => key;
16 } 17 }
17 18
18 class B implements I { 19 class B implements I {
19 int key; // jsname is not 'key' 20 int key; // jsname is not 'key'
20 B([this.key = 222]); 21 B([this.key = 222]);
21 int getKey() => key; 22 int getKey() => key;
22 } 23 }
23 24
24 class X native "*X" { 25 @native("*X")
25 int native_key_method() native 'key'; 26 class X {
27 @native('key') int native_key_method();
26 // This should cause B.key to be renamed, but not A.key. 28 // This should cause B.key to be renamed, but not A.key.
27 int key() native 'key'; 29 @native('key') int key();
28 } 30 }
29 31
30 A makeA() native; 32 @native A makeA();
31 X makeX() native; 33 @native X makeX();
32 34
33 35
34 void setup() native """ 36 @native("""
35 // This code is all inside 'setup' and so not accesible from the global scope. 37 // This code is all inside 'setup' and so not accesible from the global scope.
36 function A(){ this.key = 111; } 38 function A(){ this.key = 111; }
37 A.prototype.getKey = function(){return this.key;}; 39 A.prototype.getKey = function(){return this.key;};
38 40
39 function X(){} 41 function X(){}
40 X.prototype.key = function(){return 666;}; 42 X.prototype.key = function(){return 666;};
41 43
42 makeA = function(){return new A}; 44 makeA = function(){return new A};
43 makeX = function(){return new X}; 45 makeX = function(){return new X};
44 """; 46 """)
47 void setup();
45 48
46 testDynamic() { 49 testDynamic() {
47 var things = [makeA(), new B(), makeX()]; 50 var things = [makeA(), new B(), makeX()];
48 var a = things[0]; 51 var a = things[0];
49 var b = things[1]; 52 var b = things[1];
50 var x = things[2]; 53 var x = things[2];
51 54
52 Expect.equals(111, a.key); 55 Expect.equals(111, a.key);
53 Expect.equals(222, b.key); 56 Expect.equals(222, b.key);
54 Expect.equals(111, a.getKey()); 57 Expect.equals(111, a.getKey());
(...skipping 29 matching lines...) Expand all
84 Expect.equals(222, b.getKey()); 87 Expect.equals(222, b.getKey());
85 } 88 }
86 89
87 main() { 90 main() {
88 setup(); 91 setup();
89 92
90 testTyped(); 93 testTyped();
91 testPartial(); 94 testPartial();
92 testDynamic(); 95 testDynamic();
93 } 96 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698