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

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

Issue 10824062: dart2dart (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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 'class IFactory{factory I.fromFoo()=> new A(5);}' 203 'class IFactory{factory I.fromFoo()=> new A(5);}'
204 'interface I default IFactory{I.fromFoo();}' 204 'interface I default IFactory{I.fromFoo();}'
205 'class A implements I{A(this.f);A.fromFoo(foo):this("f");' 205 'class A implements I{A(this.f);A.fromFoo(foo):this("f");'
206 'final String f;}'); 206 'final String f;}');
207 } 207 }
208 208
209 testAbstractClass() { 209 testAbstractClass() {
210 testDart2Dart('main(){A.foo;}abstract class A{final static num foo;}'); 210 testDart2Dart('main(){A.foo;}abstract class A{final static num foo;}');
211 } 211 }
212 212
213 testConflictSendsRename() {
214 // Various Send-s to current library and external library. Verify that
215 // everything is renamed correctly in conflicting class names and global
216 // functions.
217 var librarySrc = '''
218 #library("mylib.dart");
219
220 globalfoo() {}
221
222 class A {
223 A(){}
224 A.fromFoo(){}
225 static staticfoo(){}
226 foo(){}
227 static final field = 5;
228 }
229 ''';
230 var mainSrc = '''
231 #import("mylib.dart", prefix: "mylib");
232
233 globalfoo() {}
234
235 class A {
236 A(){}
237 A.fromFoo(){}
238 static staticfoo(){}
239 foo(){}
240 static final field = 5;
241 }
242
243 main() {
244 globalfoo();
245 A.field;
246 A.staticfoo();
247 new A();
248 new A.fromFoo();
249 new A().foo();
250
251 mylib.globalfoo();
252 mylib.A.field;
253 mylib.A.staticfoo();
254 new mylib.A();
255 new mylib.A.fromFoo();
256 new mylib.A().foo();
257 }
258 ''';
259 var expectedResult = 'globalfoo(){}'
260 '_globalfoo(){}'
261 'main(){_globalfoo(); A.field; A.staticfoo(); new A(); '
262 'new A.fromFoo(); new A().foo(); globalfoo(); _A.field; '
263 '_A.staticfoo(); new _A(); new _A.fromFoo(); new _A().foo();}'
264 'class A{A(){}A.fromFoo(){}foo(){}static staticfoo(){}'
265 'static final field=5;}'
266 'class _A{_A(){}_A.fromFoo(){}foo(){}static staticfoo(){}'
267 'static final field=5;}';
268 testDart2DartWithLibrary(mainSrc, librarySrc,
269 (String result) { Expect.equals(expectedResult, result); });
270 }
271
272 testNoConflictSendsRename() {
273 // Various Send-s to current library and external library. Nothing should be
274 // renamed here, only library prefixes must be cut.
275 var librarySrc = '''
276 #library("mylib.dart");
277
278 globalfoo() {}
279
280 class A {
281 A(){}
282 A.fromFoo(){}
283 static staticfoo(){}
284 foo(){}
285 static final field = 5;
286 }
287 ''';
288 var mainSrc = '''
289 #import("mylib.dart", prefix: "mylib");
290
291 myglobalfoo() {}
292
293 class MyA {
294 MyA(){}
295 MyA.myfromFoo(){}
296 static mystaticfoo(){}
297 myfoo(){}
298 static final myfield = 5;
299 }
300
301 main() {
302 myglobalfoo();
303 MyA.myfield;
304 MyA.mystaticfoo();
305 new MyA();
306 new MyA.myfromFoo();
307 new MyA().myfoo();
308
309 mylib.globalfoo();
310 mylib.A.field;
311 mylib.A.staticfoo();
312 new mylib.A();
313 new mylib.A.fromFoo();
314 new mylib.A().foo();
315 }
316 ''';
317 var expectedResult = 'myglobalfoo(){}'
318 'globalfoo(){}'
319 'main(){myglobalfoo(); MyA.myfield; MyA.mystaticfoo(); new MyA(); '
320 'new MyA.myfromFoo(); new MyA().myfoo(); globalfoo(); A.field; '
321 'A.staticfoo(); new A(); new A.fromFoo(); new A().foo();}'
322 'class MyA{MyA(){}MyA.myfromFoo(){}myfoo(){}'
323 'static final myfield=5;static mystaticfoo(){}}'
324 'class A{A(){}A.fromFoo(){}foo(){}'
325 'static staticfoo(){}static final field=5;}';
326 testDart2DartWithLibrary(mainSrc, librarySrc,
327 (String result) { Expect.equals(expectedResult, result); });
328 }
329
213 testConflictLibraryClassRename() { 330 testConflictLibraryClassRename() {
214 var librarySrc = ''' 331 var librarySrc = '''
215 #library('mylib'); 332 #library('mylib');
216 333
217 topfoo() {} 334 topfoo() {}
218 335
219 class A { 336 class A {
220 foo(){} 337 foo(){}
221 } 338 }
222 '''; 339 ''';
(...skipping 20 matching lines...) Expand all
243 var GREATVAR = b.myliba; 360 var GREATVAR = b.myliba;
244 b.mylist; 361 b.mylist;
245 a = getA(); 362 a = getA();
246 topfoo(); 363 topfoo();
247 mylib.topfoo(); 364 mylib.topfoo();
248 } 365 }
249 '''; 366 ''';
250 var expectedResult = 'topfoo(){}_topfoo(){var x=5;}A getA()=> null;' 367 var expectedResult = 'topfoo(){}_topfoo(){var x=5;}A getA()=> null;'
251 'main(){var a=new A(); a.foo(); var b=new _A.fromFoo(); b.foo(); ' 368 'main(){var a=new A(); a.foo(); var b=new _A.fromFoo(); b.foo(); '
252 'var GREATVAR=b.myliba; b.mylist; a=getA(); _topfoo(); topfoo();}' 369 'var GREATVAR=b.myliba; b.mylist; a=getA(); _topfoo(); topfoo();}'
253 'class _A{_A.fromFoo(){}List<List> mylist;num foo(){}A myliba;}' 370 'class _A{_A.fromFoo(){}List<_A> mylist;num foo(){}A myliba;}'
254 'class A{foo(){}}'; 371 'class A{foo(){}}';
255 testDart2DartWithLibrary(mainSrc, librarySrc, 372 testDart2DartWithLibrary(mainSrc, librarySrc,
256 (String result) { Expect.equals(expectedResult, result); }); 373 (String result) { Expect.equals(expectedResult, result); });
257 } 374 }
258 375
259 main() { 376 main() {
260 testGenericTypes(); 377 testGenericTypes();
261 testForLoop(); 378 testForLoop();
262 testEmptyList(); 379 testEmptyList();
263 testClosure(); 380 testClosure();
264 testIndexedOperatorDecl(); 381 testIndexedOperatorDecl();
265 testNativeMethods(); 382 testNativeMethods();
266 testPrefixIncrements(); 383 testPrefixIncrements();
267 testConstModifier(); 384 testConstModifier();
268 testSimpleFileUnparse(); 385 testSimpleFileUnparse();
269 testSimpleObjectInstantiation(); 386 testSimpleObjectInstantiation();
270 testSimpleTopLevelClass(); 387 testSimpleTopLevelClass();
271 testClassWithSynthesizedConstructor(); 388 testClassWithSynthesizedConstructor();
272 testClassWithMethod(); 389 testClassWithMethod();
273 testVariableDefinitions(); 390 testVariableDefinitions();
274 testGetSet(); 391 testGetSet();
275 testFactoryConstructor(); 392 testFactoryConstructor();
276 testTopLevelField(); 393 testTopLevelField();
277 testAbstractClass(); 394 testAbstractClass();
278 testConflictLibraryClassRename(); 395 testConflictLibraryClassRename();
396 testNoConflictSendsRename();
397 testConflictSendsRename();
279 } 398 }
OLDNEW
« lib/compiler/implementation/resolver.dart ('K') | « lib/compiler/implementation/resolver.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698