@@ -16,36 +16,39 @@ func TestExecuteFunction(t *testing.T) {
1616 err := vm .Execute (ctx , `(defn test-add [a b] (+ a b))` )
1717 require .NoError (t , err )
1818
19- err = vm .ExecuteFunction (ctx , nil , "test-add" , 2 , 3 )
19+ err = vm .ExecuteFunction (ctx , nil , Params {}, "test-add" , 2 , 3 )
2020 require .NoError (t , err )
2121 })
2222
2323 t .Run ("non-existent function" , func (t * testing.T ) {
24- err := vm .ExecuteFunction (ctx , nil , "non-existent-function" )
24+ err := vm .ExecuteFunction (ctx , nil , Params {}, "non-existent-function" )
2525 require .Error (t , err )
2626 })
2727
2828 t .Run ("function with different parameter types" , func (t * testing.T ) {
2929 err := vm .Execute (ctx , `(defn test-params [num str bool]
3030 (print "num:" num "str:" str "bool:" bool))` )
3131 require .NoError (t , err )
32- err = vm .ExecuteFunction (ctx , nil , "test-params" , 42 , "hello" , true )
32+ err = vm .ExecuteFunction (
33+ ctx , nil , Params {},
34+ "test-params" , 42 , "hello" , true ,
35+ )
3336 require .NoError (t , err )
3437 })
3538
3639 t .Run ("function with no parameters" , func (t * testing.T ) {
3740 err := vm .Execute (ctx , `(defn test-no-params [] (print "no params"))` )
3841 require .NoError (t , err )
3942
40- err = vm .ExecuteFunction (ctx , nil , "test-no-params" )
43+ err = vm .ExecuteFunction (ctx , nil , Params {}, "test-no-params" )
4144 require .NoError (t , err )
4245 })
4346
4447 t .Run ("function that errors" , func (t * testing.T ) {
4548 err := vm .Execute (ctx , `(defn test-error [] (error "test error"))` )
4649 require .NoError (t , err )
4750
48- err = vm .ExecuteFunction (ctx , nil , "test-error" )
51+ err = vm .ExecuteFunction (ctx , nil , Params {}, "test-error" )
4952 require .Error (t , err )
5053 require .Contains (t , err .Error (), "test error" )
5154 })
@@ -63,7 +66,7 @@ func TestExecuteFunction(t *testing.T) {
6366 err = vm .Execute (ctx , `(defn test-with-user [] (test-user-context))` )
6467 require .NoError (t , err )
6568 testUser := "test-user"
66- err = vm .ExecuteFunction (ctx , testUser , "test-with-user" )
69+ err = vm .ExecuteFunction (ctx , testUser , Params {}, "test-with-user" )
6770 require .NoError (t , err )
6871 require .Equal (t , testUser , receivedUser )
6972 })
@@ -75,7 +78,7 @@ func TestExecuteFunction(t *testing.T) {
7578 )
7679 require .NoError (t , err )
7780
78- err = vm .ExecuteFunction (ctx , nil , "test-var-fn" )
81+ err = vm .ExecuteFunction (ctx , nil , Params {}, "test-var-fn" )
7982 require .NoError (t , err )
8083 })
8184
@@ -86,19 +89,22 @@ func TestExecuteFunction(t *testing.T) {
8689 )
8790 require .NoError (t , err )
8891
89- err = vm .ExecuteFunction (ctx , nil , "test-complex-return" )
92+ err = vm .ExecuteFunction (ctx , nil , Params {}, "test-complex-return" )
9093 require .NoError (t , err )
9194 })
9295
9396 t .Run ("built-in function" , func (t * testing.T ) {
94- err = vm .ExecuteFunction (ctx , nil , "length" , []int {1 , 2 , 3 , 4 })
97+ err = vm .ExecuteFunction (
98+ ctx , nil , Params {},
99+ "length" , []int {1 , 2 , 3 , 4 },
100+ )
95101 require .NoError (t , err )
96102 })
97103
98104 t .Run ("wrong parameter count" , func (t * testing.T ) {
99105 err := vm .Execute (ctx , `(defn test-param-count [a b] (+ a b))` )
100106 require .NoError (t , err )
101- err = vm .ExecuteFunction (ctx , nil , "test-param-count" , 1 )
107+ err = vm .ExecuteFunction (ctx , nil , Params {}, "test-param-count" , 1 )
102108 require .Error (t , err )
103109 })
104110
@@ -109,7 +115,7 @@ func TestExecuteFunction(t *testing.T) {
109115 cancelledCtx , cancel := context .WithCancel (ctx )
110116 cancel ()
111117
112- err = vm .ExecuteFunction (cancelledCtx , nil , "test-slow" )
118+ err = vm .ExecuteFunction (cancelledCtx , nil , Params {}, "test-slow" )
113119 require .Error (t , err )
114120 require .Contains (t , err .Error (), "context canceled" )
115121 })
0 commit comments