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

Side by Side Diff: tests/compiler/dart2js/unparser_test.dart

Issue 10824329: dart2dart properly collect top level fields (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
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) 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:uri'); 5 #import('dart:uri');
6 #import('parser_helper.dart'); 6 #import('parser_helper.dart');
7 #import("../../../lib/compiler/compiler.dart"); 7 #import("../../../lib/compiler/compiler.dart");
8 #import("../../../lib/compiler/implementation/tree/tree.dart"); 8 #import("../../../lib/compiler/implementation/tree/tree.dart");
9 9
10 testUnparse(String statement) { 10 testUnparse(String statement) {
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 } 220 }
221 221
222 testConflictSendsRename() { 222 testConflictSendsRename() {
223 // Various Send-s to current library and external library. Verify that 223 // Various Send-s to current library and external library. Verify that
224 // everything is renamed correctly in conflicting class names and global 224 // everything is renamed correctly in conflicting class names and global
225 // functions. 225 // functions.
226 var librarySrc = ''' 226 var librarySrc = '''
227 #library("mylib.dart"); 227 #library("mylib.dart");
228 228
229 globalfoo() {} 229 globalfoo() {}
230 var globalVar;
Anton Muhin 2012/08/16 11:05:48 just for fun, let's try variable lists, something
Roman 2012/08/16 11:46:09 Done.
231 var globalVarInitialized = 6;
230 232
231 class A { 233 class A {
232 A(){} 234 A(){}
233 A.fromFoo(){} 235 A.fromFoo(){}
234 static staticfoo(){} 236 static staticfoo(){}
235 foo(){} 237 foo(){}
236 static final field = 5; 238 static final field = 5;
237 } 239 }
238 '''; 240 ''';
239 var mainSrc = ''' 241 var mainSrc = '''
240 #import("mylib.dart", prefix: "mylib"); 242 #import("mylib.dart", prefix: "mylib");
241 243
242 globalfoo() {} 244 globalfoo() {}
245 var globalVar;
246 var globalVarInitialized = 6;
243 247
244 class A { 248 class A {
245 A(){} 249 A(){}
246 A.fromFoo(){} 250 A.fromFoo(){}
247 static staticfoo(){} 251 static staticfoo(){}
248 foo(){} 252 foo(){}
249 static final field = 5; 253 static final field = 5;
250 } 254 }
251 255
252 main() { 256 main() {
257 globalVar;
258 globalVarInitialized;
253 globalfoo(); 259 globalfoo();
254 A.field; 260 A.field;
255 A.staticfoo(); 261 A.staticfoo();
256 new A(); 262 new A();
257 new A.fromFoo(); 263 new A.fromFoo();
258 new A().foo(); 264 new A().foo();
259 265
266 mylib.globalVar;
267 mylib.globalVarInitialized;
260 mylib.globalfoo(); 268 mylib.globalfoo();
261 mylib.A.field; 269 mylib.A.field;
262 mylib.A.staticfoo(); 270 mylib.A.staticfoo();
263 new mylib.A(); 271 new mylib.A();
264 new mylib.A.fromFoo(); 272 new mylib.A.fromFoo();
265 new mylib.A().foo(); 273 new mylib.A().foo();
266 } 274 }
267 '''; 275 ''';
268 var expectedResult = 'globalfoo(){}p_globalfoo(){}main(){p_globalfoo(); p_A.fi eld; p_A.staticfoo(); new p_A(); new p_A.fromFoo(); new p_A().foo(); globalfoo() ; A.field; A.staticfoo(); new A(); new A.fromFoo(); new A().foo();}class p_A{p_A (){}p_A.fromFoo(){}foo(){}static staticfoo(){}static final field=5;}class A{A(){ }A.fromFoo(){}foo(){}static staticfoo(){}static final field=5;}'; 276 var expectedResult = 'globalfoo(){}p_globalfoo(){}main(){globalVar; globalVarI nitialized; p_globalfoo(); A.field; A.staticfoo(); new A(); new A.fromFoo(); new A().foo(); p_globalVar; p_globalVarInitialized; globalfoo(); p_A.field; p_A.sta ticfoo(); new p_A(); new p_A.fromFoo(); new p_A().foo();}var globalVar;var p_glo balVar;var globalVarInitialized=6;var p_globalVarInitialized=6;class A{A(){}A.fr omFoo(){}foo(){}static staticfoo(){}static final field=5;}class p_A{p_A(){}p_A.f romFoo(){}foo(){}static staticfoo(){}static final field=5;}';
269 testDart2DartWithLibrary(mainSrc, librarySrc, 277 testDart2DartWithLibrary(mainSrc, librarySrc,
270 (String result) { Expect.equals(expectedResult, result); }); 278 (String result) { Expect.equals(expectedResult, result); });
271 } 279 }
272 280
273 testNoConflictSendsRename() { 281 testNoConflictSendsRename() {
274 // Various Send-s to current library and external library. Nothing should be 282 // Various Send-s to current library and external library. Nothing should be
275 // renamed here, only library prefixes must be cut. 283 // renamed here, only library prefixes must be cut.
276 var librarySrc = ''' 284 var librarySrc = '''
277 #library("mylib.dart"); 285 #library("mylib.dart");
278 286
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 testGetSet(); 415 testGetSet();
408 testFactoryConstructor(); 416 testFactoryConstructor();
409 testAbstractClass(); 417 testAbstractClass();
410 testConflictSendsRename(); 418 testConflictSendsRename();
411 testNoConflictSendsRename(); 419 testNoConflictSendsRename();
412 testConflictLibraryClassRename(); 420 testConflictLibraryClassRename();
413 testDefaultClassWithArgs(); 421 testDefaultClassWithArgs();
414 testClassExtendsWithArgs(); 422 testClassExtendsWithArgs();
415 testStaticInvocation(); 423 testStaticInvocation();
416 } 424 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698