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 '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 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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.closedWorld; |
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 = | 741 var interceptorType = |
742 findTypeMask(compiler, 'Interceptor', 'nonNullSubclass'); | 742 findTypeMask(compiler, 'Interceptor', 'nonNullSubclass'); |
743 | 743 |
744 checkReturn('returnNum1', commonMasks.numType); | 744 checkReturn('returnNum1', commonMasks.numType); |
745 checkReturn('returnNum2', commonMasks.numType); | 745 checkReturn('returnNum2', commonMasks.numType); |
746 checkReturn('returnInt1', commonMasks.uint31Type); | 746 checkReturn('returnInt1', commonMasks.uint31Type); |
747 checkReturn('returnInt2', commonMasks.uint31Type); | 747 checkReturn('returnInt2', commonMasks.uint31Type); |
748 checkReturn('returnDouble', commonMasks.doubleType); | 748 checkReturn('returnDouble', commonMasks.doubleType); |
749 checkReturn('returnGiveUp', interceptorType); | 749 checkReturn('returnGiveUp', interceptorType); |
750 checkReturn('returnInt5', commonMasks.uint32Type); // uint31+uint31->uint32 | 750 checkReturn('returnInt5', commonMasks.uint32Type); // uint31+uint31->uint32 |
751 checkReturn('returnInt6', commonMasks.uint32Type); // uint31+uint31->uint32 | 751 checkReturn('returnInt6', commonMasks.uint32Type); // uint31+uint31->uint32 |
752 checkReturn('returnIntOrNull', commonMasks.uint31Type.nullable()); | 752 checkReturn('returnIntOrNull', commonMasks.uint31Type.nullable()); |
753 checkReturn('returnInt3', commonMasks.uint31Type); | 753 checkReturn('returnInt3', commonMasks.uint31Type); |
754 checkReturn('returnDynamic', commonMasks.dynamicType); | 754 checkReturn('returnDynamic', commonMasks.dynamicType); |
755 checkReturn('returnInt4', commonMasks.uint31Type); | 755 checkReturn('returnInt4', commonMasks.uint31Type); |
756 checkReturn('returnInt7', commonMasks.positiveIntType); | 756 checkReturn('returnInt7', commonMasks.positiveIntType); |
757 checkReturn('returnInt8', commonMasks.positiveIntType); | 757 checkReturn('returnInt8', commonMasks.positiveIntType); |
758 checkReturn('returnEmpty1', const TypeMask.nonNullEmpty()); | 758 checkReturn('returnEmpty1', const TypeMask.nonNullEmpty()); |
759 checkReturn('returnEmpty2', const TypeMask.nonNullEmpty()); | 759 checkReturn('returnEmpty2', const TypeMask.nonNullEmpty()); |
760 TypeMask intType = new TypeMask.nonNullSubtype( | 760 TypeMask intType = new TypeMask.nonNullSubtype( |
761 compiler.coreClasses.intClass, compiler.world); | 761 compiler.coreClasses.intClass, compiler.closedWorld); |
762 checkReturn('testIsCheck1', intType); | 762 checkReturn('testIsCheck1', intType); |
763 checkReturn('testIsCheck2', intType); | 763 checkReturn('testIsCheck2', intType); |
764 checkReturn('testIsCheck3', intType.nullable()); | 764 checkReturn('testIsCheck3', intType.nullable()); |
765 checkReturn('testIsCheck4', intType); | 765 checkReturn('testIsCheck4', intType); |
766 checkReturn('testIsCheck5', intType); | 766 checkReturn('testIsCheck5', intType); |
767 checkReturn('testIsCheck6', commonMasks.dynamicType); | 767 checkReturn('testIsCheck6', commonMasks.dynamicType); |
768 checkReturn('testIsCheck7', intType); | 768 checkReturn('testIsCheck7', intType); |
769 checkReturn('testIsCheck8', commonMasks.dynamicType); | 769 checkReturn('testIsCheck8', commonMasks.dynamicType); |
770 checkReturn('testIsCheck9', intType); | 770 checkReturn('testIsCheck9', intType); |
771 checkReturn('testIsCheck10', commonMasks.dynamicType); | 771 checkReturn('testIsCheck10', commonMasks.dynamicType); |
(...skipping 12 matching lines...) Expand all Loading... |
784 checkReturn('testIsCheck23', intType); | 784 checkReturn('testIsCheck23', intType); |
785 checkReturn('testIsCheck24', intType); | 785 checkReturn('testIsCheck24', intType); |
786 checkReturn('testIsCheck25', commonMasks.dynamicType); | 786 checkReturn('testIsCheck25', commonMasks.dynamicType); |
787 checkReturn('testIsCheck26', intType); | 787 checkReturn('testIsCheck26', intType); |
788 checkReturn('testIsCheck27', intType); | 788 checkReturn('testIsCheck27', intType); |
789 checkReturn('testIsCheck28', commonMasks.dynamicType); | 789 checkReturn('testIsCheck28', commonMasks.dynamicType); |
790 checkReturn('testIsCheck29', commonMasks.dynamicType); | 790 checkReturn('testIsCheck29', commonMasks.dynamicType); |
791 checkReturn('testIf1', commonMasks.uint31Type.nullable()); | 791 checkReturn('testIf1', commonMasks.uint31Type.nullable()); |
792 checkReturn('testIf2', commonMasks.uint31Type.nullable()); | 792 checkReturn('testIf2', commonMasks.uint31Type.nullable()); |
793 checkReturn('returnAsString', new TypeMask.subtype( | 793 checkReturn('returnAsString', new TypeMask.subtype( |
794 compiler.coreClasses.stringClass, compiler.world)); | 794 compiler.coreClasses.stringClass, compiler.closedWorld)); |
795 checkReturn('returnIntAsNum', commonMasks.uint31Type); | 795 checkReturn('returnIntAsNum', commonMasks.uint31Type); |
796 checkReturn('returnAsTypedef', commonMasks.functionType.nullable()); | 796 checkReturn('returnAsTypedef', commonMasks.functionType.nullable()); |
797 checkReturn('returnTopLevelGetter', commonMasks.uint31Type); | 797 checkReturn('returnTopLevelGetter', commonMasks.uint31Type); |
798 checkReturn('testDeadCode', commonMasks.uint31Type); | 798 checkReturn('testDeadCode', commonMasks.uint31Type); |
799 checkReturn('testLabeledIf', commonMasks.uint31Type.nullable()); | 799 checkReturn('testLabeledIf', commonMasks.uint31Type.nullable()); |
800 checkReturn('testSwitch1', simplify( | 800 checkReturn('testSwitch1', simplify( |
801 commonMasks.intType | 801 commonMasks.intType |
802 .union(commonMasks.doubleType, compiler.world) | 802 .union(commonMasks.doubleType, compiler.closedWorld) |
803 .nullable(), | 803 .nullable(), |
804 compiler)); | 804 compiler)); |
805 checkReturn('testSwitch2', commonMasks.uint31Type); | 805 checkReturn('testSwitch2', commonMasks.uint31Type); |
806 checkReturn('testSwitch3', interceptorType.nullable()); | 806 checkReturn('testSwitch3', interceptorType.nullable()); |
807 checkReturn('testSwitch4', commonMasks.uint31Type); | 807 checkReturn('testSwitch4', commonMasks.uint31Type); |
808 checkReturn('testSwitch5', commonMasks.uint31Type); | 808 checkReturn('testSwitch5', commonMasks.uint31Type); |
809 checkReturn('testContinue1', interceptorType.nullable()); | 809 checkReturn('testContinue1', interceptorType.nullable()); |
810 checkReturn('testBreak1', interceptorType.nullable()); | 810 checkReturn('testBreak1', interceptorType.nullable()); |
811 checkReturn('testContinue2', interceptorType.nullable()); | 811 checkReturn('testContinue2', interceptorType.nullable()); |
812 checkReturn('testBreak2', commonMasks.uint32Type.nullable()); | 812 checkReturn('testBreak2', commonMasks.uint32Type.nullable()); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
869 checkReturn('testSpecialization3', commonMasks.uint31Type.nullable()); | 869 checkReturn('testSpecialization3', commonMasks.uint31Type.nullable()); |
870 checkReturn('testReturnNull1', commonMasks.nullType); | 870 checkReturn('testReturnNull1', commonMasks.nullType); |
871 checkReturn('testReturnNull2', commonMasks.nullType); | 871 checkReturn('testReturnNull2', commonMasks.nullType); |
872 checkReturn('testReturnNull3', commonMasks.dynamicType); | 872 checkReturn('testReturnNull3', commonMasks.dynamicType); |
873 checkReturn('testReturnNull4', commonMasks.nullType); | 873 checkReturn('testReturnNull4', commonMasks.nullType); |
874 checkReturn('testReturnNull5', commonMasks.nullType); | 874 checkReturn('testReturnNull5', commonMasks.nullType); |
875 checkReturn('testReturnNull6', commonMasks.dynamicType); | 875 checkReturn('testReturnNull6', commonMasks.dynamicType); |
876 checkReturn('testReturnNotEquals', commonMasks.boolType); | 876 checkReturn('testReturnNotEquals', commonMasks.boolType); |
877 })); | 877 })); |
878 } | 878 } |
OLD | NEW |