func runTest(t *testing.T, name string, lineNum int, input, output []string) bool { shouldFail := strings.HasSuffix(name, "_fail.ivy") mobile.Reset() in := strings.Join(input, "\n") result, err := mobile.Eval(in) if shouldFail { if err == nil { t.Fatalf("\nexpected execution failure at %s:%d:\n%s", name, lineNum, in) } return true } if err != nil { t.Fatalf("\nexecution failure (%s) at %s:%d:\n%s", err, name, lineNum, in) } return true if shouldFail { return true } if !equal(strings.Split(result, "\n"), output) { t.Errorf("\n%s:%d:\n%s\ngot:\n%swant:\n%s", name, lineNum, strings.Join(input, "\n"), result, strings.Join(output, "\n")) return false } return true }
func ivyHandler(ctx context.Context, w hugot.ResponseWriter, m *hugot.Message) error { m.Parse() out, err := ivy.Eval(strings.Join(m.Args(), " ") + "\n") if err != nil { return err } fmt.Fprint(w, out) return nil }