Skip to content

Commit 2992aac

Browse files
committed
Add func(...any) (any, error) test
1 parent e092ae3 commit 2992aac

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

expr_test.go

+16
Original file line numberDiff line numberDiff line change
@@ -1660,6 +1660,22 @@ func TestFastCall(t *testing.T) {
16601660
assert.Equal(t, float64(8), out)
16611661
}
16621662

1663+
func TestFastCall_OpCallFastErr(t *testing.T) {
1664+
env := map[string]interface{}{
1665+
"func": func(...interface{}) (interface{}, error) {
1666+
return 8, nil
1667+
},
1668+
}
1669+
code := `func("8")`
1670+
1671+
program, err := expr.Compile(code, expr.Env(env))
1672+
assert.NoError(t, err)
1673+
1674+
out, err := expr.Run(program, env)
1675+
assert.NoError(t, err)
1676+
assert.Equal(t, 8, out)
1677+
}
1678+
16631679
func TestRun_custom_func_returns_an_error_as_second_arg(t *testing.T) {
16641680
env := map[string]interface{}{
16651681
"semver": func(value string, cmp string) (bool, error) { return true, nil },

0 commit comments

Comments
 (0)