Rewind IO input upon resetting the lexer.

This commit is contained in:
Yorick Peterse 2014-05-26 00:33:20 +02:00
parent c81c6db74e
commit 28edc7726f
2 changed files with 9 additions and 0 deletions

View File

@ -91,6 +91,8 @@ module Oga
@line = 1
@elements = []
@data.rewind if io_input?
reset_native
end

View File

@ -15,5 +15,12 @@ describe Oga::XML::Lexer do
[:T_ELEM_END, nil, 2]
]
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