コード例 #1
0
ファイル: json_test.go プロジェクト: javachengwc/many-ql
func TestJSONInputFrontend(t *testing.T) {
	pipes := plumbing.New()
	buf := new(bytes.Buffer)
	go fakeInterpreter(pipes)

	Write(pipes, buf)

	if got := buf.String(); got != expectedJSON {
		t.Error(
			"Error generating output JSON file. Expected "+expectedJSON+" rows. Got:",
			got,
		)
	}
}
コード例 #2
0
ファイル: csv_test.go プロジェクト: javachengwc/many-ql
func TestCsvInputFrontend(t *testing.T) {
	pipes := plumbing.New()
	buf := new(bytes.Buffer)
	go fakeInterpreter(pipes)

	Write(pipes, buf)

	if got := buf.String(); got != expectedCsv {
		t.Error(
			"Error generating output CSV file. Expected Q1,A question,No rows. Got:",
			got,
		)
	}
}
コード例 #3
0
ファイル: json_test.go プロジェクト: javachengwc/many-ql
func TestJSONinputFrontend(t *testing.T) {
	pipes := plumbing.New()
	expectedAnswers := make(chan map[string]string)
	fakeInterpreter(pipes, expectedAnswers)

	go Read(pipes, strings.NewReader(fakeCsv))

	got := <-expectedAnswers
	rowcount := len(got)
	if rowcount != 2 {
		t.Error(
			"Error parsing input JSON file. Expected 2 rows. Got:",
			rowcount,
		)
	}
}
コード例 #4
0
ファイル: interpreter.go プロジェクト: javachengwc/many-ql
// New starts interpreter with an AST (*ast.Questionaire) and with
// channels to communicate with Frontend process.
func New(q *ast.QuestionaireNode) *plumbing.Pipes {
	typecheck(q)

	pipes := plumbing.New()
	st := symboltable.New()

	v := &interpreter{
		questionaire: q,
		send:         pipes.ToFrontend(),
		receive:      pipes.FromFrontend(),
		execute:      execute.New(pipes.ToFrontend(), st),
		draw:         draw.New(pipes.ToFrontend()),
		symbols:      st,
	}
	go v.loop()

	return pipes
}