factor/basis/xml/interpolate/interpolate-tests.factor

53 lines
1.3 KiB
Factor
Raw Normal View History

2009-01-19 23:25:15 -05:00
! Copyright (C) 2009 Daniel Ehrenberg.
! See http://factorcode.org/license.txt for BSD license.
2009-01-25 22:06:45 -05:00
USING: tools.test xml.interpolate multiline kernel assocs
sequences accessors xml.writer xml.interpolate.private
2009-01-26 17:11:30 -05:00
locals splitting urls ;
2009-01-19 23:25:15 -05:00
IN: xml.interpolate.tests
2009-01-25 22:06:45 -05:00
2009-01-26 00:52:25 -05:00
[ "a" "c" { "a" "c" f } ] [
"<?xml version='1.0'?><x><-a-><b val=<-c->/><-></x>"
2009-01-26 17:11:30 -05:00
string>doc
2009-01-25 22:06:45 -05:00
[ second var>> ]
[ fourth "val" swap at var>> ]
[ extract-variables ] tri
] unit-test
[ {" <?xml version="1.0" encoding="UTF-8"?>
<x>
one
<b val="two"/>
y
<foo/>
</x>"} ] [
[let* | a [ "one" ] c [ "two" ] x [ "y" ]
d [ [XML <-x-> <foo/> XML] ] |
<XML
<x> <-a-> <b val=<-c->/> <-d-> </x>
XML> pprint-xml>string
]
] unit-test
2009-01-26 00:52:25 -05:00
[ {" <?xml version="1.0" encoding="UTF-8"?>
<doc>
<item>
one
</item>
<item>
two
</item>
<item>
three
</item>
</doc>"} ] [
"one two three" " " split
[ [XML <item><-></item> XML] ] map
<XML <doc><-></doc> XML> pprint-xml>string
] unit-test
2009-01-26 17:11:30 -05:00
[ {" <?xml version="1.0" encoding="UTF-8"?>
<x number="3" url="http://factorcode.org/" string="hello" word="drop"/>"} ]
[ 3 f URL" http://factorcode.org/" "hello" \ drop
<XML <x number=<-> false=<-> url=<-> string=<-> word=<->/> XML>
pprint-xml>string ] unit-test