Skip to content

Commit

Permalink
Merge pull request #794 from moofkit/heredoc_ending_not_same_line
Browse files Browse the repository at this point in the history
adds SyntaxError and warning spec for not same line heredoc
  • Loading branch information
andrykonchin authored Oct 9, 2020
2 parents bc19421 + 65d0092 commit 04716a5
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions language/heredoc_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,22 @@
s.encoding.should == Encoding::US_ASCII
end

ruby_version_is "2.7" do
it 'raises SyntaxError if quoted HEREDOC identifier is ending not on same line' do
-> {
eval %{<<"HERE\n"\nraises syntax error\nHERE}
}.should raise_error(SyntaxError)
end
end

ruby_version_is ""..."2.7" do
it 'prints a warning if quoted HEREDOC identifier is ending not on same line' do
-> {
eval %{<<"HERE\n"\nit warns\nHERE}
}.should complain(/here document identifier ends with a newline/)
end
end

it "allows HEREDOC with <<~'identifier', allowing to indent identifier and content" do
require_relative 'fixtures/squiggly_heredoc'
SquigglyHeredocSpecs.message.should == "character density, n.:\n The number of very weird people in the office.\n"
Expand Down

0 comments on commit 04716a5

Please sign in to comment.