[ruby/erb] Fix line numbers after multi-line <%#

(https://github.com/ruby/erb/pull/42)

https://github.com/ruby/erb/commit/526885923e
This commit is contained in:
Takashi Kokubun 2022-11-28 20:55:58 -08:00 committed by git
parent b5726892d0
commit 129d208f9a
2 changed files with 13 additions and 1 deletions

View File

@ -384,7 +384,7 @@ class ERB::Compiler # :nodoc:
when '<%='
add_insert_cmd(out, content)
when '<%#'
# commented out
out.push("\n" * content.count("\n")) # only adjust lineno
end
end

View File

@ -713,6 +713,18 @@ EOS
erb = Marshal.load(Marshal.dump(erb))
assert_raise(ArgumentError) {erb.result}
end
def test_multi_line_comment_lineno
erb = ERB.new(<<~EOS)
<%= __LINE__ %>
<%#
%><%= __LINE__ %>
EOS
assert_equal <<~EOS, erb.result
1
3
EOS
end
end
class TestERBCoreWOStrScan < TestERBCore