Fix Busted Functional Tests
Fix the functional tests busted by Revision 212. Sync with latest HTML5lib.
This commit is contained in:
parent
51474e06c8
commit
5db9ddaf47
12 changed files with 67 additions and 30 deletions
6
vendor/plugins/HTML5lib/test/test_lxp.rb
vendored
6
vendor/plugins/HTML5lib/test/test_lxp.rb
vendored
|
@ -9,7 +9,11 @@ def assert_xml_equal(input, expected=nil, parser=HTML5::XMLParser)
|
|||
document = parser.parse(input.chomp, :lowercase_attr_name => false, :lowercase_element_name => false).root
|
||||
if not expected
|
||||
expected = input.chomp.gsub(XMLELEM,&sortattrs)
|
||||
expected = expected.gsub(/&#(\d+);/) {[$1.to_i].pack('U')}
|
||||
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
|
||||
|
|
|
@ -12,11 +12,11 @@ class SanitizeTest < Test::Unit::TestCase
|
|||
include HTML5
|
||||
|
||||
def sanitize_xhtml stream
|
||||
XHTMLParser.parse_fragment(stream, {:tokenizer => HTMLSanitizer, :encoding => 'utf-8', :lowercase_element_name => false, :lowercase_attr_name => false}).to_s
|
||||
XHTMLParser.parse_fragment(stream, {:tokenizer => HTMLSanitizer, :encoding => 'utf-8', :lowercase_element_name => false, :lowercase_attr_name => false}).join
|
||||
end
|
||||
|
||||
def sanitize_html stream
|
||||
HTMLParser.parse_fragment(stream, {:tokenizer => HTMLSanitizer, :encoding => 'utf-8', :lowercase_element_name => false, :lowercase_attr_name => false}).to_s
|
||||
HTMLParser.parse_fragment(stream, {:tokenizer => HTMLSanitizer, :encoding => 'utf-8', :lowercase_element_name => false, :lowercase_attr_name => false}).join
|
||||
end
|
||||
|
||||
def sanitize_rexml stream
|
||||
|
|
|
@ -50,7 +50,7 @@ class Html5SerializeTestcase < Test::Unit::TestCase
|
|||
flunk("Expected: #{expected.inspect}, Received: #{result.inspect}")
|
||||
end
|
||||
|
||||
return if test_name == 'optionaltags'
|
||||
next if test_name == 'optionaltags'
|
||||
|
||||
result = HTML5::XHTMLSerializer.
|
||||
serialize(JsonWalker.new(test["input"]), (test["options"] || {}))
|
||||
|
@ -60,7 +60,6 @@ class Html5SerializeTestcase < Test::Unit::TestCase
|
|||
elsif !expected.include?(result)
|
||||
flunk("Expected: #{expected.inspect}, Received: #{result.inspect}")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
22
vendor/plugins/HTML5lib/test/test_stream.rb
vendored
22
vendor/plugins/HTML5lib/test/test_stream.rb
vendored
|
@ -5,6 +5,14 @@ require 'html5/inputstream'
|
|||
class HTMLInputStreamTest < Test::Unit::TestCase
|
||||
include HTML5
|
||||
|
||||
def getc stream
|
||||
if String.method_defined? :force_encoding
|
||||
stream.char.force_encoding('binary')
|
||||
else
|
||||
stream.char
|
||||
end
|
||||
end
|
||||
|
||||
def test_char_ascii
|
||||
stream = HTMLInputStream.new("'", :encoding=>'ascii')
|
||||
assert_equal('ascii', stream.char_encoding)
|
||||
|
@ -13,23 +21,23 @@ class HTMLInputStreamTest < Test::Unit::TestCase
|
|||
|
||||
def test_char_null
|
||||
stream = HTMLInputStream.new("\x00")
|
||||
assert_equal("\xef\xbf\xbd", stream.char)
|
||||
assert_equal("\xef\xbf\xbd", getc(stream))
|
||||
end
|
||||
|
||||
def test_char_utf8
|
||||
stream = HTMLInputStream.new("\xe2\x80\x98", :encoding=>'utf-8')
|
||||
assert_equal('utf-8', stream.char_encoding)
|
||||
assert_equal("\xe2\x80\x98", stream.char)
|
||||
assert_equal("\xe2\x80\x98", getc(stream))
|
||||
end
|
||||
|
||||
def test_char_win1252
|
||||
stream = HTMLInputStream.new("\xa2\xc5\xf1\x92\x86")
|
||||
assert_equal('windows-1252', stream.char_encoding)
|
||||
assert_equal("\xc2\xa2", stream.char)
|
||||
assert_equal("\xc3\x85", stream.char)
|
||||
assert_equal("\xc3\xb1", stream.char)
|
||||
assert_equal("\xe2\x80\x99", stream.char)
|
||||
assert_equal("\xe2\x80\xa0", stream.char)
|
||||
assert_equal("\xc2\xa2", getc(stream))
|
||||
assert_equal("\xc3\x85", getc(stream))
|
||||
assert_equal("\xc3\xb1", getc(stream))
|
||||
assert_equal("\xe2\x80\x99", getc(stream))
|
||||
assert_equal("\xe2\x80\xa0", getc(stream))
|
||||
end
|
||||
|
||||
def test_bom
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue