parse.y: indent at '#'
* parse.y (parser_here_document): update indent at '#', which is not a space. [ruby-core:83368] [Bug #14032] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60213 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0e7936f896
commit
8b501f6d7f
6
parse.y
6
parse.y
@ -6732,6 +6732,12 @@ parser_here_document(struct parser_params *parser, NODE *here)
|
|||||||
newtok();
|
newtok();
|
||||||
if (c == '#') {
|
if (c == '#') {
|
||||||
int t = parser_peek_variable_name(parser);
|
int t = parser_peek_variable_name(parser);
|
||||||
|
if (heredoc_line_indent != -1) {
|
||||||
|
if (heredoc_indent > heredoc_line_indent) {
|
||||||
|
heredoc_indent = heredoc_line_indent;
|
||||||
|
}
|
||||||
|
heredoc_line_indent = -1;
|
||||||
|
}
|
||||||
if (t) return t;
|
if (t) return t;
|
||||||
tokadd('#');
|
tokadd('#');
|
||||||
c = nextc();
|
c = nextc();
|
||||||
|
@ -70,4 +70,24 @@ class TestRipper::Lexer < Test::Unit::TestCase
|
|||||||
]
|
]
|
||||||
assert_equal expect, Ripper.lex(src).map {|e| e[1]}
|
assert_equal expect, Ripper.lex(src).map {|e| e[1]}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_expr_at_beginning_in_heredoc
|
||||||
|
src = <<~'E'
|
||||||
|
<<~B
|
||||||
|
a
|
||||||
|
#{1}
|
||||||
|
B
|
||||||
|
E
|
||||||
|
expect = %I[
|
||||||
|
on_heredoc_beg
|
||||||
|
on_nl
|
||||||
|
on_tstring_content
|
||||||
|
on_embexpr_beg
|
||||||
|
on_int
|
||||||
|
on_embexpr_end
|
||||||
|
on_tstring_content
|
||||||
|
on_heredoc_end
|
||||||
|
]
|
||||||
|
assert_equal expect, Ripper.lex(src).map {|e| e[1]}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -659,6 +659,14 @@ e"
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_dedented_heredoc_expr_at_beginning
|
||||||
|
result = " a\n" \
|
||||||
|
'#{1}'"\n"
|
||||||
|
expected = " a\n" \
|
||||||
|
'#{1}'"\n"
|
||||||
|
assert_dedented_heredoc(expected, result)
|
||||||
|
end
|
||||||
|
|
||||||
def test_lineno_after_heredoc
|
def test_lineno_after_heredoc
|
||||||
bug7559 = '[ruby-dev:46737]'
|
bug7559 = '[ruby-dev:46737]'
|
||||||
expected, _, actual = __LINE__, <<eom, __LINE__
|
expected, _, actual = __LINE__, <<eom, __LINE__
|
||||||
|
Loading…
x
Reference in New Issue
Block a user