コード例 #1
0
ファイル: suite_test.go プロジェクト: katydid/katydid
func test(t *testing.T, name string, g *ast.Grammar, p parser.Interface, expected bool, desc string, record bool) {
	if interp.HasRecursion(g) {
		t.Skipf("convert was not designed to handle recursion")
	}
	if strings.HasPrefix(name, "GoBigOr") {
		t.Skipf("too big to fail: the number of Ors creates a state space explosion")
	}
	var a *auto.Auto
	var err error
	if record {
		a, err = auto.CompileRecord(g)
	} else {
		a, err = auto.Compile(g)
	}
	if err != nil {
		t.Fatal(err)
	}
	match, err := a.Validate(p)
	if err != nil {
		t.Fatal(err)
	}
	if match != expected {
		t.Fatalf("Expected %v on given \n%s\n on \n%s", expected, g.String(), desc)
	}
}
コード例 #2
0
ファイル: suite_test.go プロジェクト: katydid/katydid
func test(t *testing.T, g *ast.Grammar, p parser.Interface, expected bool, desc string) {
	if interp.HasRecursion(g) {
		t.Skipf("interp was not designed to handle left recursion")
	}
	p = debug.NewLogger(p, debug.NewLineLogger())
	match, err := interp.Interpret(g, p)
	if err != nil {
		t.Fatal(err)
	}
	if match != expected {
		t.Fatalf("Expected %v on given \n%s\n on \n%s", expected, g.String(), desc)
	}
}
コード例 #3
0
ファイル: suite_test.go プロジェクト: katydid/katydid
func test(t *testing.T, g *ast.Grammar, p parser.Interface, expected bool, desc string, record bool) {
	if interp.HasRecursion(g) {
		t.Skipf("interp was not designed to handle left recursion")
	}
	var m *mem.Mem
	var err error
	if record {
		m, err = mem.NewRecord(g)
	} else {
		m, err = mem.New(g)
	}
	if err != nil {
		t.Fatal(err)
	}
	match, err := m.Validate(p)
	if err != nil {
		t.Fatal(err)
	}
	if match != expected {
		t.Fatalf("Expected %v on given \n%s\n on \n%s", expected, g.String(), desc)
	}
}