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

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

Issue 11293272: Update dart2js_foreign suite as we now validate annotations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 1 month 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 import 'native_metadata.dart';
10
9 interface I { 11 interface I {
10 int key; 12 int key;
11 } 13 }
12 14
13 @native("*A") 15 @Native("*A")
14 class A implements I { 16 class A implements I {
15 int key; // jsname is 'key' 17 int key; // jsname is 'key'
16 int getKey() => key; 18 int getKey() => key;
17 } 19 }
18 20
19 class B implements I { 21 class B implements I {
20 int key; // jsname is not 'key' 22 int key; // jsname is not 'key'
21 B([this.key = 222]); 23 B([this.key = 222]);
22 int getKey() => key; 24 int getKey() => key;
23 } 25 }
24 26
25 @native("*X") 27 @Native("*X")
26 class X { 28 class X {
27 @native('key') int native_key_method(); 29 @Native('key') int native_key_method();
28 // This should cause B.key to be renamed, but not A.key. 30 // This should cause B.key to be renamed, but not A.key.
29 @native('key') int key(); 31 @Native('key') int key();
30 } 32 }
31 33
32 @native A makeA(); 34 @native A makeA();
33 @native X makeX(); 35 @native X makeX();
34 36
35 37
36 @native(""" 38 @Native("""
37 // This code is all inside 'setup' and so not accesible from the global scope. 39 // This code is all inside 'setup' and so not accesible from the global scope.
38 function A(){ this.key = 111; } 40 function A(){ this.key = 111; }
39 A.prototype.getKey = function(){return this.key;}; 41 A.prototype.getKey = function(){return this.key;};
40 42
41 function X(){} 43 function X(){}
42 X.prototype.key = function(){return 666;}; 44 X.prototype.key = function(){return 666;};
43 45
44 makeA = function(){return new A}; 46 makeA = function(){return new A};
45 makeX = function(){return new X}; 47 makeX = function(){return new X};
46 """) 48 """)
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 Expect.equals(222, b.getKey()); 89 Expect.equals(222, b.getKey());
88 } 90 }
89 91
90 main() { 92 main() {
91 setup(); 93 setup();
92 94
93 testTyped(); 95 testTyped();
94 testPartial(); 96 testPartial();
95 testDynamic(); 97 testDynamic();
96 } 98 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698