(t *testing.T)
| 899 | } |
| 900 | |
| 901 | func TestFunctionAsCELFunction(t *testing.T) { |
| 902 | tests := []struct { |
| 903 | name string |
| 904 | f *Function |
| 905 | want any |
| 906 | }{ |
| 907 | { |
| 908 | name: "nil function", |
| 909 | f: nil, |
| 910 | want: errors.New("invalid function: nil"), |
| 911 | }, |
| 912 | { |
| 913 | name: "unnamed function", |
| 914 | f: &Function{}, |
| 915 | want: errors.New("invalid function"), |
| 916 | }, |
| 917 | { |
| 918 | name: "no overloads", |
| 919 | f: NewFunction("no_overloads"), |
| 920 | want: errors.New("missing overloads"), |
| 921 | }, |
| 922 | { |
| 923 | name: "nil overload", |
| 924 | f: NewFunction("no_overloads", nil), |
| 925 | want: errors.New("invalid overload: nil"), |
| 926 | }, |
| 927 | { |
| 928 | name: "missing overload id", |
| 929 | f: NewFunction("size", &Overload{}), |
| 930 | want: errors.New("missing overload id"), |
| 931 | }, |
| 932 | { |
| 933 | name: "no return type", |
| 934 | f: NewFunction("size", |
| 935 | NewOverload("size_string", []*TypeDesc{NewTypeDesc("string")}, nil), |
| 936 | ), |
| 937 | want: errors.New("return: invalid type"), |
| 938 | }, |
| 939 | { |
| 940 | name: "bad return type", |
| 941 | f: NewFunction("size", |
| 942 | NewOverload("size_string", []*TypeDesc{NewTypeDesc("string")}, NewTypeDesc("")), |
| 943 | ), |
| 944 | want: errors.New("invalid type"), |
| 945 | }, |
| 946 | { |
| 947 | name: "bad arg type", |
| 948 | f: NewFunction("size", |
| 949 | NewOverload("size_string", []*TypeDesc{NewTypeDesc("")}, NewTypeDesc("")), |
| 950 | ), |
| 951 | want: errors.New("invalid type"), |
| 952 | }, |
| 953 | { |
| 954 | name: "undefined arg type", |
| 955 | f: NewFunction("size", |
| 956 | NewOverload("size_undefined", []*TypeDesc{NewTypeDesc("undefined")}, NewTypeDesc("int")), |
| 957 | ), |
| 958 | want: errors.New("undefined type"), |
nothing calls this directly
no test coverage detected