@@ -3,13 +3,14 @@ package expr_test
3
3
import (
4
4
"encoding/json"
5
5
"fmt"
6
- "github.com/antonmedv/expr/ast"
7
- "github.com/antonmedv/expr/file"
8
6
"reflect"
9
7
"strings"
10
8
"testing"
11
9
"time"
12
10
11
+ "github.com/antonmedv/expr/ast"
12
+ "github.com/antonmedv/expr/file"
13
+
13
14
"github.com/antonmedv/expr"
14
15
"github.com/stretchr/testify/assert"
15
16
"github.com/stretchr/testify/require"
@@ -962,6 +963,23 @@ func TestExpr_calls_with_nil(t *testing.T) {
962
963
require .Equal (t , true , out )
963
964
}
964
965
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
+
965
983
func TestConstExpr_error (t * testing.T ) {
966
984
env := map [string ]interface {}{
967
985
"divide" : func (a , b int ) int { return a / b },
0 commit comments