Index: src/0dev.org/parse/parse_test.go ================================================================== --- src/0dev.org/parse/parse_test.go +++ src/0dev.org/parse/parse_test.go @@ -6,19 +6,19 @@ func TestAccept(t *testing.T) { // Accept(0) will always match :) p0 := Accept(0) if n, r := p0(""); !n.Matched || n.Content != "" || n.Nodes != nil || r != "" { - t.Error("Invalid result for Accept's negative test", n) + t.Error("Invalid result for Accept empty match test", n) } // Test with a non-zero amount of bytes p := Accept(1) if n, r := p(""); n.Matched || n.Content != "" || n.Nodes != nil || r != "" { - t.Error("Invalid result for Accept's negative test", n) + t.Error("Invalid result for Accept no-match test", n) } if n, r := p("a"); !n.Matched || n.Content != "a" || n.Nodes != nil || r != "" { - t.Error("Invalid result for Accept's positive test", n) + t.Error("Invalid result for Accept match test", n) } } func TestK(t *testing.T) { p := Accept(1) @@ -53,10 +53,21 @@ } if n, r := a("aa"); !n.Matched || n.Content != "a" || n.Nodes != nil || r != "a" { t.Error("Invalid result for Any match test", n) } } + +func TestDefer(t *testing.T) { + d, dp := Defer() + *dp = Accept(1) + if n, r := d(""); n.Matched || n.Content != "" || n.Nodes != nil || r != "" { + t.Error("Invalid result for Defer no-match test", n) + } + if n, r := d("a"); !n.Matched || n.Content != "a" || n.Nodes != nil || r != "" { + t.Error("Invalid result for Defer match test", n) + } +} func TestString(t *testing.T) { s := String("aa") if n, r := s("aa"); !n.Matched || n.Content != "aa" || n.Nodes != nil || r != "" { t.Error("Invalid result for String match test", n)