require File.join(File.dirname(__FILE__), 'preamble') require 'html5lib/liberalxmlparser' XMLELEM = /<(\w+\s*)((?:[-:\w]+="[^"]*"\s*)+)(\/?)>/ SORTATTRS = '<#{$1+$2.split.sort.join(' ')+$3}>' def assert_xml_equal(input, expected=nil, parser=HTML5lib::XMLParser) document = parser.parse(input.chomp).root if not expected expected = input.chomp.gsub(XMLELEM,SORTATTRS) expected = expected.gsub(/(\d+);/) {[$1.to_i].pack('U')} 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=HTML5lib::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( '