require File.join(File.dirname(__FILE__), 'preamble') require 'html5/liberalxmlparser' XMLELEM = /<(\w+\s*)((?:[-:\w]+="[^"]*"\s*)+)(\/?)>/ def assert_xml_equal(input, expected=nil, parser=HTML5::XMLParser) sortattrs = proc {"<#{$1+$2.split.sort.join(' ')+$3}>"} document = parser.parse(input.chomp, :lowercase_attr_name => false, :lowercase_element_name => false).root if not expected expected = input.chomp.gsub(XMLELEM,&sortattrs) if expected.respond_to? :force_encoding expected = expected.gsub(/(\d+);/) {$1.to_i.chr('utf-8')} else expected = expected.gsub(/(\d+);/) {[$1.to_i].pack('U')} end output = document.to_s.gsub(/'/,'"').gsub(XMLELEM,&sortattrs) assert_equal(expected, output) else assert_equal(expected, document.to_s.gsub(/'/,'"')) end end def assert_xhtml_equal(input, expected=nil, parser=HTML5::XHTMLParser) assert_xml_equal(input, expected, parser) end class BasicXhtml5Test < Test::Unit::TestCase def test_title_body_mismatched_close assert_xhtml_equal( '
foo
","foo
") end def test_optional_close assert_xml_equal("foo","
foo
") end def test_html_mismatched assert_xml_equal("foo","foo") end end class OpmlTest < Test::Unit::TestCase def test_mixedCaseElement assert_xml_equal( '