Example #1
0
func readTypeTestScript(scriptPath string) ([]*typeTest, error) {
	script, err := os.Open(scriptPath)
	if err != nil {
		return nil, err
	}
	defer script.Close()

	in := newLineCountReader(strio.NewLineReader(script))

	tests, err := readTypeTests(in)
	if err != nil {
		err = fmt.Errorf("%s:%d:\t%v", scriptPath, in.LineNum()-1, err)
	}

	for _, test := range tests {
		test.loc_ = scriptPath + ":" + test.loc_
	}

	return tests, err
}
Example #2
0
func parseAction(t *testing.T, def string) testAction {
	buf := bytes.NewBufferString(def)
	in := strio.NewLineReader(buf)

	tests, err := readTypeTests(in)
	if err != nil {
		t.Fatalf("unexpected error: %v", err)
	}

	if len(tests) != 1 {
		t.Fatalf("expected 1 parsed tests, got %d", len(tests))
	}

	actions := tests[0].actions()
	if len(actions) != 1 {
		t.Fatalf("expected 1 test action, got %d", len(actions))
	}

	return actions[0]
}
Example #3
0
func newLineReader(s string) strio.LineReader {
	buf := bytes.NewBufferString(s)
	return strio.NewLineReader(buf)
}