Example #1
0
func check(t *testing.T, code string, expected_out string, expected_err string) {
	out, err := eval.Eval(code)
	if !(ts(expected_out) == ts(out)) {
		t.Error(fmt.Sprintf("Expected output to be \n%s\nInstead got:\n%s\n", out, expected_out))
	}
	if !(ts(expected_err) == ts(err)) {
		t.Error(fmt.Sprintf("Expected compiler error to be \n%s\n. Instead got:\n%s\n", err, expected_err))
	}
}
Example #2
0
File: gore.go Project: wlan0/gore
func main() {
	var src string
	if len(os.Args) > 1 {
		src = os.Args[1]
	} else {
		fmt.Println("Enter one or more lines and hit ctrl-D")
		src = readStdin()
	}

	out, err := eval.Eval(src)
	if err == "" {
		println("---------------------------------")
		println(out)
	} else {
		fmt.Println("== Error ========")
		fmt.Println(err)
	}
}