1 # tests for heredocs besides what is tested in base/lex.t
13 # heredoc without newline (#65838)
15 my $string = <<'HEREDOC';
19 my $code = "<<'HEREDOC';\n${string}HEREDOC"; # HD w/o newline, in eval-string
20 my $hd = eval $code or warn "$@ ---";
21 is($hd, $string, "no terminating newline in string-eval");
27 my $string = "testing for 65838";
30 "print <<'HEREDOC';\n${string}\nHEREDOC",
33 "heredoc at EOF without trailing newline"
37 "print <<;\n$string\n",
39 { switches => ['-X'] },
40 "blank-terminated heredoc at EOF"
43 "print <<\n$string\n",
45 { switches => ['-X'] },
46 "blank-terminated heredoc at EOF and no semicolon"
49 "print <<foo\r\nick and queasy\r\nfoo\r\n",
51 { switches => ['-X'] },
52 "crlf-terminated heredoc"
55 "print qq|\${\\<<foo}|\nick and queasy\nfoo\n",
57 { switches => ['-w'], stderr => 1 },
58 'no warning for qq|${\<<foo}| in file'
63 # here-doc parse failures
66 "print <<HEREDOC;\nwibble\n HEREDOC",
67 qr/find string terminator/,
69 "string terminator must start at newline"
73 "print <<;\nno more newlines",
74 qr/find string terminator/,
75 { switches => ['-X'] },
76 "empty string terminator still needs a newline"
80 "print <<ThisTerminatorIsLongerThanTheData;\nno more newlines",
81 qr/find string terminator/,
83 "long terminator fails correctly"