ruby/test/rexml/parser/test_stream.rb
nagachika 3fd2cbecff merge revision(s) 59033,59034: [Backport #13636]
rexml: add close tag check on end of document to StreamParser

	[ruby-core:81593] [Bug #13636]

	Reported by Anton Sivakov. Thanks!!!

	* properties.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@59399 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-23 07:33:07 +00:00

32 lines
726 B
Ruby

require "test/unit"
require "rexml/document"
require "rexml/streamlistener"
module REXMLTests
class TestStreamParser < Test::Unit::TestCase
class NullListener
include REXML::StreamListener
end
class TestInvalid < self
def test_no_end_tag
xml = "<root><sub>"
exception = assert_raise(REXML::ParseException) do
parse(xml)
end
assert_equal(<<-MESSAGE, exception.to_s)
Missing end tag for '/root/sub'
Line: 1
Position: #{xml.bytesize}
Last 80 unconsumed characters:
MESSAGE
end
private
def parse(xml, listener=nil)
listener ||= NullListener.new
REXML::Document.parse_stream(xml, listener)
end
end
end
end