# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-# The rest of this file was written by Jason Woofenden in 2015, and is released
-# under the terms of the CC0 license:
+# The rest of this file was written by Jason Woofenden in 2015-2016, and is
+# released under the terms of the CC0 license:
# http://creativecommons.org/publicdomain/zero/1.0/ and into the public domain
tests = [
}, {
name: "template.dat #108"
html: "<template><a><table><a>"
- expected: "| <html>\n| <head>\n| <template>\n| content\n| <a>\n| <a>\n| <table>\n| <body>"
+ expected: "| <html>\n| <head>\n| <template>\n| content\n| <a>\n| <a>\n| <table>\n| <body>\n"
}, {
name: "tests10.dat #1"
html: "<!DOCTYPE html><svg></svg>"
}
]
-if window?.wheic?
- wheic = window.wheic
+if typeof module isnt 'undefined' and module.exports?
+ wheic = require './parse-html.coffee'
else
- wheic = require './wheic.js'
+ wheic = window.wheic
serialize_els = (els, prefix = '| ') ->
ret = ''
attr_keys.sort() # TODO this should be "lexicographically by UTF-16 code unit"
for k in attr_keys
ret += "#{prefix} #{k}=\"#{el.attrs[k]}\"\n"
- if el.name is 'template' # ?check ns
+ if el.name is 'template' and el.namespace is wheic.NS_HTML
ret += "#{prefix} content\n"
ret += serialize_els el.children, "#{prefix} "
else
ret += "#{prefix}UNKNOWN TAG TYPE #{el.type}"
return ret
-test_results = passed: 0, failed: 0, fragment: 0, pending: 0
+test_results = passed: 0, failed: 0
test_parser = (args) ->
- if args.fragment? # hide fragment tests for now
- test_results.fragment += 1
- return
- if args.name.substr(0, 20) is "pending-spec-changes" # hide for now
- test_results.pending += 1
- return
wheic.debug_log_reset()
parse_errors = []
args.error_cb = (i) ->
parse_errors.push i
prev_node_id = 0 # reset counter
- parsed = wheic.parse_html args
+ parsed = wheic.parse_html args.html, args
serialized = serialize_els parsed
if serialized isnt args.expected
test_results.failed += 1
test_results.passed += 1
# console.log "passed \"#{args.name}\""
test_summary = ->
- console.log "Tests passed: #{test_results.passed}, Failed: #{test_results.failed}, ignored: #{test_results.fragment}"
+ console.log "Tests passed: #{test_results.passed}, Failed: #{test_results.failed}"
next_test = 0