mirror of
https://github.com/hanzoai/expr.git
synced 2026-09-24 16:58:58 +00:00
Add quotes to error message
This commit is contained in:
@@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user