all repos — min @ dbe12b22f80807ece701f7e10d9519b3676eb438

A small but practical concatenative programming language.

Added tests for xml module
h3rald h3rald@h3rald.com
Sun, 30 Jul 2023 12:44:02 +0000
commit

dbe12b22f80807ece701f7e10d9519b3676eb438

parent

4da4ef954921993dd39b2c033d40b84c8ea17630

2 files changed, 17 insertions(+), 6 deletions(-)

jump to
M minpkg/lib/min_xml.nimminpkg/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.mintests/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