Skip to content

Commit fc691e3

Browse files
fix(test): add function type in the test
1 parent 1c7ad66 commit fc691e3

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

test/operator/operator_test.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ func TestOperator_interface(t *testing.T) {
5555
require.Equal(t, true, output)
5656
}
5757

58+
type Value struct {
59+
Int int
60+
}
61+
5862
func TestOperator_Function(t *testing.T) {
5963
env := map[string]interface{}{
6064
"foo": Value{1},
@@ -67,15 +71,13 @@ func TestOperator_Function(t *testing.T) {
6771
expr.Operator("+", "Add"),
6872
expr.Function("Add", func(args ...interface{}) (interface{}, error) {
6973
return args[0].(Value).Int + args[1].(Value).Int, nil
70-
}),
74+
},
75+
new(func(_ Value, __ Value) int),
76+
),
7177
)
7278
require.NoError(t, err)
7379

7480
output, err := expr.Run(program, env)
7581
require.NoError(t, err)
7682
require.Equal(t, 3, output)
7783
}
78-
79-
type Value struct {
80-
Int int
81-
}

0 commit comments

Comments
 (0)