Skip to content

Commit 56c606d

Browse files
committed
Add test
1 parent 9f164c0 commit 56c606d

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

v8_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,26 @@ func TestMustEval(t *testing.T) {
221221
}
222222
}
223223

224+
func TestCall(t *testing.T) {
225+
ctx := NewContext()
226+
ctx.AddFunc("func_call", func(args ...interface{}) (interface{}, error) {
227+
f := func(args ...interface{}) (interface{}, error) {
228+
return "V8", nil
229+
}
230+
ret, _ := args[0].(Function).Call("Go", 2, 1, f)
231+
return ret, nil
232+
})
233+
234+
r := ctx.MustEval(`
235+
func_call(function() {
236+
return "Hello " + arguments[0] + (arguments[1] - arguments[2])
237+
+ ", Hello " + arguments[3]();
238+
})
239+
`).(string)
240+
if r != "Hello Go1, Hello V8" {
241+
t.Fatal(`Expected result to be "Hello Go1, Hello V8", got`, r)
242+
}
243+
}
224244
func v8EvalRoutine(i int, wg *sync.WaitGroup, t *testing.T) {
225245
defer wg.Done()
226246

0 commit comments

Comments
 (0)