(t *testing.T)
| 792 | } |
| 793 | |
| 794 | func TestFunctionAsCELFunction(t *testing.T) { |
| 795 | tests := []struct { |
| 796 | name string |
| 797 | f *Function |
| 798 | want any |
| 799 | }{ |
| 800 | { |
| 801 | name: "nil function", |
| 802 | f: nil, |
| 803 | want: errors.New("invalid function: nil"), |
| 804 | }, |
| 805 | { |
| 806 | name: "unnamed function", |
| 807 | f: &Function{}, |
| 808 | want: errors.New("invalid function"), |
| 809 | }, |
| 810 | { |
| 811 | name: "no overloads", |
| 812 | f: NewFunction("no_overloads"), |
| 813 | want: errors.New("missing overloads"), |
| 814 | }, |
| 815 | { |
| 816 | name: "nil overload", |
| 817 | f: NewFunction("no_overloads", nil), |
| 818 | want: errors.New("invalid overload: nil"), |
| 819 | }, |
| 820 | { |
| 821 | name: "missing overload id", |
| 822 | f: NewFunction("size", &Overload{}), |
| 823 | want: errors.New("missing overload id"), |
| 824 | }, |
| 825 | { |
| 826 | name: "no return type", |
| 827 | f: NewFunction("size", |
| 828 | NewOverload("size_string", []*TypeDesc{NewTypeDesc("string")}, nil), |
| 829 | ), |
| 830 | want: errors.New("return: invalid type"), |
| 831 | }, |
| 832 | { |
| 833 | name: "bad return type", |
| 834 | f: NewFunction("size", |
| 835 | NewOverload("size_string", []*TypeDesc{NewTypeDesc("string")}, NewTypeDesc("")), |
| 836 | ), |
| 837 | want: errors.New("invalid type"), |
| 838 | }, |
| 839 | { |
| 840 | name: "bad arg type", |
| 841 | f: NewFunction("size", |
| 842 | NewOverload("size_string", []*TypeDesc{NewTypeDesc("")}, NewTypeDesc("")), |
| 843 | ), |
| 844 | want: errors.New("invalid type"), |
| 845 | }, |
| 846 | { |
| 847 | name: "undefined arg type", |
| 848 | f: NewFunction("size", |
| 849 | NewOverload("size_undefined", []*TypeDesc{NewTypeDesc("undefined")}, NewTypeDesc("int")), |
| 850 | ), |
| 851 | want: errors.New("undefined type"), |
nothing calls this directly
no test coverage detected