Fix Ripper with heredoc.
This commit is contained in:
parent
562b97e2f0
commit
b84b253a69
Notes:
git
2021-01-17 12:58:39 +09:00
@ -130,6 +130,7 @@ class Ripper
|
|||||||
@buf = []
|
@buf = []
|
||||||
@stack = []
|
@stack = []
|
||||||
super()
|
super()
|
||||||
|
@buf = @stack.pop unless @stack.empty?
|
||||||
if raise_errors and !@errors.empty?
|
if raise_errors and !@errors.empty?
|
||||||
raise SyntaxError, @errors.map(&:message).join(' ;')
|
raise SyntaxError, @errors.map(&:message).join(' ;')
|
||||||
end
|
end
|
||||||
|
@ -90,6 +90,16 @@ 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_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
|
def test_slice
|
||||||
assert_equal "string\#{nil}\n",
|
assert_equal "string\#{nil}\n",
|
||||||
Ripper.slice(%(<<HERE\nstring\#{nil}\nHERE), "heredoc_beg .*? nl $(.*?) heredoc_end", 1)
|
Ripper.slice(%(<<HERE\nstring\#{nil}\nHERE), "heredoc_beg .*? nl $(.*?) heredoc_end", 1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user