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

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

Issue 10866017: dart2dart Fix type variables rename (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('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/dart_backend/dart_backend.dart"); 9 #import("../../../lib/compiler/implementation/dart_backend/dart_backend.dart");
10 #import("../../../lib/compiler/implementation/elements/elements.dart"); 10 #import("../../../lib/compiler/implementation/elements/elements.dart");
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 (String result) { Expect.equals(expectedResult, result); }); 513 (String result) { Expect.equals(expectedResult, result); });
514 } 514 }
515 515
516 testTypeVariablesAreRenamed() { 516 testTypeVariablesAreRenamed() {
517 // Somewhat a hack: we require all the references of the identifier 517 // Somewhat a hack: we require all the references of the identifier
518 // to be renamed in the same way for the whole library. Hence 518 // to be renamed in the same way for the whole library. Hence
519 // if we have a class and type variable with the same name, they 519 // if we have a class and type variable with the same name, they
520 // both should be renamed. 520 // both should be renamed.
521 var librarySrc = ''' 521 var librarySrc = '''
522 #library('mylib'); 522 #library('mylib');
523 typedef void MyFunction<T extends num>(T arg);
523 class T {} 524 class T {}
524 class B<T> {} 525 class B<T> {}
525 class A<T> extends B<T> { T f; } 526 class A<T> extends B<T> { T f; }
526 '''; 527 ''';
527 var mainSrc = ''' 528 var mainSrc = '''
528 #import('mylib.dart', prefix: 'mylib'); 529 #import('mylib.dart', prefix: 'mylib');
530 typedef void MyFunction<T extends num>(T arg);
529 class T {} 531 class T {}
530 class B<T> {} 532 class B<T> {}
531 class A<T> extends B<T> { T f; } 533 class A<T> extends B<T> { T f; }
532 534
533 main() { 535 main() {
536 MyFunction myf1;
537 mylib.MyFunction myf2;
534 new A<int>().f; 538 new A<int>().f;
535 new T(); 539 new T();
536 540
537 new mylib.A<int>().f; 541 new mylib.A<int>().f;
538 new mylib.T(); 542 new mylib.T();
539 } 543 }
540 '''; 544 ''';
541 var expectedResult = 545 var expectedResult =
542 'class T{}class B<T>{}class A<T> extends B<T>{T f;}' 546 'typedef void MyFunction<T extends num>(T arg);'
543 'class p_T{}class p_B<p_T>{}class p_A<p_T> extends p_B<p_T>{p_T f;}' 547 'class T{}'
544 'main(){new p_A<int>().f; new p_T(); new A<int>().f; new T();}'; 548 'class B<T>{}'
549 'class A<T> extends B<T>{T f;}'
550 'typedef void p_MyFunction<p_T extends num>(p_T arg);'
551 'class p_T{}'
552 'class p_B<p_T>{}'
553 'class p_A<p_T> extends p_B<p_T>{p_T f;}'
554 'main(){p_MyFunction myf1; MyFunction myf2; new p_A<int>().f; '
555 'new p_T(); new A<int>().f; new T();}';
545 testDart2DartWithLibrary(mainSrc, librarySrc, 556 testDart2DartWithLibrary(mainSrc, librarySrc,
546 (String result) { Expect.equals(expectedResult, result); }); 557 (String result) { Expect.equals(expectedResult, result); });
547 } 558 }
548 559
549 testClassTypeArgumentBound() { 560 testClassTypeArgumentBound() {
550 var librarySrc = ''' 561 var librarySrc = '''
551 #library('mylib'); 562 #library('mylib');
552 563
553 interface I {} 564 interface I {}
554 class A<T extends I> {} 565 class A<T extends I> {}
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 testClassExtendsWithArgs(); 632 testClassExtendsWithArgs();
622 testStaticInvocation(); 633 testStaticInvocation();
623 testLibraryGetSet(); 634 testLibraryGetSet();
624 testFieldTypeOutput(); 635 testFieldTypeOutput();
625 testDefaultClassNamePlaceholder(); 636 testDefaultClassNamePlaceholder();
626 testFactoryRename(); 637 testFactoryRename();
627 testTypeVariablesAreRenamed(); 638 testTypeVariablesAreRenamed();
628 testClassTypeArgumentBound(); 639 testClassTypeArgumentBound();
629 testDoubleMains(); 640 testDoubleMains();
630 } 641 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698