aboutsummaryrefslogtreecommitdiff
path: root/src/go/parser/parser_test.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2019-09-17 16:32:11 -0700
committerRobert Griesemer <gri@golang.org>2019-09-18 04:47:40 +0000
commit99aa56a437be4f72da2eefd2cce1c09fe8d7c201 (patch)
tree56113461ce06a8586aa1a29886dff0309b771f2d /src/go/parser/parser_test.go
parentd55cf5b80cf3232bdc2793a8362f9acd8a6f8442 (diff)
downloadgo-99aa56a437be4f72da2eefd2cce1c09fe8d7c201.tar.gz
go-99aa56a437be4f72da2eefd2cce1c09fe8d7c201.zip
go/parser: return partial result from ParseExpr in case of error
Remove redundant code and improve documentation in the process. Fixes #34211. Change-Id: I9a6d1467f1a2c98a163f41f9df147fc6500c6fad Reviewed-on: https://go-review.googlesource.com/c/go/+/196077 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/go/parser/parser_test.go')
-rw-r--r--src/go/parser/parser_test.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/go/parser/parser_test.go b/src/go/parser/parser_test.go
index 18c05bce20..25a374eeef 100644
--- a/src/go/parser/parser_test.go
+++ b/src/go/parser/parser_test.go
@@ -108,9 +108,16 @@ func TestParseExpr(t *testing.T) {
// an invalid expression
src = "a + *"
- if _, err := ParseExpr(src); err == nil {
+ x, err = ParseExpr(src)
+ if err == nil {
t.Errorf("ParseExpr(%q): got no error", src)
}
+ if x == nil {
+ t.Errorf("ParseExpr(%q): got no (partial) result", src)
+ }
+ if _, ok := x.(*ast.BinaryExpr); !ok {
+ t.Errorf("ParseExpr(%q): got %T, want *ast.BinaryExpr", src, x)
+ }
// a valid expression followed by extra tokens is invalid
src = "a[i] := x"