コード例 #1
0
ファイル: execute_test.go プロジェクト: javachengwc/many-ql
func TestCyclicDependencies(t *testing.T) {
	defer func() {
		recover()
	}()
	form := parser.ReadQL(
		strings.NewReader(`
		form SomeForm {
			"QuestionLabel" question1 string

			if(question3){
				"question2" question2 bool
			}

			if(question2){
				"question3" question3 bool
			}
		}
		`),
		"test.ql",
	)
	tc, st := New()
	tc.QuestionaireNode(form)
	if err := st.Err(); err == nil {
		t.Errorf("Typecheck error: cyclic dependencies should trigger error")
	}
}
コード例 #2
0
ファイル: utils.go プロジェクト: javachengwc/many-ql
func startInterpreter(srcReader io.Reader, srcFn string) (pipes *plumbing.Pipes,
	guiAppName string,
) {
	aQuestionaire := parser.ReadQL(srcReader, srcFn)
	pipes = interpreter.New(aQuestionaire)
	guiAppName = aQuestionaire.Label()
	return pipes, guiAppName
}
コード例 #3
0
ファイル: execute_test.go プロジェクト: javachengwc/many-ql
func TestDuplicatedIdentifier(t *testing.T) {
	form := parser.ReadQL(
		strings.NewReader(`form SomeForm {
			"QuestionLabel" question1 string
			"QuestionLabel" question1 string
		}`),
		"test.ql",
	)
	tc, st := New()
	tc.QuestionaireNode(form)
	if err := st.Err(); err == nil {
		t.Errorf("Typecheck error: duplicated identifiers should trigger error")
	}
}
コード例 #4
0
ファイル: execute_test.go プロジェクト: javachengwc/many-ql
func TestRepeatedCaptions(t *testing.T) {
	form := parser.ReadQL(
		strings.NewReader(`form SomeForm {
			"QuestionLabel" question1 string
			"QuestionLabel" question2 numeric
		}`),
		"test.ql",
	)
	tc, st := New()
	tc.QuestionaireNode(form)
	if warn := st.Warn(); warn == nil {
		t.Errorf("Typecheck error: duplicated captions should trigger warnings")
	}
}
コード例 #5
0
ファイル: execute_test.go プロジェクト: javachengwc/many-ql
func TestInvalidOperands(t *testing.T) {
	defer func() {
		recover()
	}()
	form := parser.ReadQL(
		strings.NewReader(`form SomeForm {
			"QuestionLabel" question1 string
			if (question1 + "string"){}
		}`),
		"test.ql",
	)
	tc, st := New()
	tc.QuestionaireNode(form)
	if err := st.Err(); err == nil {
		t.Errorf("Typecheck error: invalid operations should trigger error")
	}
}
コード例 #6
0
ファイル: execute_test.go プロジェクト: javachengwc/many-ql
func TestDuplicatedIdentifierInIfBlocks(t *testing.T) {
	form := parser.ReadQL(
		strings.NewReader(`form SomeForm {
			"QuestionLabel" question1 bool
			if (question1){
				"QuestionLabel2 - True" question2 string
			}
			if (!question1){
				"QuestionLabel2 - False" question2 string
			}
		}`),
		"test.ql",
	)
	tc, st := New()
	tc.QuestionaireNode(form)
	if err := st.Err(); err == nil {
		t.Errorf("Typecheck error: duplicated identifiers should trigger error")
	}
}
コード例 #7
0
func runForm(source string) *plumbing.Pipes {
	form := parser.ReadQL(strings.NewReader(source), "test.ql")
	return New(form)
}