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

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

Issue 2345083003: dart2js: run dartfmt on tests (Closed)
Patch Set: revert another multipart test Created 4 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 "package:async_helper/async_helper.dart"; 6 import "package:async_helper/async_helper.dart";
7 import 'package:compiler/src/types/types.dart' show TypeMask; 7 import 'package:compiler/src/types/types.dart' show TypeMask;
8 import 'type_mask_test_helper.dart'; 8 import 'type_mask_test_helper.dart';
9 9
10 import 'compiler_helper.dart'; 10 import 'compiler_helper.dart';
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 testReturnNull6(); 720 testReturnNull6();
721 testReturnNotEquals(); 721 testReturnNotEquals();
722 } 722 }
723 """; 723 """;
724 724
725 void main() { 725 void main() {
726 Uri uri = new Uri(scheme: 'source'); 726 Uri uri = new Uri(scheme: 'source');
727 var compiler = compilerFor(TEST, uri); 727 var compiler = compilerFor(TEST, uri);
728 compiler.diagnosticHandler = createHandler(compiler, TEST); 728 compiler.diagnosticHandler = createHandler(compiler, TEST);
729 asyncTest(() => compiler.run(uri).then((_) { 729 asyncTest(() => compiler.run(uri).then((_) {
730 var commonMasks = compiler.commonMasks; 730 var commonMasks = compiler.commonMasks;
731 var typesInferrer = compiler.globalInference.typesInferrer; 731 var typesInferrer = compiler.globalInference.typesInferrer;
732 var world = compiler.world; 732 var world = compiler.world;
733 733
734 checkReturn(String name, type) { 734 checkReturn(String name, type) {
735 var element = findElement(compiler, name); 735 var element = findElement(compiler, name);
736 Expect.equals( 736 Expect.equals(
737 type, 737 type,
738 simplify(typesInferrer.getReturnTypeOfElement(element), compiler), 738 simplify(typesInferrer.getReturnTypeOfElement(element), compiler),
739 name); 739 name);
740 } 740 }
741 var interceptorType =
742 findTypeMask(compiler, 'Interceptor', 'nonNullSubclass');
743 741
744 checkReturn('returnNum1', commonMasks.numType); 742 var interceptorType =
745 checkReturn('returnNum2', commonMasks.numType); 743 findTypeMask(compiler, 'Interceptor', 'nonNullSubclass');
746 checkReturn('returnInt1', commonMasks.uint31Type);
747 checkReturn('returnInt2', commonMasks.uint31Type);
748 checkReturn('returnDouble', commonMasks.doubleType);
749 checkReturn('returnGiveUp', interceptorType);
750 checkReturn('returnInt5', commonMasks.uint32Type); // uint31+uint31->uint32
751 checkReturn('returnInt6', commonMasks.uint32Type); // uint31+uint31->uint32
752 checkReturn('returnIntOrNull', commonMasks.uint31Type.nullable());
753 checkReturn('returnInt3', commonMasks.uint31Type);
754 checkReturn('returnDynamic', commonMasks.dynamicType);
755 checkReturn('returnInt4', commonMasks.uint31Type);
756 checkReturn('returnInt7', commonMasks.positiveIntType);
757 checkReturn('returnInt8', commonMasks.positiveIntType);
758 checkReturn('returnEmpty1', const TypeMask.nonNullEmpty());
759 checkReturn('returnEmpty2', const TypeMask.nonNullEmpty());
760 TypeMask intType = new TypeMask.nonNullSubtype(
761 compiler.coreClasses.intClass, compiler.world);
762 checkReturn('testIsCheck1', intType);
763 checkReturn('testIsCheck2', intType);
764 checkReturn('testIsCheck3', intType.nullable());
765 checkReturn('testIsCheck4', intType);
766 checkReturn('testIsCheck5', intType);
767 checkReturn('testIsCheck6', commonMasks.dynamicType);
768 checkReturn('testIsCheck7', intType);
769 checkReturn('testIsCheck8', commonMasks.dynamicType);
770 checkReturn('testIsCheck9', intType);
771 checkReturn('testIsCheck10', commonMasks.dynamicType);
772 checkReturn('testIsCheck11', intType);
773 checkReturn('testIsCheck12', commonMasks.dynamicType);
774 checkReturn('testIsCheck13', intType);
775 checkReturn('testIsCheck14', commonMasks.dynamicType);
776 checkReturn('testIsCheck15', intType);
777 checkReturn('testIsCheck16', commonMasks.dynamicType);
778 checkReturn('testIsCheck17', intType);
779 checkReturn('testIsCheck18', commonMasks.dynamicType);
780 checkReturn('testIsCheck19', commonMasks.dynamicType);
781 checkReturn('testIsCheck20', interceptorType);
782 checkReturn('testIsCheck21', commonMasks.dynamicType);
783 checkReturn('testIsCheck22', commonMasks.dynamicType);
784 checkReturn('testIsCheck23', intType);
785 checkReturn('testIsCheck24', intType);
786 checkReturn('testIsCheck25', commonMasks.dynamicType);
787 checkReturn('testIsCheck26', intType);
788 checkReturn('testIsCheck27', intType);
789 checkReturn('testIsCheck28', commonMasks.dynamicType);
790 checkReturn('testIsCheck29', commonMasks.dynamicType);
791 checkReturn('testIf1', commonMasks.uint31Type.nullable());
792 checkReturn('testIf2', commonMasks.uint31Type.nullable());
793 checkReturn('returnAsString', new TypeMask.subtype(
794 compiler.coreClasses.stringClass, compiler.world));
795 checkReturn('returnIntAsNum', commonMasks.uint31Type);
796 checkReturn('returnAsTypedef', commonMasks.functionType.nullable());
797 checkReturn('returnTopLevelGetter', commonMasks.uint31Type);
798 checkReturn('testDeadCode', commonMasks.uint31Type);
799 checkReturn('testLabeledIf', commonMasks.uint31Type.nullable());
800 checkReturn('testSwitch1', simplify(
801 commonMasks.intType
802 .union(commonMasks.doubleType, compiler.world)
803 .nullable(),
804 compiler));
805 checkReturn('testSwitch2', commonMasks.uint31Type);
806 checkReturn('testSwitch3', interceptorType.nullable());
807 checkReturn('testSwitch4', commonMasks.uint31Type);
808 checkReturn('testSwitch5', commonMasks.uint31Type);
809 checkReturn('testContinue1', interceptorType.nullable());
810 checkReturn('testBreak1', interceptorType.nullable());
811 checkReturn('testContinue2', interceptorType.nullable());
812 checkReturn('testBreak2', commonMasks.uint32Type.nullable());
813 checkReturn('testReturnElementOfConstList1', commonMasks.uint31Type);
814 checkReturn('testReturnElementOfConstList2', commonMasks.uint31Type);
815 checkReturn('testReturnItselfOrInt', commonMasks.uint31Type);
816 checkReturn('testReturnInvokeDynamicGetter', commonMasks.dynamicType);
817 744
818 checkReturn('testDoWhile1', commonMasks.stringType); 745 checkReturn('returnNum1', commonMasks.numType);
819 checkReturn('testDoWhile2', commonMasks.nullType); 746 checkReturn('returnNum2', commonMasks.numType);
820 checkReturn('testDoWhile3', commonMasks.uint31Type); 747 checkReturn('returnInt1', commonMasks.uint31Type);
821 checkReturn('testDoWhile4', commonMasks.numType); 748 checkReturn('returnInt2', commonMasks.uint31Type);
749 checkReturn('returnDouble', commonMasks.doubleType);
750 checkReturn('returnGiveUp', interceptorType);
751 checkReturn(
752 'returnInt5', commonMasks.uint32Type); // uint31+uint31->uint32
753 checkReturn(
754 'returnInt6', commonMasks.uint32Type); // uint31+uint31->uint32
755 checkReturn('returnIntOrNull', commonMasks.uint31Type.nullable());
756 checkReturn('returnInt3', commonMasks.uint31Type);
757 checkReturn('returnDynamic', commonMasks.dynamicType);
758 checkReturn('returnInt4', commonMasks.uint31Type);
759 checkReturn('returnInt7', commonMasks.positiveIntType);
760 checkReturn('returnInt8', commonMasks.positiveIntType);
761 checkReturn('returnEmpty1', const TypeMask.nonNullEmpty());
762 checkReturn('returnEmpty2', const TypeMask.nonNullEmpty());
763 TypeMask intType = new TypeMask.nonNullSubtype(
764 compiler.coreClasses.intClass, compiler.world);
765 checkReturn('testIsCheck1', intType);
766 checkReturn('testIsCheck2', intType);
767 checkReturn('testIsCheck3', intType.nullable());
768 checkReturn('testIsCheck4', intType);
769 checkReturn('testIsCheck5', intType);
770 checkReturn('testIsCheck6', commonMasks.dynamicType);
771 checkReturn('testIsCheck7', intType);
772 checkReturn('testIsCheck8', commonMasks.dynamicType);
773 checkReturn('testIsCheck9', intType);
774 checkReturn('testIsCheck10', commonMasks.dynamicType);
775 checkReturn('testIsCheck11', intType);
776 checkReturn('testIsCheck12', commonMasks.dynamicType);
777 checkReturn('testIsCheck13', intType);
778 checkReturn('testIsCheck14', commonMasks.dynamicType);
779 checkReturn('testIsCheck15', intType);
780 checkReturn('testIsCheck16', commonMasks.dynamicType);
781 checkReturn('testIsCheck17', intType);
782 checkReturn('testIsCheck18', commonMasks.dynamicType);
783 checkReturn('testIsCheck19', commonMasks.dynamicType);
784 checkReturn('testIsCheck20', interceptorType);
785 checkReturn('testIsCheck21', commonMasks.dynamicType);
786 checkReturn('testIsCheck22', commonMasks.dynamicType);
787 checkReturn('testIsCheck23', intType);
788 checkReturn('testIsCheck24', intType);
789 checkReturn('testIsCheck25', commonMasks.dynamicType);
790 checkReturn('testIsCheck26', intType);
791 checkReturn('testIsCheck27', intType);
792 checkReturn('testIsCheck28', commonMasks.dynamicType);
793 checkReturn('testIsCheck29', commonMasks.dynamicType);
794 checkReturn('testIf1', commonMasks.uint31Type.nullable());
795 checkReturn('testIf2', commonMasks.uint31Type.nullable());
796 checkReturn(
797 'returnAsString',
798 new TypeMask.subtype(
799 compiler.coreClasses.stringClass, compiler.world));
800 checkReturn('returnIntAsNum', commonMasks.uint31Type);
801 checkReturn('returnAsTypedef', commonMasks.functionType.nullable());
802 checkReturn('returnTopLevelGetter', commonMasks.uint31Type);
803 checkReturn('testDeadCode', commonMasks.uint31Type);
804 checkReturn('testLabeledIf', commonMasks.uint31Type.nullable());
805 checkReturn(
806 'testSwitch1',
807 simplify(
808 commonMasks.intType
809 .union(commonMasks.doubleType, compiler.world)
810 .nullable(),
811 compiler));
812 checkReturn('testSwitch2', commonMasks.uint31Type);
813 checkReturn('testSwitch3', interceptorType.nullable());
814 checkReturn('testSwitch4', commonMasks.uint31Type);
815 checkReturn('testSwitch5', commonMasks.uint31Type);
816 checkReturn('testContinue1', interceptorType.nullable());
817 checkReturn('testBreak1', interceptorType.nullable());
818 checkReturn('testContinue2', interceptorType.nullable());
819 checkReturn('testBreak2', commonMasks.uint32Type.nullable());
820 checkReturn('testReturnElementOfConstList1', commonMasks.uint31Type);
821 checkReturn('testReturnElementOfConstList2', commonMasks.uint31Type);
822 checkReturn('testReturnItselfOrInt', commonMasks.uint31Type);
823 checkReturn('testReturnInvokeDynamicGetter', commonMasks.dynamicType);
822 824
823 checkReturnInClass(String className, String methodName, type) { 825 checkReturn('testDoWhile1', commonMasks.stringType);
824 var cls = findElement(compiler, className); 826 checkReturn('testDoWhile2', commonMasks.nullType);
825 var element = cls.lookupLocalMember(methodName); 827 checkReturn('testDoWhile3', commonMasks.uint31Type);
826 Expect.equals(type, 828 checkReturn('testDoWhile4', commonMasks.numType);
827 simplify(typesInferrer.getReturnTypeOfElement(element), compiler),
828 '$className:$methodName');
829 }
830 829
831 checkReturnInClass('A', 'returnInt1', commonMasks.uint32Type); 830 checkReturnInClass(String className, String methodName, type) {
832 checkReturnInClass('A', 'returnInt2', commonMasks.uint32Type); 831 var cls = findElement(compiler, className);
833 checkReturnInClass('A', 'returnInt3', commonMasks.uint32Type); 832 var element = cls.lookupLocalMember(methodName);
834 checkReturnInClass('A', 'returnInt4', commonMasks.uint32Type); 833 Expect.equals(
835 checkReturnInClass('A', 'returnInt5', commonMasks.uint32Type); 834 type,
836 checkReturnInClass('A', 'returnInt6', commonMasks.uint32Type); 835 simplify(typesInferrer.getReturnTypeOfElement(element), compiler),
837 checkReturnInClass('A', '==', interceptorType); 836 '$className:$methodName');
837 }
838 838
839 checkReturnInClass('B', 'returnInt1', commonMasks.uint32Type); 839 checkReturnInClass('A', 'returnInt1', commonMasks.uint32Type);
840 checkReturnInClass('B', 'returnInt2', commonMasks.uint32Type); 840 checkReturnInClass('A', 'returnInt2', commonMasks.uint32Type);
841 checkReturnInClass('B', 'returnInt3', commonMasks.uint32Type); 841 checkReturnInClass('A', 'returnInt3', commonMasks.uint32Type);
842 checkReturnInClass('B', 'returnInt4', commonMasks.uint32Type); 842 checkReturnInClass('A', 'returnInt4', commonMasks.uint32Type);
843 checkReturnInClass('B', 'returnInt5', commonMasks.uint32Type); 843 checkReturnInClass('A', 'returnInt5', commonMasks.uint32Type);
844 checkReturnInClass('B', 'returnInt6', commonMasks.uint32Type); 844 checkReturnInClass('A', 'returnInt6', commonMasks.uint32Type);
845 checkReturnInClass('B', 'returnInt7', commonMasks.uint32Type); 845 checkReturnInClass('A', '==', interceptorType);
846 checkReturnInClass('B', 'returnInt8', commonMasks.uint32Type);
847 checkReturnInClass('B', 'returnInt9', commonMasks.uint31Type);
848 846
849 checkReturnInClass('C', 'returnInt1', commonMasks.positiveIntType); 847 checkReturnInClass('B', 'returnInt1', commonMasks.uint32Type);
850 checkReturnInClass('C', 'returnInt2', commonMasks.positiveIntType); 848 checkReturnInClass('B', 'returnInt2', commonMasks.uint32Type);
851 checkReturnInClass('C', 'returnInt3', commonMasks.positiveIntType); 849 checkReturnInClass('B', 'returnInt3', commonMasks.uint32Type);
852 checkReturnInClass('C', 'returnInt4', commonMasks.positiveIntType); 850 checkReturnInClass('B', 'returnInt4', commonMasks.uint32Type);
853 checkReturnInClass('C', 'returnInt5', commonMasks.positiveIntType); 851 checkReturnInClass('B', 'returnInt5', commonMasks.uint32Type);
854 checkReturnInClass('C', 'returnInt6', commonMasks.positiveIntType); 852 checkReturnInClass('B', 'returnInt6', commonMasks.uint32Type);
853 checkReturnInClass('B', 'returnInt7', commonMasks.uint32Type);
854 checkReturnInClass('B', 'returnInt8', commonMasks.uint32Type);
855 checkReturnInClass('B', 'returnInt9', commonMasks.uint31Type);
855 856
856 checkFactoryConstructor(String className, String factoryName) { 857 checkReturnInClass('C', 'returnInt1', commonMasks.positiveIntType);
857 var cls = findElement(compiler, className); 858 checkReturnInClass('C', 'returnInt2', commonMasks.positiveIntType);
858 var element = cls.localLookup(factoryName); 859 checkReturnInClass('C', 'returnInt3', commonMasks.positiveIntType);
859 Expect.equals(new TypeMask.nonNullExact(cls, world), 860 checkReturnInClass('C', 'returnInt4', commonMasks.positiveIntType);
860 typesInferrer.getReturnTypeOfElement(element)); 861 checkReturnInClass('C', 'returnInt5', commonMasks.positiveIntType);
861 } 862 checkReturnInClass('C', 'returnInt6', commonMasks.positiveIntType);
862 checkFactoryConstructor('A', '');
863 863
864 checkReturn('testCascade1', commonMasks.growableListType); 864 checkFactoryConstructor(String className, String factoryName) {
865 checkReturn('testCascade2', new TypeMask.nonNullExact( 865 var cls = findElement(compiler, className);
866 findElement(compiler, 'CascadeHelper'), world)); 866 var element = cls.localLookup(factoryName);
867 checkReturn('testSpecialization1', commonMasks.numType); 867 Expect.equals(new TypeMask.nonNullExact(cls, world),
868 checkReturn('testSpecialization2', commonMasks.dynamicType); 868 typesInferrer.getReturnTypeOfElement(element));
869 checkReturn('testSpecialization3', commonMasks.uint31Type.nullable()); 869 }
870 checkReturn('testReturnNull1', commonMasks.nullType); 870
871 checkReturn('testReturnNull2', commonMasks.nullType); 871 checkFactoryConstructor('A', '');
872 checkReturn('testReturnNull3', commonMasks.dynamicType); 872
873 checkReturn('testReturnNull4', commonMasks.nullType); 873 checkReturn('testCascade1', commonMasks.growableListType);
874 checkReturn('testReturnNull5', commonMasks.nullType); 874 checkReturn(
875 checkReturn('testReturnNull6', commonMasks.dynamicType); 875 'testCascade2',
876 checkReturn('testReturnNotEquals', commonMasks.boolType); 876 new TypeMask.nonNullExact(
877 })); 877 findElement(compiler, 'CascadeHelper'), world));
878 checkReturn('testSpecialization1', commonMasks.numType);
879 checkReturn('testSpecialization2', commonMasks.dynamicType);
880 checkReturn('testSpecialization3', commonMasks.uint31Type.nullable());
881 checkReturn('testReturnNull1', commonMasks.nullType);
882 checkReturn('testReturnNull2', commonMasks.nullType);
883 checkReturn('testReturnNull3', commonMasks.dynamicType);
884 checkReturn('testReturnNull4', commonMasks.nullType);
885 checkReturn('testReturnNull5', commonMasks.nullType);
886 checkReturn('testReturnNull6', commonMasks.dynamicType);
887 checkReturn('testReturnNotEquals', commonMasks.boolType);
888 }));
878 } 889 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/simple_inferrer_relations_test.dart ('k') | tests/compiler/dart2js/simple_inferrer_try_catch_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698