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

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

Issue 10831332: Support new getter syntax. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review comments and disable one test. 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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 // Class member of typedef-ed function type. 187 // Class member of typedef-ed function type.
188 // Maybe typedef should be included in the result too, but it 188 // Maybe typedef should be included in the result too, but it
189 // works fine without it. 189 // works fine without it.
190 testDart2Dart( 190 testDart2Dart(
191 'typedef void foofunc(arg);main(){new A((arg){});}' 191 'typedef void foofunc(arg);main(){new A((arg){});}'
192 'class A{A(foofunc this.handler);final foofunc handler;}'); 192 'class A{A(foofunc this.handler);final foofunc handler;}');
193 } 193 }
194 194
195 testGetSet() { 195 testGetSet() {
196 // Top-level get/set. 196 // Top-level get/set.
197 testDart2Dart('set foo(arg){}get foo(){return 5;}main(){foo; foo=5;}'); 197 testDart2Dart('set foo(arg){}get foo{return 5;}main(){foo; foo=5;}');
198 // Field get/set. 198 // Field get/set.
199 testDart2Dart('main(){var a=new A(); a.foo; a.foo=5;}' 199 testDart2Dart('main(){var a=new A(); a.foo; a.foo=5;}'
200 'class A{set foo(a){}get foo(){return 5;}}'); 200 'class A{set foo(a){}get foo{return 5;}}');
201 // Typed get/set. 201 // Typed get/set.
202 testDart2Dart('String get foo(){return "a";}main(){foo;}'); 202 testDart2Dart('String get foo{return "a";}main(){foo;}');
203 } 203 }
204 204
205 testFactoryConstructor() { 205 testFactoryConstructor() {
206 testDart2Dart('main(){new A.fromFoo();}class A{A.fromFoo();}'); 206 testDart2Dart('main(){new A.fromFoo();}class A{A.fromFoo();}');
207 // Now more complicated, with normal constructor and factory parameters. 207 // Now more complicated, with normal constructor and factory parameters.
208 testDart2Dart('main(){new A.fromFoo(5);}' 208 testDart2Dart('main(){new A.fromFoo(5);}'
209 'class A{A(this.f);A.fromFoo(foo):this("f");final String f;}'); 209 'class A{A(this.f);A.fromFoo(foo):this("f");final String f;}');
210 // Now even more complicated, with interface and default factory. 210 // Now even more complicated, with interface and default factory.
211 testDart2Dart('main(){new A.fromFoo(5); new I.fromFoo();}' 211 testDart2Dart('main(){new A.fromFoo(5); new I.fromFoo();}'
212 'class IFactory{factory I.fromFoo()=> new A(5);}' 212 'class IFactory{factory I.fromFoo()=> new A(5);}'
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 } 408 }
409 409
410 testStaticInvocation() { 410 testStaticInvocation() {
411 testDart2Dart('main(){var x=Math.parseDouble("1");}'); 411 testDart2Dart('main(){var x=Math.parseDouble("1");}');
412 } 412 }
413 413
414 testLibraryGetSet() { 414 testLibraryGetSet() {
415 var librarySrc = ''' 415 var librarySrc = '''
416 #library('mylib'); 416 #library('mylib');
417 417
418 get topgetset() => 5; 418 get topgetset => 5;
419 set topgetset(arg) {} 419 set topgetset(arg) {}
420 '''; 420 ''';
421 var mainSrc = ''' 421 var mainSrc = '''
422 #import('mylib.dart', prefix: 'mylib'); 422 #import('mylib.dart', prefix: 'mylib');
423 423
424 get topgetset() => 6; 424 get topgetset() => 6;
425 set topgetset(arg) {} 425 set topgetset(arg) {}
426 426
427 main() { 427 main() {
428 topgetset; 428 topgetset;
429 topgetset = 6; 429 topgetset = 6;
430 430
431 mylib.topgetset; 431 mylib.topgetset;
432 mylib.topgetset = 5; 432 mylib.topgetset = 5;
433 } 433 }
434 '''; 434 ''';
435 var expectedResult = 435 var expectedResult =
436 'get p_topgetset()=> 5;' 436 'get p_topgetset=> 5;'
437 'set p_topgetset(arg){}' 437 'set p_topgetset(arg){}'
438 'get topgetset()=> 6;' 438 'get topgetset=> 6;'
439 'set topgetset(arg){}' 439 'set topgetset(arg){}'
440 'main(){topgetset; topgetset=6; p_topgetset; p_topgetset=5;}'; 440 'main(){topgetset; topgetset=6; p_topgetset; p_topgetset=5;}';
441 testDart2DartWithLibrary(mainSrc, librarySrc, 441 testDart2DartWithLibrary(mainSrc, librarySrc,
442 (String result) { Expect.equals(expectedResult, result); }); 442 (String result) { Expect.equals(expectedResult, result); });
443 } 443 }
444 444
445 testFieldTypeOutput() { 445 testFieldTypeOutput() {
446 testDart2Dart('main(){new A().field;}class B{}class A{B field;}'); 446 testDart2Dart('main(){new A().field;}class B{}class A{B field;}');
447 } 447 }
448 448
(...skipping 17 matching lines...) Expand all
466 testVariableDefinitions(); 466 testVariableDefinitions();
467 testGetSet(); 467 testGetSet();
468 testFactoryConstructor(); 468 testFactoryConstructor();
469 testAbstractClass(); 469 testAbstractClass();
470 //testConflictSendsRename(); 470 //testConflictSendsRename();
471 testNoConflictSendsRename(); 471 testNoConflictSendsRename();
472 testConflictLibraryClassRename(); 472 testConflictLibraryClassRename();
473 testDefaultClassWithArgs(); 473 testDefaultClassWithArgs();
474 testClassExtendsWithArgs(); 474 testClassExtendsWithArgs();
475 testStaticInvocation(); 475 testStaticInvocation();
476 testLibraryGetSet(); 476 // testLibraryGetSet(); // http://dartbug.com/4604
477 testFieldTypeOutput(); 477 testFieldTypeOutput();
478 } 478 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698