@@ -501,8 +501,8 @@ func typString(pkg *Package, t types.Type) string {
501
501
func TestMethodAutoProperty (t * testing.T ) {
502
502
typs := []types.Type {
503
503
tyInt ,
504
- sigFuncEx (nil , & TyOverloadFunc {}),
505
- sigFuncEx (nil , & TyTemplateRecvMethod {types .NewParam (0 , nil , "" , tyInt )}),
504
+ sigFuncEx (nil , nil , & TyOverloadFunc {}),
505
+ sigFuncEx (nil , nil , & TyTemplateRecvMethod {types .NewParam (0 , nil , "" , tyInt )}),
506
506
}
507
507
for _ , typ := range typs {
508
508
if methodHasAutoProperty (typ , 0 ) {
@@ -512,7 +512,7 @@ func TestMethodAutoProperty(t *testing.T) {
512
512
}
513
513
514
514
func TestIsType (t * testing.T ) {
515
- if isType (sigFuncEx (nil , & TyOverloadFunc {})) {
515
+ if isType (sigFuncEx (nil , nil , & TyOverloadFunc {})) {
516
516
t .Fatal ("TestIsType: isType(TyOverloadFunc)" )
517
517
}
518
518
}
@@ -876,114 +876,6 @@ func TestIsUnbound(t *testing.T) {
876
876
}
877
877
}
878
878
879
- func TestCheckSignature (t * testing.T ) {
880
- denoteRecv (& ast.SelectorExpr {Sel : ident ("x" )})
881
- if CheckSignature (nil , 0 , 0 ) != nil {
882
- t .Fatal ("TestCheckSignature failed: CheckSignature(nil) != nil" )
883
- }
884
- sig := types .NewSignatureType (nil , nil , nil , nil , nil , false )
885
- if CheckSignature (sig , 0 , 0 ) != sig {
886
- t .Fatal ("TestCheckSignature failed: CheckSignature(sig) != sig" )
887
- }
888
- pkg := types .NewPackage ("" , "foo" )
889
- arg := types .NewParam (token .NoPos , pkg , "" , sig )
890
- sig2 := types .NewSignatureType (nil , nil , nil , types .NewTuple (arg , arg ), nil , false )
891
- o := types .NewFunc (token .NoPos , pkg , "bar" , sig2 )
892
- if CheckSignature (sigFuncEx (pkg , & TyTemplateRecvMethod {Func : o }), 0 , 0 ) == nil {
893
- t .Fatal ("TestCheckSignature failed: TemplateRecvMethod CheckSignature == nil" )
894
- }
895
-
896
- of := NewOverloadFunc (token .NoPos , pkg , "bar" , o )
897
- if CheckSignature (of .Type (), 0 , 0 ) == nil {
898
- t .Fatal ("TestCheckSignature failed: OverloadFunc CheckSignature == nil" )
899
- }
900
- if HasAutoProperty (of .Type ()) {
901
- t .Fatal ("func bar has autoprop?" )
902
- }
903
-
904
- if CheckSignature (sigFuncEx (pkg , & TyTemplateRecvMethod {Func : of }), 0 , 0 ) == nil {
905
- t .Fatal ("TestCheckSignature failed: TemplateRecvMethod OverloadFunc CheckSignature == nil" )
906
- }
907
-
908
- o2 := types .NewFunc (token .NoPos , pkg , "bar2" , sig )
909
- of2 := NewOverloadFunc (token .NoPos , pkg , "bar3" , o2 )
910
- if ! HasAutoProperty (of2 .Type ()) {
911
- t .Fatal ("func bar3 has autoprop?" )
912
- }
913
-
914
- typ := types .NewNamed (types .NewTypeName (token .NoPos , pkg , "t" , nil ), types .Typ [types .Int ], nil )
915
- om := NewOverloadMethod (typ , token .NoPos , pkg , "bar" , o )
916
- if CheckSignature (om .Type (), 0 , 1 ) != nil {
917
- t .Fatal ("TestCheckSignature failed: OverloadMethod CheckSignature != nil" )
918
- }
919
- }
920
-
921
- func TestCheckSignatures (t * testing.T ) {
922
- denoteRecv (& ast.SelectorExpr {Sel : ident ("x" )})
923
- if CheckSignatures (nil , 0 , 0 ) != nil {
924
- t .Fatal ("TestCheckSignatures failed: CheckSignatures(nil) != nil" )
925
- }
926
- sig := types .NewSignatureType (nil , nil , nil , nil , nil , false )
927
- if v := CheckSignatures (sig , 0 , 0 ); len (v ) != 1 || v [0 ] != sig {
928
- t .Fatal ("TestCheckSignatures failed: CheckSignatures(sig)[0] != sig" )
929
- }
930
- pkg := types .NewPackage ("" , "foo" )
931
- arg := types .NewParam (token .NoPos , pkg , "" , sig )
932
- sig2 := types .NewSignatureType (nil , nil , nil , types .NewTuple (arg , arg ), nil , false )
933
- o := types .NewFunc (token .NoPos , pkg , "bar" , sig2 )
934
- if CheckSignatures (sigFuncEx (pkg , & TyTemplateRecvMethod {Func : o }), 0 , 0 ) == nil {
935
- t .Fatal ("TestCheckSignatures failed: TemplateRecvMethod CheckSignatures == nil" )
936
- }
937
- sig3 := types .NewSignatureType (nil , nil , nil , types .NewTuple (arg , arg , arg ), nil , false )
938
- o2 := types .NewFunc (token .NoPos , pkg , "bar" , sig3 )
939
- of := NewOverloadFunc (token .NoPos , pkg , "bar" , o , o2 )
940
- if v := CheckSignatures (of .Type (), 0 , 0 ); len (v ) != 2 {
941
- t .Fatal ("TestCheckSignatures failed: OverloadFunc CheckSignatures ==" , len (v ))
942
- }
943
-
944
- if HasAutoProperty (of .Type ()) {
945
- t .Fatal ("func bar has autoprop?" )
946
- }
947
-
948
- if CheckSignatures (sigFuncEx (pkg , & TyTemplateRecvMethod {Func : of }), 0 , 0 ) == nil {
949
- t .Fatal ("TestCheckSignatures failed: TemplateRecvMethod OverloadFunc CheckSignatures == nil" )
950
- }
951
-
952
- o3 := types .NewFunc (token .NoPos , pkg , "bar2" , sig )
953
- of2 := NewOverloadFunc (token .NoPos , pkg , "bar3" , o3 )
954
- if ! HasAutoProperty (of2 .Type ()) {
955
- t .Fatal ("func bar3 has autoprop?" )
956
- }
957
-
958
- typ := types .NewNamed (types .NewTypeName (token .NoPos , pkg , "t" , nil ), types .Typ [types .Int ], nil )
959
- om := NewOverloadMethod (typ , token .NoPos , pkg , "bar" , o , o2 )
960
- if CheckSignatures (om .Type (), 0 , 1 ) != nil {
961
- t .Fatal ("TestCheckSignatures failed: OverloadMethod CheckSignatures != nil" )
962
- }
963
- }
964
-
965
- func TestCheckSigParam (t * testing.T ) {
966
- if checkSigParam (types .NewPointer (types .Typ [types .Int ]), - 1 ) {
967
- t .Fatal ("TestCheckSigParam failed: checkSigParam *int should return false" )
968
- }
969
- pkg := types .NewPackage ("" , "foo" )
970
- typ := types .NewNamed (types .NewTypeName (token .NoPos , pkg , "t" , nil ), types .Typ [types .Int ], nil )
971
- if ! checkSigParam (typ , - 1 ) {
972
- t .Fatal ("TestCheckSigParam failed: checkSigParam *t should return true" )
973
- }
974
- typ2 := types .NewStruct (nil , nil )
975
- if ! checkSigParam (typ2 , - 1 ) {
976
- t .Fatal ("TestCheckSigParam failed: checkSigParam *t should return true" )
977
- }
978
- typ3 := types .NewSlice (types .Typ [types .Int ])
979
- if ! checkSigParam (typ3 , - 2 ) {
980
- t .Fatal ("TestCheckSigParam failed: checkSigParam []int should return true" )
981
- }
982
- if checkSigParam (types .Typ [types .Int ], - 2 ) {
983
- t .Fatal ("TestCheckSigParam failed: checkSigParam int should return false" )
984
- }
985
- }
986
-
987
879
func TestErrWriteFile (t * testing.T ) {
988
880
pkg := NewPackage ("" , "foo" , gblConf )
989
881
pkg .Types = nil
0 commit comments