mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile/internal/syntax: fix syntax.Parse doc string, improved tests
1) Fix the doc string for syntax.Parse: The returned AST is always nil if there was an error and an error handler is missing. 2) Adjust the syntax Print and Dump tests such that they print and dump the AST even in the presence of errors. Change-Id: If658eabdcc83f578d815070bc65d1a5f6cfaddfc Reviewed-on: https://go-review.googlesource.com/94157 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
1a22738749
commit
eda39fe9b2
4 changed files with 22 additions and 13 deletions
|
|
@ -14,9 +14,13 @@ func TestDump(t *testing.T) {
|
|||
t.Skip("skipping test in short mode")
|
||||
}
|
||||
|
||||
ast, err := ParseFile(*src_, nil, nil, CheckBranches)
|
||||
// provide a dummy error handler so parsing doesn't stop after first error
|
||||
ast, err := ParseFile(*src_, func(error) {}, nil, CheckBranches)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if ast != nil {
|
||||
Fdump(os.Stdout, ast)
|
||||
}
|
||||
Fdump(os.Stdout, ast)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue