Skip to content

Fix postfix if/unless/while/until after heredoc #485

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

Merged
merged 2 commits into from
Aug 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion lib/rdoc/ruby_lex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,7 @@ def identify_here_document(op)
indent: indent,
started: false
}
@lex_state = :EXPR_BEG
@lex_state = :EXPR_END
Token(RDoc::RubyLex::TkHEREDOCBEG, start_token)
end

Expand Down
29 changes: 29 additions & 0 deletions test/test_rdoc_parser_ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2499,6 +2499,35 @@ def blah()
assert_equal markup_code, expected
end

def test_parse_statements_postfix_if_after_heredocbeg
@filename = 'file.rb'
util_parser <<RUBY
class Foo
def blah()
<<~EOM if true
EOM
end
end
RUBY

expected = <<EXPTECTED
<span class="ruby-keyword">def</span> <span class="ruby-identifier">blah</span>()
<span class="ruby-identifier">&lt;&lt;~EOM</span> <span class="ruby-keyword">if</span> <span class="ruby-keyword">true</span>
<span class="ruby-value"></span><span class="ruby-identifier"> EOM
</span> <span class="ruby-keyword">end</span>
EXPTECTED
expected = expected.rstrip

@parser.scan

foo = @top_level.classes.first
assert_equal 'Foo', foo.full_name

blah = foo.method_list.first
markup_code = blah.markup_code.sub(/^.*\n/, '')
assert_equal markup_code, expected
end

def test_parse_require_dynamic_string
content = <<-RUBY
prefix = 'path'
Expand Down