OLD | NEW |
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 | 7 import |
8 '../../../sdk/lib/_internal/compiler/implementation/types/types.dart' | 8 '../../../sdk/lib/_internal/compiler/implementation/types/types.dart' |
9 show TypeMask; | 9 show TypeMask; |
10 | 10 |
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
710 Expect.equals( | 710 Expect.equals( |
711 type, | 711 type, |
712 typesInferrer.getReturnTypeOfElement(element).simplify(compiler), | 712 typesInferrer.getReturnTypeOfElement(element).simplify(compiler), |
713 name); | 713 name); |
714 } | 714 } |
715 var interceptorType = | 715 var interceptorType = |
716 findTypeMask(compiler, 'Interceptor', 'nonNullSubclass'); | 716 findTypeMask(compiler, 'Interceptor', 'nonNullSubclass'); |
717 | 717 |
718 checkReturn('returnNum1', typesTask.numType); | 718 checkReturn('returnNum1', typesTask.numType); |
719 checkReturn('returnNum2', typesTask.numType); | 719 checkReturn('returnNum2', typesTask.numType); |
720 checkReturn('returnInt1', typesTask.intType); | 720 checkReturn('returnInt1', typesTask.uint31Type); |
721 checkReturn('returnInt2', typesTask.intType); | 721 checkReturn('returnInt2', typesTask.uint31Type); |
722 checkReturn('returnDouble', typesTask.doubleType); | 722 checkReturn('returnDouble', typesTask.doubleType); |
723 checkReturn('returnGiveUp', interceptorType); | 723 checkReturn('returnGiveUp', interceptorType); |
724 checkReturn('returnInt5', typesTask.intType); | 724 checkReturn('returnInt5', typesTask.intType); |
725 checkReturn('returnInt6', typesTask.intType); | 725 checkReturn('returnInt6', typesTask.intType); |
726 checkReturn('returnIntOrNull', typesTask.intType.nullable()); | 726 checkReturn('returnIntOrNull', typesTask.uint31Type.nullable()); |
727 checkReturn('returnInt3', typesTask.intType); | 727 checkReturn('returnInt3', typesTask.uint31Type); |
728 checkReturn('returnDynamic', typesTask.dynamicType); | 728 checkReturn('returnDynamic', typesTask.dynamicType); |
729 checkReturn('returnInt4', typesTask.intType); | 729 checkReturn('returnInt4', typesTask.uint31Type); |
730 checkReturn('returnInt7', typesTask.intType); | 730 checkReturn('returnInt7', typesTask.intType); |
731 checkReturn('returnInt8', typesTask.intType); | 731 checkReturn('returnInt8', typesTask.intType); |
732 checkReturn('returnEmpty1', const TypeMask.nonNullEmpty()); | 732 checkReturn('returnEmpty1', const TypeMask.nonNullEmpty()); |
733 checkReturn('returnEmpty2', const TypeMask.nonNullEmpty()); | 733 checkReturn('returnEmpty2', const TypeMask.nonNullEmpty()); |
734 TypeMask intType = new TypeMask.nonNullSubtype(compiler.intClass); | 734 TypeMask intType = new TypeMask.nonNullSubtype(compiler.intClass); |
735 checkReturn('testIsCheck1', intType); | 735 checkReturn('testIsCheck1', intType); |
736 checkReturn('testIsCheck2', intType); | 736 checkReturn('testIsCheck2', intType); |
737 checkReturn('testIsCheck3', intType.nullable()); | 737 checkReturn('testIsCheck3', intType.nullable()); |
738 checkReturn('testIsCheck4', intType); | 738 checkReturn('testIsCheck4', intType); |
739 checkReturn('testIsCheck5', intType); | 739 checkReturn('testIsCheck5', intType); |
(...skipping 14 matching lines...) Expand all Loading... |
754 checkReturn('testIsCheck20', typesTask.dynamicType.nonNullable()); | 754 checkReturn('testIsCheck20', typesTask.dynamicType.nonNullable()); |
755 checkReturn('testIsCheck21', typesTask.dynamicType); | 755 checkReturn('testIsCheck21', typesTask.dynamicType); |
756 checkReturn('testIsCheck22', typesTask.dynamicType); | 756 checkReturn('testIsCheck22', typesTask.dynamicType); |
757 checkReturn('testIsCheck23', intType); | 757 checkReturn('testIsCheck23', intType); |
758 checkReturn('testIsCheck24', intType); | 758 checkReturn('testIsCheck24', intType); |
759 checkReturn('testIsCheck25', typesTask.dynamicType); | 759 checkReturn('testIsCheck25', typesTask.dynamicType); |
760 checkReturn('testIsCheck26', intType); | 760 checkReturn('testIsCheck26', intType); |
761 checkReturn('testIsCheck27', intType); | 761 checkReturn('testIsCheck27', intType); |
762 checkReturn('testIsCheck28', typesTask.dynamicType); | 762 checkReturn('testIsCheck28', typesTask.dynamicType); |
763 checkReturn('testIsCheck29', typesTask.dynamicType); | 763 checkReturn('testIsCheck29', typesTask.dynamicType); |
764 checkReturn('testIf1', typesTask.intType.nullable()); | 764 checkReturn('testIf1', typesTask.uint31Type.nullable()); |
765 checkReturn('testIf2', typesTask.intType.nullable()); | 765 checkReturn('testIf2', typesTask.uint31Type.nullable()); |
766 checkReturn('returnAsString', | 766 checkReturn('returnAsString', |
767 new TypeMask.subtype(compiler.stringClass)); | 767 new TypeMask.subtype(compiler.stringClass)); |
768 checkReturn('returnIntAsNum', typesTask.intType); | 768 checkReturn('returnIntAsNum', typesTask.uint31Type); |
769 checkReturn('returnAsTypedef', typesTask.functionType.nullable()); | 769 checkReturn('returnAsTypedef', typesTask.functionType.nullable()); |
770 checkReturn('returnTopLevelGetter', typesTask.intType); | 770 checkReturn('returnTopLevelGetter', typesTask.intType); |
771 checkReturn('testDeadCode', typesTask.intType); | 771 checkReturn('testDeadCode', typesTask.intType); |
772 checkReturn('testLabeledIf', typesTask.intType.nullable()); | 772 checkReturn('testLabeledIf', typesTask.uint31Type.nullable()); |
773 checkReturn('testSwitch1', typesTask.intType | 773 checkReturn('testSwitch1', typesTask.intType |
774 .union(typesTask.doubleType, compiler) | 774 .union(typesTask.doubleType, compiler) |
775 .nullable().simplify(compiler)); | 775 .nullable().simplify(compiler)); |
776 checkReturn('testSwitch2', typesTask.intType); | 776 checkReturn('testSwitch2', typesTask.uint31Type); |
777 checkReturn('testSwitch3', interceptorType.nullable()); | 777 checkReturn('testSwitch3', interceptorType.nullable()); |
778 checkReturn('testSwitch4', typesTask.intType); | 778 checkReturn('testSwitch4', typesTask.uint31Type); |
779 checkReturn('testSwitch5', typesTask.intType); | 779 checkReturn('testSwitch5', typesTask.uint31Type); |
780 checkReturn('testContinue1', interceptorType.nullable()); | 780 checkReturn('testContinue1', interceptorType.nullable()); |
781 checkReturn('testBreak1', interceptorType.nullable()); | 781 checkReturn('testBreak1', interceptorType.nullable()); |
782 checkReturn('testContinue2', interceptorType.nullable()); | 782 checkReturn('testContinue2', interceptorType.nullable()); |
783 checkReturn('testBreak2', typesTask.intType.nullable()); | 783 checkReturn('testBreak2', typesTask.intType.nullable()); |
784 checkReturn('testReturnElementOfConstList1', typesTask.intType); | 784 checkReturn('testReturnElementOfConstList1', typesTask.uint31Type); |
785 checkReturn('testReturnElementOfConstList2', typesTask.intType); | 785 checkReturn('testReturnElementOfConstList2', typesTask.uint31Type); |
786 checkReturn('testReturnItselfOrInt', typesTask.intType); | 786 checkReturn('testReturnItselfOrInt', typesTask.uint31Type); |
787 checkReturn('testReturnInvokeDynamicGetter', typesTask.dynamicType); | 787 checkReturn('testReturnInvokeDynamicGetter', typesTask.dynamicType); |
788 | 788 |
789 checkReturn('testDoWhile1', typesTask.stringType); | 789 checkReturn('testDoWhile1', typesTask.stringType); |
790 checkReturn('testDoWhile2', typesTask.nullType); | 790 checkReturn('testDoWhile2', typesTask.nullType); |
791 checkReturn('testDoWhile3', typesTask.intType); | 791 checkReturn('testDoWhile3', typesTask.uint31Type); |
792 checkReturn('testDoWhile4', typesTask.numType); | 792 checkReturn('testDoWhile4', typesTask.numType); |
793 | 793 |
794 checkReturnInClass(String className, String methodName, type) { | 794 checkReturnInClass(String className, String methodName, type) { |
795 var cls = findElement(compiler, className); | 795 var cls = findElement(compiler, className); |
796 var element = cls.lookupLocalMember(methodName); | 796 var element = cls.lookupLocalMember(methodName); |
797 Expect.equals(type, | 797 Expect.equals(type, |
798 typesInferrer.getReturnTypeOfElement(element).simplify(compiler)); | 798 typesInferrer.getReturnTypeOfElement(element).simplify(compiler)); |
799 } | 799 } |
800 | 800 |
801 checkReturnInClass('A', 'returnInt1', typesTask.intType); | 801 checkReturnInClass('A', 'returnInt1', typesTask.intType); |
(...skipping 20 matching lines...) Expand all Loading... |
822 Expect.equals(new TypeMask.nonNullExact(cls), | 822 Expect.equals(new TypeMask.nonNullExact(cls), |
823 typesInferrer.getReturnTypeOfElement(element)); | 823 typesInferrer.getReturnTypeOfElement(element)); |
824 } | 824 } |
825 checkFactoryConstructor('A', ''); | 825 checkFactoryConstructor('A', ''); |
826 | 826 |
827 checkReturn('testCascade1', typesTask.growableListType); | 827 checkReturn('testCascade1', typesTask.growableListType); |
828 checkReturn('testCascade2', new TypeMask.nonNullExact( | 828 checkReturn('testCascade2', new TypeMask.nonNullExact( |
829 findElement(compiler, 'CascadeHelper'))); | 829 findElement(compiler, 'CascadeHelper'))); |
830 checkReturn('testSpecialization1', typesTask.numType); | 830 checkReturn('testSpecialization1', typesTask.numType); |
831 checkReturn('testSpecialization2', typesTask.dynamicType); | 831 checkReturn('testSpecialization2', typesTask.dynamicType); |
832 checkReturn('testSpecialization3', typesTask.intType.nullable()); | 832 checkReturn('testSpecialization3', typesTask.uint31Type.nullable()); |
833 checkReturn('testReturnNull1', typesTask.nullType); | 833 checkReturn('testReturnNull1', typesTask.nullType); |
834 checkReturn('testReturnNull2', typesTask.nullType); | 834 checkReturn('testReturnNull2', typesTask.nullType); |
835 checkReturn('testReturnNull3', typesTask.dynamicType); | 835 checkReturn('testReturnNull3', typesTask.dynamicType); |
836 checkReturn('testReturnNull4', typesTask.nullType); | 836 checkReturn('testReturnNull4', typesTask.nullType); |
837 checkReturn('testReturnNull5', typesTask.nullType); | 837 checkReturn('testReturnNull5', typesTask.nullType); |
838 checkReturn('testReturnNull6', typesTask.dynamicType); | 838 checkReturn('testReturnNull6', typesTask.dynamicType); |
839 })); | 839 })); |
840 } | 840 } |
OLD | NEW |