Fix endless loop in test after moving default catch code external

This commit is contained in:
lash 2023-04-06 11:49:52 +01:00
parent 7c1bc78c98
commit 983bac0c53
Signed by untrusted user who does not match committer: lash
GPG Key ID: 21D2E7BB88C2A746

View File

@ -75,7 +75,12 @@ func(r *TestResource) getInput(ctx context.Context) (string, error) {
} }
func(r *TestResource) GetCode(sym string) ([]byte, 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) { func TestRun(t *testing.T) {
@ -83,6 +88,7 @@ func TestRun(t *testing.T) {
rs := TestResource{} rs := TestResource{}
b := NewLine(nil, MOVE, []string{"foo"}, nil, nil) b := NewLine(nil, MOVE, []string{"foo"}, nil, nil)
b = NewLine(b, HALT, nil, nil, nil)
//b := []byte{0x00, MOVE, 0x03} //b := []byte{0x00, MOVE, 0x03}
//b = append(b, []byte("foo")...) //b = append(b, []byte("foo")...)
_, err := Run(b, &st, &rs, context.TODO()) _, err := Run(b, &st, &rs, context.TODO())
@ -282,16 +288,11 @@ func TestRunArgInvalid(t *testing.T) {
st.Down("root") st.Down("root")
b := NewLine(nil, INCMP, []string{"bar", "baz"}, nil, nil) 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()) b, err = Run(b, &st, &rs, context.TODO())
if err != nil { if err != nil {
t.Fatal(err) 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() r := st.Where()
if r != "_catch" { if r != "_catch" {
t.Fatalf("expected where-state _catch, got %v", r) t.Fatalf("expected where-state _catch, got %v", r)