go-vise

Constrained Size Output Virtual Machine
Info | Log | Files | Refs | README | LICENSE

commit 983bac0c5383c592e332b5d015c2e535aaa75b40
parent 7c1bc78c986bfae7e4308c84549e464fd8972fd0
Author: lash <dev@holbrook.no>
Date:   Thu,  6 Apr 2023 11:49:52 +0100

Fix endless loop in test after moving default catch code external

Diffstat:
Mgo/vm/runner_test.go | 13+++++++------
1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/go/vm/runner_test.go b/go/vm/runner_test.go @@ -75,7 +75,12 @@ func(r *TestResource) getInput(ctx context.Context) (string, error) { } func(r *TestResource) GetCode(sym string) ([]byte, error) { - return []byte{}, nil + var b []byte + if sym == "_catch" { + b = NewLine(b, MOUT, []string{"0", "repent"}, nil, nil) + b = NewLine(b, HALT, nil, nil, nil) + } + return b, nil } func TestRun(t *testing.T) { @@ -83,6 +88,7 @@ func TestRun(t *testing.T) { rs := TestResource{} b := NewLine(nil, MOVE, []string{"foo"}, nil, nil) + b = NewLine(b, HALT, nil, nil, nil) //b := []byte{0x00, MOVE, 0x03} //b = append(b, []byte("foo")...) _, err := Run(b, &st, &rs, context.TODO()) @@ -282,16 +288,11 @@ func TestRunArgInvalid(t *testing.T) { st.Down("root") b := NewLine(nil, INCMP, []string{"bar", "baz"}, nil, nil) - //b = NewLine(b, CATCH, []string{"_catch"}, []byte{state.FLAG_INMATCH}, []uint8{1}) b, err = Run(b, &st, &rs, context.TODO()) if err != nil { t.Fatal(err) } - expect := NewLine(nil, MOVE, []string{"root"}, nil, nil) - if !bytes.Equal(b, expect) { - t.Fatalf("expected:\n\t%x\ngot:\b\t%x\n", expect, b) - } r := st.Where() if r != "_catch" { t.Fatalf("expected where-state _catch, got %v", r)