Rewind IO input upon resetting the lexer.
This commit is contained in:
parent
c81c6db74e
commit
28edc7726f
|
@ -91,6 +91,8 @@ module Oga
|
||||||
@line = 1
|
@line = 1
|
||||||
@elements = []
|
@elements = []
|
||||||
|
|
||||||
|
@data.rewind if io_input?
|
||||||
|
|
||||||
reset_native
|
reset_native
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -15,5 +15,12 @@ describe Oga::XML::Lexer do
|
||||||
[:T_ELEM_END, nil, 2]
|
[:T_ELEM_END, nil, 2]
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
example 'rewind input when resetting the lexer' do
|
||||||
|
lexer = described_class.new(StringIO.new(('<a>foo</a>')))
|
||||||
|
|
||||||
|
lexer.lex.empty?.should == false
|
||||||
|
lexer.lex.empty?.should == false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue