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 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 asyncTest(() => compiler.run(uri).then((_) { | 729 asyncTest(() => compiler.run(uri).then((_) { |
730 var typesInferrer = compiler.globalInference.typesInferrerInternal; | 730 var typesInferrer = compiler.globalInference.typesInferrerInternal; |
731 var closedWorld = typesInferrer.closedWorld; | 731 var closedWorld = typesInferrer.closedWorld; |
732 var commonMasks = closedWorld.commonMasks; | 732 var commonMasks = closedWorld.commonMasks; |
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( | 738 simplify( |
739 typesInferrer.getReturnTypeOfElement(element), closedWorld), | 739 typesInferrer.getReturnTypeOfMember(element), closedWorld), |
740 name); | 740 name); |
741 } | 741 } |
742 | 742 |
743 var interceptorType = commonMasks.interceptorType; | 743 var interceptorType = commonMasks.interceptorType; |
744 | 744 |
745 checkReturn('returnNum1', commonMasks.numType); | 745 checkReturn('returnNum1', commonMasks.numType); |
746 checkReturn('returnNum2', commonMasks.numType); | 746 checkReturn('returnNum2', commonMasks.numType); |
747 checkReturn('returnInt1', commonMasks.uint31Type); | 747 checkReturn('returnInt1', commonMasks.uint31Type); |
748 checkReturn('returnInt2', commonMasks.uint31Type); | 748 checkReturn('returnInt2', commonMasks.uint31Type); |
749 checkReturn('returnDouble', commonMasks.doubleType); | 749 checkReturn('returnDouble', commonMasks.doubleType); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 checkReturn('testDoWhile2', commonMasks.nullType); | 827 checkReturn('testDoWhile2', commonMasks.nullType); |
828 checkReturn('testDoWhile3', commonMasks.uint31Type); | 828 checkReturn('testDoWhile3', commonMasks.uint31Type); |
829 checkReturn('testDoWhile4', commonMasks.numType); | 829 checkReturn('testDoWhile4', commonMasks.numType); |
830 | 830 |
831 checkReturnInClass(String className, String methodName, type) { | 831 checkReturnInClass(String className, String methodName, type) { |
832 dynamic cls = findElement(compiler, className); | 832 dynamic cls = findElement(compiler, className); |
833 var element = cls.lookupLocalMember(methodName); | 833 var element = cls.lookupLocalMember(methodName); |
834 Expect.equals( | 834 Expect.equals( |
835 type, | 835 type, |
836 simplify( | 836 simplify( |
837 typesInferrer.getReturnTypeOfElement(element), closedWorld), | 837 typesInferrer.getReturnTypeOfMember(element), closedWorld), |
838 '$className:$methodName'); | 838 '$className:$methodName'); |
839 } | 839 } |
840 | 840 |
841 checkReturnInClass('A', 'returnInt1', commonMasks.uint32Type); | 841 checkReturnInClass('A', 'returnInt1', commonMasks.uint32Type); |
842 checkReturnInClass('A', 'returnInt2', commonMasks.uint32Type); | 842 checkReturnInClass('A', 'returnInt2', commonMasks.uint32Type); |
843 checkReturnInClass('A', 'returnInt3', commonMasks.uint32Type); | 843 checkReturnInClass('A', 'returnInt3', commonMasks.uint32Type); |
844 checkReturnInClass('A', 'returnInt4', commonMasks.uint32Type); | 844 checkReturnInClass('A', 'returnInt4', commonMasks.uint32Type); |
845 checkReturnInClass('A', 'returnInt5', commonMasks.uint32Type); | 845 checkReturnInClass('A', 'returnInt5', commonMasks.uint32Type); |
846 checkReturnInClass('A', 'returnInt6', commonMasks.uint32Type); | 846 checkReturnInClass('A', 'returnInt6', commonMasks.uint32Type); |
847 checkReturnInClass('A', '==', interceptorType); | 847 checkReturnInClass('A', '==', interceptorType); |
(...skipping 12 matching lines...) Expand all Loading... |
860 checkReturnInClass('C', 'returnInt2', commonMasks.positiveIntType); | 860 checkReturnInClass('C', 'returnInt2', commonMasks.positiveIntType); |
861 checkReturnInClass('C', 'returnInt3', commonMasks.positiveIntType); | 861 checkReturnInClass('C', 'returnInt3', commonMasks.positiveIntType); |
862 checkReturnInClass('C', 'returnInt4', commonMasks.positiveIntType); | 862 checkReturnInClass('C', 'returnInt4', commonMasks.positiveIntType); |
863 checkReturnInClass('C', 'returnInt5', commonMasks.positiveIntType); | 863 checkReturnInClass('C', 'returnInt5', commonMasks.positiveIntType); |
864 checkReturnInClass('C', 'returnInt6', commonMasks.positiveIntType); | 864 checkReturnInClass('C', 'returnInt6', commonMasks.positiveIntType); |
865 | 865 |
866 checkFactoryConstructor(String className, String factoryName) { | 866 checkFactoryConstructor(String className, String factoryName) { |
867 dynamic cls = findElement(compiler, className); | 867 dynamic cls = findElement(compiler, className); |
868 var element = cls.localLookup(factoryName); | 868 var element = cls.localLookup(factoryName); |
869 Expect.equals(new TypeMask.nonNullExact(cls, closedWorld), | 869 Expect.equals(new TypeMask.nonNullExact(cls, closedWorld), |
870 typesInferrer.getReturnTypeOfElement(element)); | 870 typesInferrer.getReturnTypeOfMember(element)); |
871 } | 871 } |
872 | 872 |
873 checkFactoryConstructor('A', ''); | 873 checkFactoryConstructor('A', ''); |
874 | 874 |
875 checkReturn('testCascade1', commonMasks.growableListType); | 875 checkReturn('testCascade1', commonMasks.growableListType); |
876 ClassElement clsCascadeHelper = findElement(compiler, 'CascadeHelper'); | 876 ClassElement clsCascadeHelper = findElement(compiler, 'CascadeHelper'); |
877 checkReturn('testCascade2', | 877 checkReturn('testCascade2', |
878 new TypeMask.nonNullExact(clsCascadeHelper, closedWorld)); | 878 new TypeMask.nonNullExact(clsCascadeHelper, closedWorld)); |
879 checkReturn('testSpecialization1', commonMasks.numType); | 879 checkReturn('testSpecialization1', commonMasks.numType); |
880 checkReturn('testSpecialization2', commonMasks.dynamicType); | 880 checkReturn('testSpecialization2', commonMasks.dynamicType); |
881 checkReturn('testSpecialization3', commonMasks.uint31Type.nullable()); | 881 checkReturn('testSpecialization3', commonMasks.uint31Type.nullable()); |
882 checkReturn('testReturnNull1', commonMasks.nullType); | 882 checkReturn('testReturnNull1', commonMasks.nullType); |
883 checkReturn('testReturnNull2', commonMasks.nullType); | 883 checkReturn('testReturnNull2', commonMasks.nullType); |
884 checkReturn('testReturnNull3', commonMasks.dynamicType); | 884 checkReturn('testReturnNull3', commonMasks.dynamicType); |
885 checkReturn('testReturnNull4', commonMasks.nullType); | 885 checkReturn('testReturnNull4', commonMasks.nullType); |
886 checkReturn('testReturnNull5', commonMasks.nullType); | 886 checkReturn('testReturnNull5', commonMasks.nullType); |
887 checkReturn('testReturnNull6', commonMasks.dynamicType); | 887 checkReturn('testReturnNull6', commonMasks.dynamicType); |
888 checkReturn('testReturnNotEquals', commonMasks.boolType); | 888 checkReturn('testReturnNotEquals', commonMasks.boolType); |
889 })); | 889 })); |
890 } | 890 } |
OLD | NEW |