all repos — min @ 2e8cb4237a3d94d3e5ee5c9f416a50af458f489b

A small but practical concatenative programming language.

tests/xml.min

 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
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
'min-test require :test
;;;


"xml" test.describe

  ("test" xml.entity "text" dict.get "test" ==) test.assert

  ("test" xml.comment "text" dict.get "test" ==) test.assert

  ("test" xml.text "text" dict.get "test" ==) test.assert

  ("test" xml.cdata "text" dict.get "test" ==) test.assert

  ("test" xml.element "tag" dict.get "test" ==) test.assert

  (
   "test" xml.element :xnode
   xnode {"a" :attr1} "attributes" dict.set @xnode
   "a1" xml.element :child
   "text..." xml.text :text
   xnode (child text) => "children" dict.set @xnode
   xnode xml.to-xml 
   "<test attr1=\"a\"><a1 />text...</test>" == ) test.assert

   (
    "<ul><li class='test'>yes</li><li class='test'>...</li><li>no</li></ul>" xml.from-xml :xnode
    xnode "li.test" xml.query 
    "children" dict.get first "text" dict.get "yes" ==
   ) test.assert

   (
    "<ul><li class='test'>yes</li><li class='test'>...</li><li>no</li></ul>" xml.from-xml :xnode
    xnode "li.test" xml.query-all 
    size 2 ==
   ) test.assert

   (
    "<b>this is a test</b><img src='test.jpg'><i>&copy</i>" xml.from-html :xnode
    xnode xml.to-xml "<document>\n  <b>this is a test</b>\n  <img src=\"test.jpg\" />\n  <i>&amp;copy</i>\n</document>" ==
   ) test.assert

   (
    "&gt;" xml.entity xml.entity2utf8 ">" ==
   ) test.assert

   (
    "This is a <i>test</i>" xml.escape "This is a &lt;i&gt;test&lt;/i&gt;" ==
   ) test.assert

  test.report
  stack.clear