Added tests for xml module
h3rald h3rald@h3rald.com
Sun, 30 Jul 2023 12:44:02 +0000
2 files changed,
17 insertions(+),
6 deletions(-)
M
minpkg/lib/min_xml.nim
→
minpkg/lib/min_xml.nim
@@ -116,16 +116,16 @@ let xml = i.newXml(xdict)
i.push ($xml).newVal def.symbol("xquery") do (i: In): - let vals = i.expect("dict:xml-element", "'sym") - let xdict = vals[0] - let query = vals[1].getString + let vals = i.expect("'sym", "dict:xml-element") + let xdict = vals[1] + let query = vals[0].getString let root = i.newXml(xdict) i.push i.newXDict(root.querySelector(query)) def.symbol("xqueryall") do (i: In): - let vals = i.expect("dict:xml-element", "'sym") - let xdict = vals[0] - let query = vals[1].getString + let vals = i.expect("'sym", "dict:xml-element") + let xdict = vals[1] + let query = vals[0].getString let root = i.newXml(xdict) let xresults = root.querySelectorAll(query) var results = newSeq[MinValue](0)
M
tests/xml.min
→
tests/xml.min
@@ -23,5 +23,16 @@ xnode (child text) => %children @xnode
xnode to-xml "<test attr1=\"a\"><a1 />text...</test>" == ) *test/assert + ( + "<ul><li class='test'>yes</li><li class='test'>...</li><li>no</li></ul>" from-xml :xnode + xnode "li.test" xquery + /children first /text "yes" == + ) *test/assert + + ( + "<ul><li class='test'>yes</li><li class='test'>...</li><li>no</li></ul>" from-xml :xnode + xnode "li.test" xqueryall + size 2 == + ) *test/assert *test/report clear-stack