Skip to content

Commit

Permalink
Add quotes to error message
Browse files Browse the repository at this point in the history
  • Loading branch information
antonmedv committed Feb 18, 2024
1 parent 3da8527 commit 323873a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions patcher/operator_override.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}
}
6 changes: 3 additions & 3 deletions test/operator/operator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/expr-lang/expr"
Expand Down Expand Up @@ -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),
Expand All @@ -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),
Expand All @@ -131,7 +132,6 @@ func TestOperator_Function_WithTypes(t *testing.T) {
),
)
})

}

func TestOperator_FunctionOverTypesPrecedence(t *testing.T) {
Expand Down

0 comments on commit 323873a

Please sign in to comment.