]> gitweb.factorcode.org Git - factor.git/blob - basis/xml/interpolate/interpolate-tests.factor
Merge branch 'master' into experimental
[factor.git] / basis / xml / interpolate / interpolate-tests.factor
1 ! Copyright (C) 2009 Daniel Ehrenberg.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: tools.test xml.interpolate multiline kernel assocs
4 sequences accessors xml.writer xml.interpolate.private
5 locals splitting urls xml.data classes ;
6 IN: xml.interpolate.tests
7
8 [ "a" "c" { "a" "c" f } ] [
9     "<?xml version='1.0'?><x><-a-><b val=<-c->/><-></x>"
10     string>doc
11     [ second var>> ]
12     [ fourth "val" attr var>> ]
13     [ extract-variables ] tri
14 ] unit-test
15
16 [ {" <?xml version="1.0" encoding="UTF-8"?>
17 <x>
18   one
19   <b val="two"/>
20   y
21   <foo/>
22 </x>"} ] [
23     [let* | a [ "one" ] c [ "two" ] x [ "y" ]
24            d [ [XML <-x-> <foo/> XML] ] |
25         <XML
26             <x> <-a-> <b val=<-c->/> <-d-> </x>
27         XML> pprint-xml>string
28     ]
29 ] unit-test
30
31 [ {" <?xml version="1.0" encoding="UTF-8"?>
32 <doc>
33   <item>
34     one
35   </item>
36   <item>
37     two
38   </item>
39   <item>
40     three
41   </item>
42 </doc>"} ] [
43     "one two three" " " split
44     [ [XML <item><-></item> XML] ] map
45     <XML <doc><-></doc> XML> pprint-xml>string
46 ] unit-test
47
48 [ {" <?xml version="1.0" encoding="UTF-8"?>
49 <x number="3" url="http://factorcode.org/" string="hello" word="drop"/>"} ]
50 [ 3 f URL" http://factorcode.org/" "hello" \ drop
51   <XML <x number=<-> false=<-> url=<-> string=<-> word=<->/> XML>
52   pprint-xml>string  ] unit-test
53
54 [ "<x>3</x>" ] [ 3 [XML <x><-></x> XML] xml>string ] unit-test
55 [ "<x></x>" ] [ f [XML <x><-></x> XML] xml>string ] unit-test
56
57 \ <XML must-infer
58 [ { } "" interpolate-xml ] must-infer
59 [ [XML <foo><-></foo> <bar val=<->/> XML] ] must-infer
60
61 [ xml-chunk ] [ [ [XML <foo/> XML] ] first class ] unit-test
62 [ xml ] [ [ <XML <foo/> XML> ] first class ] unit-test
63 [ xml-chunk ] [ [ [XML <foo val=<->/> XML] ] third class ] unit-test
64 [ xml ] [ [ <XML <foo val=<->/> XML> ] third class ] unit-test
65 [ 1 ] [ [ [XML <foo/> XML] ] length ] unit-test
66 [ 1 ] [ [ <XML <foo/> XML> ] length ] unit-test
67
68 [ "" ] [ [XML XML] concat ] unit-test