Skip to content

Commit

Permalink
syntax: cover "EOF immediately after heredoc" in Stmts via a test
Browse files Browse the repository at this point in the history
We had a test for it for Parse, but not for Stmts.
  • Loading branch information
mvdan committed Feb 23, 2025
1 parent 4355e90 commit 623352b
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions syntax/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2156,19 +2156,25 @@ func TestParseStmtsStopEarly(t *testing.T) {

func TestParseStmtsError(t *testing.T) {
t.Parallel()
in := "foo; )"
p := NewParser()
recv := make(chan bool, 10)
errc := make(chan error, 1)
go func() {
errc <- p.Stmts(strings.NewReader(in), func(s *Stmt) bool {
recv <- true
return true
for _, in := range []string{
"foo; )",
"bar; <<EOF",
} {
t.Run("", func(t *testing.T) {
p := NewParser()
recv := make(chan bool, 10)
errc := make(chan error, 1)
go func() {
errc <- p.Stmts(strings.NewReader(in), func(s *Stmt) bool {
recv <- true
return true
})
}()
<-recv
if err := <-errc; err == nil {
t.Fatalf("Expected an error in %q, but got nil", in)
}
})
}()
<-recv
if err := <-errc; err == nil {
t.Fatalf("Expected an error in %q, but got nil", in)
}
}

Expand Down

0 comments on commit 623352b

Please sign in to comment.