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

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

Issue 10894011: Do not emit some unnecessary whitespaces in unparser. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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
« no previous file with comments | « lib/compiler/implementation/tree/unparser.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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('mock_compiler.dart'); 7 #import('mock_compiler.dart');
8 #import("../../../lib/compiler/compiler.dart"); 8 #import("../../../lib/compiler/compiler.dart");
9 #import("../../../lib/compiler/implementation/leg.dart", prefix:'leg'); 9 #import("../../../lib/compiler/implementation/leg.dart", prefix:'leg');
10 #import("../../../lib/compiler/implementation/dart_backend/dart_backend.dart"); 10 #import("../../../lib/compiler/implementation/dart_backend/dart_backend.dart");
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 testForLoop() { 121 testForLoop() {
122 testUnparse('for(;i<100;i++ ){}'); 122 testUnparse('for(;i<100;i++ ){}');
123 testUnparse('for(i=0;i<100;i++ ){}'); 123 testUnparse('for(i=0;i<100;i++ ){}');
124 } 124 }
125 125
126 testEmptyList() { 126 testEmptyList() {
127 testUnparse('var x=[];'); 127 testUnparse('var x=[];');
128 } 128 }
129 129
130 testClosure() { 130 testClosure() {
131 testUnparse('var x=(var x)=> x;'); 131 testUnparse('var x=(var x)=>x;');
132 } 132 }
133 133
134 testIndexedOperatorDecl() { 134 testIndexedOperatorDecl() {
135 testUnparseMember('operator[](int i)=> null;'); 135 testUnparseMember('operator[](int i)=>null;');
136 testUnparseMember('operator[]=(int i,int j)=> null;'); 136 testUnparseMember('operator[]=(int i,int j)=>null;');
137 } 137 }
138 138
139 testNativeMethods() { 139 testNativeMethods() {
140 testUnparseMember('foo()native;'); 140 testUnparseMember('foo()native;');
141 testUnparseMember('foo()native "bar";'); 141 testUnparseMember('foo()native "bar";');
142 testUnparseMember('foo()native "this.x = 41";'); 142 testUnparseMember('foo()native "this.x = 41";');
143 } 143 }
144 144
145 testPrefixIncrements() { 145 testPrefixIncrements() {
146 testUnparse(' ++i;'); 146 testUnparse(' ++i;');
147 testUnparse(' ++a[i];'); 147 testUnparse(' ++a[i];');
148 testUnparse(' ++a[ ++b[i]];'); 148 testUnparse(' ++a[ ++b[i]];');
149 } 149 }
150 150
151 testConstModifier() { 151 testConstModifier() {
152 testUnparse('foo([var a=const []]){}'); 152 testUnparse('foo([var a=const[]]){}');
153 testUnparse('foo([var a=const{}]){}'); 153 testUnparse('foo([var a=const{}]){}');
154 testUnparse('foo(){var a=const []; var b=const{};}'); 154 testUnparse('foo(){var a=const[];var b=const{};}');
155 testUnparse('foo([var a=const [const{"a": const [1,2,3]}]]){}'); 155 testUnparse('foo([var a=const[const{"a":const[1,2,3]}]]){}');
156 } 156 }
157 157
158 testSimpleFileUnparse() { 158 testSimpleFileUnparse() {
159 final src = ''' 159 final src = '''
160 should_be_dropped() { 160 should_be_dropped() {
161 } 161 }
162 162
163 should_be_kept() { 163 should_be_kept() {
164 } 164 }
165 165
(...skipping 16 matching lines...) Expand all
182 182
183 testSimpleTopLevelClass() { 183 testSimpleTopLevelClass() {
184 testDart2Dart('main(){new A();}class A{A(){}}'); 184 testDart2Dart('main(){new A();}class A{A(){}}');
185 } 185 }
186 186
187 testClassWithSynthesizedConstructor() { 187 testClassWithSynthesizedConstructor() {
188 testDart2Dart('main(){new A();}class A{}'); 188 testDart2Dart('main(){new A();}class A{}');
189 } 189 }
190 190
191 testClassWithMethod() { 191 testClassWithMethod() {
192 testDart2Dart('main(){var a=new A(); a.foo();}class A{void foo(){}}'); 192 testDart2Dart('main(){var a=new A();a.foo();}class A{void foo(){}}');
193 } 193 }
194 194
195 testExtendsImplements() { 195 testExtendsImplements() {
196 testDart2Dart('main(){new B<Object>();}' 196 testDart2Dart('main(){new B<Object>();}'
197 'class A<T>{}class B<T> extends A<T>{}'); 197 'class A<T>{}class B<T> extends A<T>{}');
198 } 198 }
199 199
200 testVariableDefinitions() { 200 testVariableDefinitions() {
201 testDart2Dart('main(){final var x,y; final String s;}'); 201 testDart2Dart('main(){final var x,y;final String s;}');
202 testDart2Dart('foo(f,g){}main(){foo(1,2);}'); 202 testDart2Dart('foo(f,g){}main(){foo(1,2);}');
203 testDart2Dart('foo(f(arg)){}main(){foo(main);}'); 203 testDart2Dart('foo(f(arg)){}main(){foo(main);}');
204 // A couple of static/finals inside a class. 204 // A couple of static/finals inside a class.
205 testDart2Dart('main(){A.a; A.b;}class A{static const String a="5";' 205 testDart2Dart('main(){A.a;A.b;}class A{static const String a="5";'
206 'static const String b="4";}'); 206 'static const String b="4";}');
207 // Class member of typedef-ed function type. 207 // Class member of typedef-ed function type.
208 // Maybe typedef should be included in the result too, but it 208 // Maybe typedef should be included in the result too, but it
209 // works fine without it. 209 // works fine without it.
210 testDart2Dart( 210 testDart2Dart(
211 'typedef void foofunc(arg);main(){new A((arg){});}' 211 'typedef void foofunc(arg);main(){new A((arg){});}'
212 'class A{A(foofunc this.handler);final foofunc handler;}'); 212 'class A{A(foofunc this.handler);final foofunc handler;}');
213 } 213 }
214 214
215 testGetSet() { 215 testGetSet() {
216 // Top-level get/set. 216 // Top-level get/set.
217 testDart2Dart('set foo(arg){}get foo{return 5;}main(){foo; foo=5;}'); 217 testDart2Dart('set foo(arg){}get foo{return 5;}main(){foo;foo=5;}');
218 // Field get/set. 218 // Field get/set.
219 testDart2Dart('main(){var a=new A(); a.foo; a.foo=5;}' 219 testDart2Dart('main(){var a=new A();a.foo;a.foo=5;}'
220 'class A{set foo(a){}get foo{return 5;}}'); 220 'class A{set foo(a){}get foo{return 5;}}');
221 // Typed get/set. 221 // Typed get/set.
222 testDart2Dart('String get foo{return "a";}main(){foo;}'); 222 testDart2Dart('String get foo{return "a";}main(){foo;}');
223 } 223 }
224 224
225 testFactoryConstructor() { 225 testFactoryConstructor() {
226 testDart2Dart('main(){new A.fromFoo();}class A{A.fromFoo();}'); 226 testDart2Dart('main(){new A.fromFoo();}class A{A.fromFoo();}');
227 // Now more complicated, with normal constructor and factory parameters. 227 // Now more complicated, with normal constructor and factory parameters.
228 testDart2Dart('main(){new A.fromFoo(5);}' 228 testDart2Dart('main(){new A.fromFoo(5);}'
229 'class A{A(this.f);A.fromFoo(foo):this("f");final String f;}'); 229 'class A{A(this.f);A.fromFoo(foo):this("f");final String f;}');
230 // Now even more complicated, with interface and default factory. 230 // Now even more complicated, with interface and default factory.
231 testDart2Dart('main(){new A.fromFoo(5); new I.fromFoo();}' 231 testDart2Dart('main(){new A.fromFoo(5);new I.fromFoo();}'
232 'class IFactory{factory I.fromFoo()=> new A(5);}' 232 'class IFactory{factory I.fromFoo()=>new A(5);}'
233 'interface I default IFactory{I.fromFoo();}' 233 'interface I default IFactory{I.fromFoo();}'
234 'class A implements I{A(this.f);A.fromFoo(foo):this("f");' 234 'class A implements I{A(this.f);A.fromFoo(foo):this("f");'
235 'final String f;}'); 235 'final String f;}');
236 } 236 }
237 237
238 testAbstractClass() { 238 testAbstractClass() {
239 testDart2Dart('main(){A.foo;}abstract class A{final static num foo;}'); 239 testDart2Dart('main(){A.foo;}abstract class A{final static num foo;}');
240 } 240 }
241 241
242 testConflictSendsRename() { 242 testConflictSendsRename() {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 new mylib.A(); 293 new mylib.A();
294 new mylib.A.fromFoo(); 294 new mylib.A.fromFoo();
295 new mylib.A().foo(); 295 new mylib.A().foo();
296 } 296 }
297 '''; 297 ''';
298 var expectedResult = 298 var expectedResult =
299 'globalfoo(){}var globalVar;var globalVarInitialized=6,globalVarInitialize d2=7;' 299 'globalfoo(){}var globalVar;var globalVarInitialized=6,globalVarInitialize d2=7;'
300 'class A{A(){}A.fromFoo(){}static staticfoo(){}foo(){}static const field=5 ;}' 300 'class A{A(){}A.fromFoo(){}static staticfoo(){}foo(){}static const field=5 ;}'
301 'p_globalfoo(){}var p_globalVar;var p_globalVarInitialized=6,p_globalVarIn itialized2=7;' 301 'p_globalfoo(){}var p_globalVar;var p_globalVarInitialized=6,p_globalVarIn itialized2=7;'
302 'class p_A{p_A(){}p_A.fromFoo(){}static p_staticfoo(){}foo(){}static const p_field=5;}' 302 'class p_A{p_A(){}p_A.fromFoo(){}static p_staticfoo(){}foo(){}static const p_field=5;}'
303 'main(){p_globalVar; p_globalVarInitialized; p_globalVarInitialized2; p_gl obalfoo();' 303 'main(){p_globalVar;p_globalVarInitialized;p_globalVarInitialized2;p_globa lfoo();'
304 ' p_A.p_field; p_A.p_staticfoo();' 304 'p_A.p_field;p_A.p_staticfoo();'
305 ' new p_A(); new p_A.fromFoo(); new p_A().foo();' 305 'new p_A();new p_A.fromFoo();new p_A().foo();'
306 ' globalVar; globalVarInitialized; globalVarInitialized2; globalfoo();' 306 'globalVar;globalVarInitialized;globalVarInitialized2;globalfoo();'
307 ' A.field; A.staticfoo();' 307 'A.field;A.staticfoo();'
308 ' new A(); new A.fromFoo(); new A().foo();}'; 308 'new A();new A.fromFoo();new A().foo();}';
309 testDart2DartWithLibrary(mainSrc, librarySrc, 309 testDart2DartWithLibrary(mainSrc, librarySrc,
310 (String result) { Expect.equals(expectedResult, result); }); 310 (String result) { Expect.equals(expectedResult, result); });
311 } 311 }
312 312
313 testNoConflictSendsRename() { 313 testNoConflictSendsRename() {
314 // Various Send-s to current library and external library. Nothing should be 314 // Various Send-s to current library and external library. Nothing should be
315 // renamed here, only library prefixes must be cut. 315 // renamed here, only library prefixes must be cut.
316 var librarySrc = ''' 316 var librarySrc = '''
317 #library("mylib.dart"); 317 #library("mylib.dart");
318 318
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 new mylib.A(); 353 new mylib.A();
354 new mylib.A.fromFoo(); 354 new mylib.A.fromFoo();
355 new mylib.A().foo(); 355 new mylib.A().foo();
356 } 356 }
357 '''; 357 ''';
358 var expectedResult = 358 var expectedResult =
359 'globalfoo(){}' 359 'globalfoo(){}'
360 'class A{A(){}A.fromFoo(){}static staticfoo(){}foo(){}static const field=5 ;}' 360 'class A{A(){}A.fromFoo(){}static staticfoo(){}foo(){}static const field=5 ;}'
361 'myglobalfoo(){}' 361 'myglobalfoo(){}'
362 'class MyA{MyA(){}MyA.myfromFoo(){}static mystaticfoo(){}myfoo(){}static c onst myfield=5;}' 362 'class MyA{MyA(){}MyA.myfromFoo(){}static mystaticfoo(){}myfoo(){}static c onst myfield=5;}'
363 'main(){myglobalfoo(); MyA.myfield; MyA.mystaticfoo(); new MyA();' 363 'main(){myglobalfoo();MyA.myfield;MyA.mystaticfoo();new MyA();'
364 ' new MyA.myfromFoo(); new MyA().myfoo(); globalfoo(); A.field;' 364 'new MyA.myfromFoo();new MyA().myfoo();globalfoo();A.field;'
365 ' A.staticfoo(); new A(); new A.fromFoo(); new A().foo();}'; 365 'A.staticfoo();new A();new A.fromFoo();new A().foo();}';
366 testDart2DartWithLibrary(mainSrc, librarySrc, 366 testDart2DartWithLibrary(mainSrc, librarySrc,
367 (String result) { Expect.equals(expectedResult, result); }); 367 (String result) { Expect.equals(expectedResult, result); });
368 } 368 }
369 369
370 testConflictLibraryClassRename() { 370 testConflictLibraryClassRename() {
371 var librarySrc = ''' 371 var librarySrc = '''
372 #library('mylib'); 372 #library('mylib');
373 373
374 topfoo() {} 374 topfoo() {}
375 375
(...skipping 26 matching lines...) Expand all
402 a = getA(); 402 a = getA();
403 topfoo(); 403 topfoo();
404 mylib.topfoo(); 404 mylib.topfoo();
405 } 405 }
406 '''; 406 ''';
407 var expectedResult = 407 var expectedResult =
408 'topfoo(){}' 408 'topfoo(){}'
409 'class A{foo(){}}' 409 'class A{foo(){}}'
410 'p_topfoo(){var x=5;}' 410 'p_topfoo(){var x=5;}'
411 'class p_A{num foo(){}p_A.fromFoo(){}A myliba;List<p_A> mylist;}' 411 'class p_A{num foo(){}p_A.fromFoo(){}A myliba;List<p_A> mylist;}'
412 'A getA()=> null;' 412 'A getA()=>null;'
413 'main(){var a=new A(); a.foo(); var b=new p_A.fromFoo(); b.foo(); var GREATV AR=b.myliba; b.mylist; a=getA(); p_topfoo(); topfoo();}'; 413 'main(){var a=new A();a.foo();var b=new p_A.fromFoo();b.foo();var GREATVAR=b .myliba;b.mylist;a=getA();p_topfoo();topfoo();}';
414 testDart2DartWithLibrary(mainSrc, librarySrc, 414 testDart2DartWithLibrary(mainSrc, librarySrc,
415 (String result) { Expect.equals(expectedResult, result); }); 415 (String result) { Expect.equals(expectedResult, result); });
416 } 416 }
417 417
418 testDefaultClassWithArgs() { 418 testDefaultClassWithArgs() {
419 testDart2Dart('main(){var result=new IA<String>();}' 419 testDart2Dart('main(){var result=new IA<String>();}'
420 'interface IA<T> default A<T extends Object>{IA();}' 420 'interface IA<T> default A<T extends Object>{IA();}'
421 'class A<T extends Object> implements IA<T>{factory A(){}}'); 421 'class A<T extends Object> implements IA<T>{factory A(){}}');
422 } 422 }
423 423
(...skipping 22 matching lines...) Expand all
446 446
447 main() { 447 main() {
448 topgetset; 448 topgetset;
449 topgetset = 6; 449 topgetset = 6;
450 450
451 mylib.topgetset; 451 mylib.topgetset;
452 mylib.topgetset = 5; 452 mylib.topgetset = 5;
453 } 453 }
454 '''; 454 ''';
455 var expectedResult = 455 var expectedResult =
456 'get topgetset=> 5;' 456 'get topgetset=>5;'
457 'set topgetset(arg){}' 457 'set topgetset(arg){}'
458 'get p_topgetset=> 6;' 458 'get p_topgetset=>6;'
459 'set p_topgetset(arg){}' 459 'set p_topgetset(arg){}'
460 'main(){p_topgetset; p_topgetset=6; topgetset; topgetset=5;}'; 460 'main(){p_topgetset;p_topgetset=6;topgetset;topgetset=5;}';
461 testDart2DartWithLibrary(mainSrc, librarySrc, 461 testDart2DartWithLibrary(mainSrc, librarySrc,
462 (String result) { Expect.equals(expectedResult, result); }); 462 (String result) { Expect.equals(expectedResult, result); });
463 } 463 }
464 464
465 testFieldTypeOutput() { 465 testFieldTypeOutput() {
466 testDart2Dart('main(){new A().field;}class B{}class A{B field;}'); 466 testDart2Dart('main(){new A().field;}class B{}class A{B field;}');
467 } 467 }
468 468
469 testLocalFunctionPlaceholder() { 469 testLocalFunctionPlaceholder() {
470 var src = ''' 470 var src = '''
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 new mylib.A(); 541 new mylib.A();
542 } 542 }
543 '''; 543 ''';
544 var expectedResult = 544 var expectedResult =
545 'interface I default B{I();}' 545 'interface I default B{I();}'
546 'class A implements I{A(){}}' 546 'class A implements I{A(){}}'
547 'class B{factory I(){}}' 547 'class B{factory I(){}}'
548 'interface p_I default p_B{p_I();}' 548 'interface p_I default p_B{p_I();}'
549 'class p_A implements p_I{p_A(){}}' 549 'class p_A implements p_I{p_A(){}}'
550 'class p_B{factory p_I(){}}' 550 'class p_B{factory p_I(){}}'
551 'main(){new p_I(); new p_A(); new I(); new A();}'; 551 'main(){new p_I();new p_A();new I();new A();}';
552 testDart2DartWithLibrary(mainSrc, librarySrc, 552 testDart2DartWithLibrary(mainSrc, librarySrc,
553 (String result) { Expect.equals(expectedResult, result); }); 553 (String result) { Expect.equals(expectedResult, result); });
554 } 554 }
555 555
556 testTypeVariablesAreRenamed() { 556 testTypeVariablesAreRenamed() {
557 // Somewhat a hack: we require all the references of the identifier 557 // Somewhat a hack: we require all the references of the identifier
558 // to be renamed in the same way for the whole library. Hence 558 // to be renamed in the same way for the whole library. Hence
559 // if we have a class and type variable with the same name, they 559 // if we have a class and type variable with the same name, they
560 // both should be renamed. 560 // both should be renamed.
561 var librarySrc = ''' 561 var librarySrc = '''
(...skipping 22 matching lines...) Expand all
584 '''; 584 ''';
585 var expectedResult = 585 var expectedResult =
586 'typedef void MyFunction<T extends num>(T arg);' 586 'typedef void MyFunction<T extends num>(T arg);'
587 'class T{}' 587 'class T{}'
588 'class B<T>{}' 588 'class B<T>{}'
589 'class A<T> extends B<T>{T f;}' 589 'class A<T> extends B<T>{T f;}'
590 'typedef void p_MyFunction<p_T extends num>(p_T arg);' 590 'typedef void p_MyFunction<p_T extends num>(p_T arg);'
591 'class p_T{}' 591 'class p_T{}'
592 'class p_B<p_T>{}' 592 'class p_B<p_T>{}'
593 'class p_A<p_T> extends p_B<p_T>{p_T f;}' 593 'class p_A<p_T> extends p_B<p_T>{p_T f;}'
594 'main(){p_MyFunction myf1; MyFunction myf2; new p_A<int>().f; ' 594 'main(){p_MyFunction myf1;MyFunction myf2;new p_A<int>().f;'
595 'new p_T(); new A<int>().f; new T();}'; 595 'new p_T();new A<int>().f;new T();}';
596 testDart2DartWithLibrary(mainSrc, librarySrc, 596 testDart2DartWithLibrary(mainSrc, librarySrc,
597 (String result) { Expect.equals(expectedResult, result); }); 597 (String result) { Expect.equals(expectedResult, result); });
598 } 598 }
599 599
600 testClassTypeArgumentBound() { 600 testClassTypeArgumentBound() {
601 var librarySrc = ''' 601 var librarySrc = '''
602 #library('mylib'); 602 #library('mylib');
603 603
604 interface I {} 604 interface I {}
605 class A<T extends I> {} 605 class A<T extends I> {}
606 606
607 '''; 607 ''';
608 var mainSrc = ''' 608 var mainSrc = '''
609 #import('mylib.dart', prefix: 'mylib'); 609 #import('mylib.dart', prefix: 'mylib');
610 610
611 interface I {} 611 interface I {}
612 class A<T extends I> {} 612 class A<T extends I> {}
613 613
614 main() { 614 main() {
615 new A(); 615 new A();
616 new mylib.A(); 616 new mylib.A();
617 } 617 }
618 '''; 618 ''';
619 var expectedResult = 619 var expectedResult =
620 'interface I{}' 620 'interface I{}'
621 'class A<T extends I>{}' 621 'class A<T extends I>{}'
622 'interface p_I{}' 622 'interface p_I{}'
623 'class p_A<p_T extends p_I>{}' 623 'class p_A<p_T extends p_I>{}'
624 'main(){new p_A(); new A();}'; 624 'main(){new p_A();new A();}';
625 testDart2DartWithLibrary(mainSrc, librarySrc, 625 testDart2DartWithLibrary(mainSrc, librarySrc,
626 (String result) { Expect.equals(expectedResult, result); }); 626 (String result) { Expect.equals(expectedResult, result); });
627 } 627 }
628 628
629 testDoubleMains() { 629 testDoubleMains() {
630 var librarySrc = ''' 630 var librarySrc = '''
631 #library('mylib'); 631 #library('mylib');
632 main() {} 632 main() {}
633 '''; 633 ''';
634 var mainSrc = ''' 634 var mainSrc = '''
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 void foo2(c,d) { 706 void foo2(c,d) {
707 var E = a; 707 var E = a;
708 } 708 }
709 foo2(b, a); 709 foo2(b, a);
710 } 710 }
711 foo1(a, 8); 711 foo1(a, 8);
712 } 712 }
713 '''; 713 ''';
714 var expectedResult = 714 var expectedResult =
715 'main(){' 715 'main(){'
716 'var a=7; ' 716 'var a=7;'
717 'void g(a,f){' 717 'void g(a,f){'
718 'void c(e,b){' 718 'void c(e,b){'
719 'var d=a;' 719 'var d=a;'
720 '} ' 720 '}'
721 'c(f,a);' 721 'c(f,a);'
722 '} ' 722 '}'
723 'g(a,8);' 723 'g(a,8);'
724 '}'; 724 '}';
725 testDart2Dart(src, 725 testDart2Dart(src,
726 (String result) { Expect.equals(expectedResult, result); }, minify: true); 726 (String result) { Expect.equals(expectedResult, result); }, minify: true);
727 } 727 }
728 728
729 testParametersMinified() { 729 testParametersMinified() {
730 var src = ''' 730 var src = '''
731 class A { 731 class A {
732 var a; 732 var a;
733 static foo(arg1) { 733 static foo(arg1) {
734 // Should not rename arg1 to a. 734 // Should not rename arg1 to a.
735 arg1 = 5; 735 arg1 = 5;
736 } 736 }
737 } 737 }
738 738
739 fooglobal(arg,[optionalarg = 7]) { 739 fooglobal(arg,[optionalarg = 7]) {
740 arg = 6; 740 arg = 6;
741 } 741 }
742 742
743 main() { 743 main() {
744 new A().a; 744 new A().a;
745 A.foo(8); 745 A.foo(8);
746 fooglobal(8); 746 fooglobal(8);
747 } 747 }
748 '''; 748 ''';
749 var expectedResult = 749 var expectedResult =
750 'class A{var D;static B(b){b=5;}}' 750 'class A{var D;static B(b){b=5;}}'
751 'C(a,[optionalarg=7]){a=6;}' 751 'C(a,[optionalarg=7]){a=6;}'
752 'main(){new A().D; A.B(8); C(8);}'; 752 'main(){new A().D;A.B(8);C(8);}';
753 testDart2Dart(src, 753 testDart2Dart(src,
754 (String result) { Expect.equals(expectedResult, result); }, minify: true); 754 (String result) { Expect.equals(expectedResult, result); }, minify: true);
755 } 755 }
756 756
757 testTypeVariablesInDifferentLibraries() { 757 testTypeVariablesInDifferentLibraries() {
758 // This is a simplified version of what we have in 758 // This is a simplified version of what we have in
759 // lib/compiler/implementation/util. 759 // lib/compiler/implementation/util.
760 var librarySrc = ''' 760 var librarySrc = '''
761 #library('mylib'); 761 #library('mylib');
762 #import('script.dart'); 762 #import('script.dart');
(...skipping 30 matching lines...) Expand all
793 const String globalconstfield; 793 const String globalconstfield;
794 794
795 void foo(String arg) {} 795 void foo(String arg) {}
796 796
797 main() { 797 main() {
798 String localvar; 798 String localvar;
799 foo("5"); 799 foo("5");
800 } 800 }
801 '''; 801 ''';
802 var expectedResult = 802 var expectedResult =
803 ' foo( arg){}main(){var localvar; foo("5");}'; 803 ' foo( arg){}main(){var localvar;foo("5");}';
804 testDart2Dart(src, 804 testDart2Dart(src,
805 (String result) { Expect.equals(expectedResult, result); }, 805 (String result) { Expect.equals(expectedResult, result); },
806 cutDeclarationTypes: true); 806 cutDeclarationTypes: true);
807 } 807 }
808 808
809 main() { 809 main() {
810 testSignedConstants(); 810 testSignedConstants();
811 testGenericTypes(); 811 testGenericTypes();
812 testForLoop(); 812 testForLoop();
813 testEmptyList(); 813 testEmptyList();
(...skipping 28 matching lines...) Expand all
842 testDoubleMains(); 842 testDoubleMains();
843 testInterfaceDefaultAnotherLib(); 843 testInterfaceDefaultAnotherLib();
844 testStaticAccessIoLib(); 844 testStaticAccessIoLib();
845 testLocalFunctionPlaceholder(); 845 testLocalFunctionPlaceholder();
846 testMinification(); 846 testMinification();
847 testClosureLocalsMinified(); 847 testClosureLocalsMinified();
848 testParametersMinified(); 848 testParametersMinified();
849 testTypeVariablesInDifferentLibraries(); 849 testTypeVariablesInDifferentLibraries();
850 testDeclarationTypePlaceholders(); 850 testDeclarationTypePlaceholders();
851 } 851 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/tree/unparser.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698