Add quotes to error message

This commit is contained in:
Anton Medvedev
2024-02-18 09:45:39 +01:00
parent b117e690fb
commit ee9b3142d1
2 changed files with 5 additions and 5 deletions
+2 -2
View File
@@ -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))
}
}
}
+3 -3
View File
@@ -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) {