Skip to content

Commit 11be624

Browse files
emickleiantonmedv
authored andcommitted
add test to demo issue
1 parent 8d1f4e8 commit 11be624

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

expr_test.go

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ package expr_test
33
import (
44
"encoding/json"
55
"fmt"
6-
"github.com/antonmedv/expr/ast"
7-
"github.com/antonmedv/expr/file"
86
"reflect"
97
"strings"
108
"testing"
119
"time"
1210

11+
"github.com/antonmedv/expr/ast"
12+
"github.com/antonmedv/expr/file"
13+
1314
"github.com/antonmedv/expr"
1415
"github.com/stretchr/testify/assert"
1516
"github.com/stretchr/testify/require"
@@ -962,6 +963,23 @@ func TestExpr_calls_with_nil(t *testing.T) {
962963
require.Equal(t, true, out)
963964
}
964965

966+
func TestExpr_call_floatarg_func_with_negative_int(t *testing.T) {
967+
env := map[string]interface{}{
968+
"cnv": func(f float64) interface{} {
969+
assert.Equal(t, -1, f)
970+
return f
971+
},
972+
}
973+
p, err := expr.Compile(
974+
"cnv(-1)",
975+
expr.Env(env))
976+
require.NoError(t, err)
977+
978+
out, err := expr.Run(p, env)
979+
require.NoError(t, err)
980+
require.Equal(t, -1, out)
981+
}
982+
965983
func TestConstExpr_error(t *testing.T) {
966984
env := map[string]interface{}{
967985
"divide": func(a, b int) int { return a / b },

0 commit comments

Comments
 (0)