Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds SyntaxError and warning spec for not same line heredoc #794

Merged
merged 3 commits into from
Oct 9, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 identifier is ending not on same line' do
-> {
eval %{<<"HERE\n"\nHERE}
}.should raise_error(SyntaxError)
end
end

ruby_version_is ""..."2.7" do
it 'prints a warning if identifier is ending not on same line' do
Copy link
Member

@andrykonchin andrykonchin Oct 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's missing "quoted identifier"

-> {
eval %{<<"HERE\n"\nHERE}
}.should complain(/here document identifier ends with a newline/)
end
end
Copy link
Member

@andrykonchin andrykonchin Oct 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wording issue. It's common to write just it warns or emits a warning here in the specs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean add the message in heredoc string itself?
If so, check please. I've just added it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No-no. I meant the wording in the spec description - it 'prints a warning. It's not a problem and it's just a matter of taste .


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