Skip to content

Commit

Permalink
test(vm): put DebugHook into test
Browse files Browse the repository at this point in the history
  • Loading branch information
ccamel committed Sep 23, 2024
1 parent f43a8cd commit c6a535a
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions engine/vm_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package engine

import (
"bytes"
"context"
"os"
"testing"
Expand Down Expand Up @@ -328,3 +329,19 @@ func TestVM_ResetEnv(t *testing.T) {
assert.Equal(t, uint64(20), maxVariables)
})
}

func TestVM_DebugHook(t *testing.T) {
var vm VM
vm.Register0(NewAtom("foo"), func(_ *VM, k Cont, env *Env) *Promise {
return k(env)
})

buf := &bytes.Buffer{}
vm.InstallHook(DebugHookFn(buf))

var env Env
ok, err := Call(&vm, NewAtom("foo"), Success, &env).Force(context.Background())
assert.NoError(t, err)
assert.True(t, ok)
assert.Equal(t, "enter\ncall(foo/0)\nexit\n", buf.String())
}

0 comments on commit c6a535a

Please sign in to comment.