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

Side by Side Diff: tests/compiler/dart2js/backend_dart/dart_backend_test.dart

Issue 448943004: Refactor and simplify the dart2dart renamer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fix a number of tests, and remove unused typedef Created 6 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 "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 import 'dart:async'; 6 import 'dart:async';
7 import "package:async_helper/async_helper.dart"; 7 import "package:async_helper/async_helper.dart";
8 import '../mock_compiler.dart'; 8 import '../mock_compiler.dart';
9 import '../mock_libraries.dart'; 9 import '../mock_libraries.dart';
10 import 'package:compiler/compiler.dart'; 10 import 'package:compiler/compiler.dart';
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 var globalVar; 334 var globalVar;
335 var globalVarInitialized = 6; 335 var globalVarInitialized = 6;
336 var globalVarInitialized2 = 7; 336 var globalVarInitialized2 = 7;
337 class A { 337 class A {
338 A() {} 338 A() {}
339 A.fromFoo() {} 339 A.fromFoo() {}
340 static staticfoo() {} 340 static staticfoo() {}
341 foo() {} 341 foo() {}
342 static const field = 5; 342 static const field = 5;
343 } 343 }
344 A_globalfoo() {} 344 globalfoo_A() {}
345 var A_globalVar; 345 var globalVar_A;
346 var A_globalVarInitialized = 6; 346 var globalVarInitialized_A = 6;
347 var A_globalVarInitialized2 = 7; 347 var globalVarInitialized2_A = 7;
348 class A_A { 348 class A_A {
349 A_A() {} 349 A_A() {}
350 A_A.A_fromFoo() {} 350 A_A.fromFoo_A() {}
351 static A_staticfoo() {} 351 static staticfoo_A() {}
352 foo() {} 352 foo() {}
353 static const A_field = 5; 353 static const field_A = 5;
354 } 354 }
355 main() { 355 main() {
356 A_globalVar; 356 globalVar_A;
357 A_globalVarInitialized; 357 globalVarInitialized_A;
358 A_globalVarInitialized2; 358 globalVarInitialized2_A;
359 A_globalfoo(); 359 globalfoo_A();
360 A_A.A_field; 360 A_A.field_A;
361 A_A.A_staticfoo(); 361 A_A.staticfoo_A();
362 new A_A(); 362 new A_A();
363 new A_A.A_fromFoo(); 363 new A_A.fromFoo_A();
364 new A_A().foo(); 364 new A_A().foo();
365 globalVar; 365 globalVar;
366 globalVarInitialized; 366 globalVarInitialized;
367 globalVarInitialized2; 367 globalVarInitialized2;
368 globalfoo(); 368 globalfoo();
369 A.field; 369 A.field;
370 A.staticfoo(); 370 A.staticfoo();
371 new A(); 371 new A();
372 new A.fromFoo(); 372 new A.fromFoo();
373 new A().foo(); 373 new A().foo();
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 a = getA(); 490 a = getA();
491 topfoo(); 491 topfoo();
492 mylib.topfoo(); 492 mylib.topfoo();
493 } 493 }
494 '''; 494 ''';
495 var expectedResult = ''' 495 var expectedResult = '''
496 topfoo() {} 496 topfoo() {}
497 class A { 497 class A {
498 foo() {} 498 foo() {}
499 } 499 }
500 A_topfoo() { 500 topfoo_A() {
501 var x = 5; 501 var x = 5;
502 } 502 }
503 class A_A { 503 class A_A {
504 num foo() {} 504 num foo() {}
505 A_A.fromFoo() {} 505 A_A.fromFoo() {}
506 A myliba; 506 A myliba;
507 List<A_A> mylist; 507 List<A_A> mylist;
508 } 508 }
509 A getA() => null; 509 A getA() => null;
510 main() { 510 main() {
511 var a = new A(); 511 var a = new A();
512 a.foo(); 512 a.foo();
513 var b = new A_A.fromFoo(); 513 var b = new A_A.fromFoo();
514 b.foo(); 514 b.foo();
515 var GREATVAR = b.myliba; 515 var GREATVAR = b.myliba;
516 b.mylist; 516 b.mylist;
517 a = getA(); 517 a = getA();
518 A_topfoo(); 518 topfoo_A();
519 topfoo(); 519 topfoo();
520 } 520 }
521 '''; 521 ''';
522 testDart2DartWithLibrary(mainSrc, librarySrc, 522 testDart2DartWithLibrary(mainSrc, librarySrc,
523 continuation: (String result) { Expect.equals(expectedResult, result); }); 523 continuation: (String result) { Expect.equals(expectedResult, result); });
524 } 524 }
525 525
526 testClassExtendsWithArgs() { 526 testClassExtendsWithArgs() {
527 testDart2Dart(''' 527 testDart2Dart('''
528 main() { 528 main() {
(...skipping 29 matching lines...) Expand all
558 topgetset; 558 topgetset;
559 topgetset = 6; 559 topgetset = 6;
560 560
561 mylib.topgetset; 561 mylib.topgetset;
562 mylib.topgetset = 5; 562 mylib.topgetset = 5;
563 } 563 }
564 '''; 564 ''';
565 var expectedResult = ''' 565 var expectedResult = '''
566 get topgetset => 5; 566 get topgetset => 5;
567 set topgetset(arg) {} 567 set topgetset(arg) {}
568 get A_topgetset => 6; 568 get topgetset_A => 6;
569 set A_topgetset(arg) {} 569 set topgetset_A(arg) {}
570 main() { 570 main() {
571 A_topgetset; 571 topgetset_A;
572 A_topgetset = 6; 572 topgetset_A = 6;
573 topgetset; 573 topgetset;
574 topgetset = 5; 574 topgetset = 5;
575 } 575 }
576 '''; 576 ''';
577 testDart2DartWithLibrary(mainSrc, librarySrc, 577 testDart2DartWithLibrary(mainSrc, librarySrc,
578 continuation: (String result) { Expect.equals(expectedResult, result); }); 578 continuation: (String result) { Expect.equals(expectedResult, result); });
579 } 579 }
580 580
581 testFieldTypeOutput() { 581 testFieldTypeOutput() {
582 testDart2Dart(''' 582 testDart2Dart('''
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 new mylib.T(); 656 new mylib.T();
657 } 657 }
658 '''; 658 ''';
659 var expectedResult = ''' 659 var expectedResult = '''
660 typedef void MyFunction<T extends num>(T arg); 660 typedef void MyFunction<T extends num>(T arg);
661 class T {} 661 class T {}
662 class B<T> {} 662 class B<T> {}
663 class A<T> extends B<T> { 663 class A<T> extends B<T> {
664 T f; 664 T f;
665 } 665 }
666 typedef void A_MyFunction<A_T extends num>(A_T arg); 666 typedef void MyFunction_A<T_A extends num>(T_A arg);
667 class A_T {} 667 class T_A {}
668 class A_B<A_T> {} 668 class B_A<T_A> {}
669 class A_A<A_T> extends A_B<A_T> { 669 class A_A<T_A> extends B_A<T_A> {
670 A_T f; 670 T_A f;
671 } 671 }
672 main() { 672 main() {
673 A_MyFunction myf1; 673 MyFunction_A myf1;
674 MyFunction myf2; 674 MyFunction myf2;
675 new A_A<int>().f; 675 new A_A<int>().f;
676 new A_T(); 676 new T_A();
677 new A<int>().f; 677 new A<int>().f;
678 new T(); 678 new T();
679 } 679 }
680 '''; 680 ''';
681 testDart2DartWithLibrary(mainSrc, librarySrc, 681 testDart2DartWithLibrary(mainSrc, librarySrc,
682 continuation: (String result) { Expect.equals(expectedResult, result); }); 682 continuation: (String result) { Expect.equals(expectedResult, result); });
683 } 683 }
684 684
685 testClassTypeArgumentBound() { 685 testClassTypeArgumentBound() {
686 var librarySrc = ''' 686 var librarySrc = '''
(...skipping 10 matching lines...) Expand all
697 class A<T extends I> {} 697 class A<T extends I> {}
698 698
699 main() { 699 main() {
700 new A(); 700 new A();
701 new mylib.A(); 701 new mylib.A();
702 } 702 }
703 '''; 703 ''';
704 var expectedResult = ''' 704 var expectedResult = '''
705 class I {} 705 class I {}
706 class A<T extends I> {} 706 class A<T extends I> {}
707 class A_I {} 707 class I_A {}
708 class A_A<A_T extends A_I> {} 708 class A_A<T_A extends I_A> {}
709 main() { 709 main() {
710 new A_A(); 710 new A_A();
711 new A(); 711 new A();
712 } 712 }
713 '''; 713 ''';
714 testDart2DartWithLibrary(mainSrc, librarySrc, 714 testDart2DartWithLibrary(mainSrc, librarySrc,
715 continuation: (String result) { Expect.equals(expectedResult, result); }); 715 continuation: (String result) { Expect.equals(expectedResult, result); });
716 } 716 }
717 717
718 testDoubleMains() { 718 testDoubleMains() {
719 var librarySrc = ''' 719 var librarySrc = '''
720 library mylib; 720 library mylib;
721 main() {} 721 main() {}
722 '''; 722 ''';
723 var mainSrc = ''' 723 var mainSrc = '''
724 import 'mylib.dart' as mylib; 724 import 'mylib.dart' as mylib;
725 main() { 725 main() {
726 mylib.main(); 726 mylib.main();
727 } 727 }
728 '''; 728 ''';
729 var expectedResult = ''' 729 var expectedResult = '''
730 A_main() {} 730 main_A() {}
731 main() { 731 main() {
732 A_main(); 732 main_A();
733 } 733 }
734 '''; 734 ''';
735 testDart2DartWithLibrary(mainSrc, librarySrc, 735 testDart2DartWithLibrary(mainSrc, librarySrc,
736 continuation: (String result) { Expect.equals(expectedResult, result); }); 736 continuation: (String result) { Expect.equals(expectedResult, result); });
737 } 737 }
738 738
739 testStaticAccessIoLib() { 739 testStaticAccessIoLib() {
740 var src = ''' 740 var src = '''
741 import 'dart:io'; 741 import 'dart:io';
742 742
743 main() { 743 main() {
744 Platform.operatingSystem; 744 Platform.operatingSystem;
745 } 745 }
746 '''; 746 ''';
747 var expectedResult = ''' 747 var expectedResult = '''
748 import "dart:io" as p; 748 import "dart:io";
749 main() { 749 main() {
750 p.Platform.operatingSystem; 750 Platform.operatingSystem;
751 } 751 }
752 '''; 752 ''';
753 testDart2Dart(src, 753 testDart2Dart(src,
754 continuation: (String result) { Expect.equals(expectedResult, result); }); 754 continuation: (String result) { Expect.equals(expectedResult, result); });
755 } 755 }
756 756
757 testMinification() { 757 testMinification() {
758 var src = ''' 758 var src = '''
759 class ClassWithVeryVeryLongName {} 759 class ClassWithVeryVeryLongName {}
760 main() { 760 main() {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 844
845 class A { 845 class A {
846 static String get userAgent => window.navigator.userAgent; 846 static String get userAgent => window.navigator.userAgent;
847 } 847 }
848 848
849 main() { 849 main() {
850 A.userAgent; 850 A.userAgent;
851 } 851 }
852 '''; 852 ''';
853 var expectedResult = ''' 853 var expectedResult = '''
854 import "dart:html" as p; 854 import "dart:html";
855 class A { 855 class A {
856 static String get A_userAgent => p.window.navigator.userAgent; 856 static String get userAgent_A => window.navigator.userAgent;
857 } 857 }
858 main() { 858 main() {
859 A.A_userAgent; 859 A.userAgent_A;
860 } 860 }
861 '''; 861 ''';
862 testDart2Dart(src, 862 testDart2Dart(src,
863 continuation: (String result) { Expect.equals(expectedResult, result); }); 863 continuation: (String result) { Expect.equals(expectedResult, result); });
864 } 864 }
865 865
866 testConflictsWithCoreLib() { 866 testConflictsWithCoreLib() {
867 var src = ''' 867 var src = '''
868 import 'dart:core' as fisk; 868 import 'dart:core' as fisk;
869 869
870 print(x) { throw 'fisk'; } 870 print(x) { throw 'fisk'; }
871 871
872 main() { 872 main() {
873 fisk.print('corelib'); 873 fisk.print('corelib');
874 print('local'); 874 print('local');
875 } 875 }
876 '''; 876 ''';
877 var expectedResult = """ 877 var expectedResult = """
878 A_print(x) { 878 print_A(x) {
879 throw 'fisk'; 879 throw 'fisk';
880 } 880 }
881 main() { 881 main() {
882 print('corelib'); 882 print('corelib');
883 A_print('local'); 883 print_A('local');
884 } 884 }
885 """; 885 """;
886 testDart2Dart(src, 886 testDart2Dart(src,
887 continuation: (String result) { Expect.equals(expectedResult, result); }); 887 continuation: (String result) { Expect.equals(expectedResult, result); });
888 } 888 }
889 889
890 testUnresolvedNamedConstructor() { 890 testUnresolvedNamedConstructor() {
891 var src = ''' 891 var src = '''
892 class A { 892 class A {
893 A() {} 893 A() {}
894 } 894 }
895 895
896 main() { 896 main() {
897 new A(); 897 new A();
898 new A.named(); 898 new A.named();
899 } 899 }
900 '''; 900 ''';
901 var expectedResult = """ 901 var expectedResult = """
902 class A { 902 class A {
903 A() {} 903 A() {}
904 } 904 }
905 main() { 905 main() {
906 new A(); 906 new A();
907 new A_Unresolved(); 907 new Unresolved_A();
908 } 908 }
909 """; 909 """;
910 testDart2Dart(src, 910 testDart2Dart(src,
911 continuation: (String result) { Expect.equals(expectedResult, result); }); 911 continuation: (String result) { Expect.equals(expectedResult, result); });
912 } 912 }
913 913
914 main() { 914 main() {
915 testSimpleFileUnparse(); 915 testSimpleFileUnparse();
916 testTopLevelField(); 916 testTopLevelField();
917 testSimpleTopLevelClass(); 917 testSimpleTopLevelClass();
(...skipping 16 matching lines...) Expand all
934 testStaticAccessIoLib(); 934 testStaticAccessIoLib();
935 testLocalFunctionPlaceholder(); 935 testLocalFunctionPlaceholder();
936 testMinification(); 936 testMinification();
937 testClosureLocalsMinified(); 937 testClosureLocalsMinified();
938 testParametersMinified(); 938 testParametersMinified();
939 testDeclarationTypePlaceholders(); 939 testDeclarationTypePlaceholders();
940 testPlatformLibraryMemberNamesAreFixed(); 940 testPlatformLibraryMemberNamesAreFixed();
941 testConflictsWithCoreLib(); 941 testConflictsWithCoreLib();
942 testUnresolvedNamedConstructor(); 942 testUnresolvedNamedConstructor();
943 } 943 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698