diff --git a/patcher/operator_override.go b/patcher/operator_override.go index 96e6894c..428454f5 100644 --- a/patcher/operator_override.go +++ b/patcher/operator_override.go @@ -131,11 +131,11 @@ func checkType(fnType conf.Tag, fn string, operator string) { func checkFunc(fn *builtin.Function, name string, operator string) { if len(fn.Types) == 0 { - panic(fmt.Errorf("function %s for %s operator misses types", name, operator)) + panic(fmt.Errorf("function %q for %q operator misses types", name, operator)) } for _, t := range fn.Types { if t.NumIn() != 2 || t.NumOut() != 1 { - panic(fmt.Errorf("function %s for %s operator does not have a correct signature", name, operator)) + panic(fmt.Errorf("function %q for %q operator does not have a correct signature", name, operator)) } } } diff --git a/test/operator/operator_test.go b/test/operator/operator_test.go index 99817eff..a19c191d 100644 --- a/test/operator/operator_test.go +++ b/test/operator/operator_test.go @@ -5,6 +5,7 @@ import ( "testing" "time" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/expr-lang/expr" @@ -108,7 +109,7 @@ func TestOperator_Function_WithTypes(t *testing.T) { "bar": Value{2}, } - require.PanicsWithError(t, `function Add for + operator misses types`, func() { + assert.PanicsWithError(t, `function "Add" for "+" operator misses types`, func() { _, _ = expr.Compile( `foo + bar`, expr.Env(env), @@ -119,7 +120,7 @@ func TestOperator_Function_WithTypes(t *testing.T) { ) }) - require.PanicsWithError(t, `function Add for + operator does not have a correct signature`, func() { + assert.PanicsWithError(t, `function "Add" for "+" operator does not have a correct signature`, func() { _, _ = expr.Compile( `foo + bar`, expr.Env(env), @@ -131,7 +132,6 @@ func TestOperator_Function_WithTypes(t *testing.T) { ), ) }) - } func TestOperator_FunctionOverTypesPrecedence(t *testing.T) {