scanner: Add tests demonstrating issue with empty heredoc anchors.
This commit is contained in:
parent
061bf373e4
commit
8bad6ac32e
@ -155,6 +155,7 @@ func TestFormatValidOutput(t *testing.T) {
|
|||||||
"#\ue123t",
|
"#\ue123t",
|
||||||
"Y=<<4\n4/\n\n\n/4/@=4/\n\n\n/4000000004\r\r\n00004\n",
|
"Y=<<4\n4/\n\n\n/4/@=4/\n\n\n/4000000004\r\r\n00004\n",
|
||||||
"x=<<_\n_\r\r\n_\n",
|
"x=<<_\n_\r\r\n_\n",
|
||||||
|
"X=<<-\n\r\r\n",
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, c := range cases {
|
for _, c := range cases {
|
||||||
|
@ -531,6 +531,9 @@ func TestError(t *testing.T) {
|
|||||||
testError(t, `"${abc`+"\n", "2:1", "literal not terminated", token.STRING)
|
testError(t, `"${abc`+"\n", "2:1", "literal not terminated", token.STRING)
|
||||||
testError(t, `/*/`, "1:4", "comment not terminated", token.COMMENT)
|
testError(t, `/*/`, "1:4", "comment not terminated", token.COMMENT)
|
||||||
testError(t, `/foo`, "1:1", "expected '/' for comment", token.COMMENT)
|
testError(t, `/foo`, "1:1", "expected '/' for comment", token.COMMENT)
|
||||||
|
|
||||||
|
testError(t, "<<\nfoo\n\n", "1:3", "zero-length heredoc anchor", token.HEREDOC)
|
||||||
|
testError(t, "<<-\nfoo\n\n", "1:4", "zero-length heredoc anchor", token.HEREDOC)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testError(t *testing.T, src, pos, msg string, tok token.Type) {
|
func testError(t *testing.T, src, pos, msg string, tok token.Type) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user