1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
include shared/tree_common
import std/streams
proc runTest(test: TCTest, factory: MAtomFactory, scripting: bool) =
let ss = newStringStream(test.data)
let opts = HTML5ParserOpts[Node, MAtom](scripting: scripting)
assert test.fragment.isNone
let pdoc = parseHTML(ss, opts, factory = factory)
#[
var ins = ""
for x in test.document.childList:
ins &= $x & '\n'
var ps = ""
for x in pdoc.childList:
ps &= $x & '\n'
echo "data ", test.data
echo "indoc ", $ins
echo "psdoc ", $ps
]#
checkTest(test.document, pdoc)
const rootpath = "test/"
proc runTests(filename: string) =
let factory = newMAtomFactory()
let tests = parseTests(readFile(rootpath & filename), factory)
for test in tests:
case test.script
of SCRIPT_OFF:
test.runTest(factory, scripting = false)
of SCRIPT_ON:
test.runTest(factory, scripting = true)
of SCRIPT_BOTH:
test.runTest(factory, scripting = false)
test.runTest(factory, scripting = true)
test "gtrsim.dat":
runTests("gtrsim.dat")
|