Add invalid input node in testdata
This commit is contained in:
parent
a3073f6189
commit
7c1bc78c98
@ -43,12 +43,11 @@ func main() {
|
|||||||
in = strings.TrimSpace(in)
|
in = strings.TrimSpace(in)
|
||||||
running, err = en.Exec([]byte(in), ctx)
|
running, err = en.Exec([]byte(in), ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "execution terminated: %v\n", err)
|
fmt.Fprintf(os.Stderr, "unexpected termination: %v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
b := bytes.NewBuffer(nil)
|
b := bytes.NewBuffer(nil)
|
||||||
en.WriteResult(b)
|
en.WriteResult(b)
|
||||||
fmt.Println(b.String())
|
fmt.Println(b.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
13
go/testdata/testdata.go
vendored
13
go/testdata/testdata.go
vendored
@ -86,13 +86,24 @@ func baz() error {
|
|||||||
return out("baz", b, tpl)
|
return out("baz", b, tpl)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func defaultCatch() error {
|
||||||
|
b := []byte{}
|
||||||
|
b = vm.NewLine(b, vm.MOUT, []string{"0", "back"}, nil, nil)
|
||||||
|
b = vm.NewLine(b, vm.HALT, nil, nil, nil)
|
||||||
|
b = vm.NewLine(b, vm.MOVE, []string{"_"}, nil, nil)
|
||||||
|
|
||||||
|
tpl := "invalid input"
|
||||||
|
|
||||||
|
return out("_catch", b, tpl)
|
||||||
|
}
|
||||||
|
|
||||||
func generate() error {
|
func generate() error {
|
||||||
err := os.MkdirAll(DataDir, 0755)
|
err := os.MkdirAll(DataDir, 0755)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
fns := []genFunc{root, foo, bar, baz}
|
fns := []genFunc{root, foo, bar, baz, defaultCatch}
|
||||||
for _, fn := range fns {
|
for _, fn := range fns {
|
||||||
err = fn()
|
err = fn()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -94,8 +94,6 @@ func RunDeadCheck(b []byte, st *state.State, rs resource.Resource, ctx context.C
|
|||||||
return b, fmt.Errorf("dead runner with no current location")
|
return b, fmt.Errorf("dead runner with no current location")
|
||||||
}
|
}
|
||||||
b = NewLine(nil, MOVE, []string{"_catch"}, nil, nil)
|
b = NewLine(nil, MOVE, []string{"_catch"}, nil, nil)
|
||||||
b = NewLine(b, HALT, nil, nil, nil)
|
|
||||||
b = NewLine(b, MOVE, []string{location}, nil, nil)
|
|
||||||
log.Printf("code is now %x", b)
|
log.Printf("code is now %x", b)
|
||||||
return b, nil
|
return b, nil
|
||||||
}
|
}
|
||||||
@ -180,7 +178,12 @@ func RunMove(b []byte, st *state.State, rs resource.Resource, ctx context.Contex
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return b, err
|
return b, err
|
||||||
}
|
}
|
||||||
st.Down(sym)
|
if sym == "_" {
|
||||||
|
st.Up()
|
||||||
|
sym = st.Where()
|
||||||
|
} else {
|
||||||
|
st.Down(sym)
|
||||||
|
}
|
||||||
code, err := rs.GetCode(sym)
|
code, err := rs.GetCode(sym)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return b, err
|
return b, err
|
||||||
|
Loading…
Reference in New Issue
Block a user