mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Fix Ripper with heredoc.
This commit is contained in:
parent
562b97e2f0
commit
b84b253a69
Notes:
git
2021-01-17 12:58:39 +09:00
2 changed files with 11 additions and 0 deletions
|
@ -130,6 +130,7 @@ class Ripper
|
|||
@buf = []
|
||||
@stack = []
|
||||
super()
|
||||
@buf = @stack.pop unless @stack.empty?
|
||||
if raise_errors and !@errors.empty?
|
||||
raise SyntaxError, @errors.map(&:message).join(' ;')
|
||||
end
|
||||
|
|
|
@ -90,6 +90,16 @@ class TestRipper::Lexer < Test::Unit::TestCase
|
|||
assert_equal expect, Ripper.lex(src).map {|e| e[1]}
|
||||
end
|
||||
|
||||
def test_stack_at_on_heredoc_beg
|
||||
src = "a <<b"
|
||||
expect = %I[
|
||||
on_ident
|
||||
on_sp
|
||||
on_heredoc_beg
|
||||
]
|
||||
assert_equal expect, Ripper.lex(src).map {|e| e[1]}
|
||||
end
|
||||
|
||||
def test_slice
|
||||
assert_equal "string\#{nil}\n",
|
||||
Ripper.slice(%(<<HERE\nstring\#{nil}\nHERE), "heredoc_beg .*? nl $(.*?) heredoc_end", 1)
|
||||
|
|
Loading…
Reference in a new issue