a6429f8c22
Completely removed the html5lib sanitizer. Fixed the string-handling to work in both Ruby 1.8.x and 1.9.2. There are still, inexplicably, two functional tests that fail. But the rest seems to work quite well.
32 lines
851 B
Ruby
Executable file
32 lines
851 B
Ruby
Executable file
#!/usr/bin/env ruby -wKU
|
|
|
|
require File.join(File.dirname(__FILE__), 'preamble')
|
|
|
|
require 'html5'
|
|
require 'html5/filters/validator'
|
|
|
|
class TestValidator < Test::Unit::TestCase
|
|
def run_validator_test(test)
|
|
p = HTML5::HTMLParser.new(:tokenizer => HTMLConformanceChecker)
|
|
p.parse(test['input'])
|
|
errorCodes = p.errors.collect{|e| e[1]}
|
|
if test.has_key?('fail-if')
|
|
assert !errorCodes.include?(test['fail-if'])
|
|
end
|
|
if test.has_key?('fail-unless')
|
|
assert errorCodes.include?(test['fail-unless'])
|
|
end
|
|
end
|
|
|
|
for filename in html5_test_files('validator')
|
|
tests = JSON.load(open(filename))
|
|
testName = File.basename(filename).sub(".test", "")
|
|
tests['tests'].each_with_index do |test, index|
|
|
define_method "test_#{testName}_#{index}" do
|
|
run_validator_test(test)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|