diff options
author | Robert Griesemer <gri@golang.org> | 2018-02-14 16:59:36 -0800 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2018-02-15 01:48:21 +0000 |
commit | eda39fe9b2bdae054a6d0b93efb9b40cc9d24391 (patch) | |
tree | d5f20329ea31440dd98871d6cab46d8e89e41c72 /src/cmd/compile/internal/syntax/printer_test.go | |
parent | 1a2273874953517cc38f7005e985c91d16ebf33c (diff) | |
download | go-eda39fe9b2bdae054a6d0b93efb9b40cc9d24391.tar.gz go-eda39fe9b2bdae054a6d0b93efb9b40cc9d24391.zip |
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>
Diffstat (limited to 'src/cmd/compile/internal/syntax/printer_test.go')
-rw-r--r-- | src/cmd/compile/internal/syntax/printer_test.go | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/cmd/compile/internal/syntax/printer_test.go b/src/cmd/compile/internal/syntax/printer_test.go index c218924202..6f19846e22 100644 --- a/src/cmd/compile/internal/syntax/printer_test.go +++ b/src/cmd/compile/internal/syntax/printer_test.go @@ -16,12 +16,16 @@ func TestPrint(t *testing.T) { t.Skip("skipping test in short mode") } - ast, err := ParseFile(*src_, nil, nil, 0) + // provide a dummy error handler so parsing doesn't stop after first error + ast, err := ParseFile(*src_, func(error) {}, nil, 0) if err != nil { - t.Fatal(err) + t.Error(err) + } + + if ast != nil { + Fprint(os.Stdout, ast, true) + fmt.Println() } - Fprint(os.Stdout, ast, true) - fmt.Println() } func TestPrintString(t *testing.T) { |