Add display initial to engine execution
This commit is contained in:
@@ -32,8 +32,11 @@ func NewEngine(st *state.State, rs resource.Resource) Engine {
|
||||
//
|
||||
// It makes sure bootstrapping code has been executed, and that the exposed bytecode is ready for user input.
|
||||
func(en *Engine) Init(sym string, ctx context.Context) error {
|
||||
err := en.st.SetInput([]byte{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
b := vm.NewLine(nil, vm.MOVE, []string{sym}, nil, nil)
|
||||
var err error
|
||||
b, err = vm.Run(b, en.st, en.rs, ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -61,7 +64,7 @@ func (en *Engine) Exec(input []byte, ctx context.Context) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
log.Printf("new execution with input 0x%x (%v)", input, len(input))
|
||||
log.Printf("new execution with input '%s' (0x%x)", input, input)
|
||||
code, err := en.st.GetCode()
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -88,8 +88,12 @@ func TestEngineInit(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
b := w.Bytes()
|
||||
if !bytes.Equal(b, []byte("hello world")) {
|
||||
t.Fatalf("expected result 'hello world', got %v", b)
|
||||
expect_str := `hello world
|
||||
1:do the foo
|
||||
2:go to the bar`
|
||||
|
||||
if !bytes.Equal(b, []byte(expect_str)) {
|
||||
t.Fatalf("expected:\n\t%s\ngot:\n\t%s\n", expect_str, b)
|
||||
}
|
||||
|
||||
input := []byte("1")
|
||||
|
||||
Reference in New Issue
Block a user