]> gitweb.factorcode.org Git - factor.git/blob - libs/xml/test.factor
3e75ef20d2dac2916ede5bf2c2565fa224f2a4e1
[factor.git] / libs / xml / test.factor
1 ! Copyright (C) 2005, 2006 Daniel Ehrenberg\r
2 ! See http://factorcode.org/license.txt for BSD license.\r
3 IN: temporary\r
4 REQUIRES: libs/xml/example ;\r
5 USING: kernel xml test io namespaces hashtables sequences\r
6     errors parser xml-arith strings ;\r
7 \r
8 ! This is insufficient\r
9 SYMBOL: xml-file\r
10 [ ] [ "libs/xml/test.xml" resource-path <file-reader>\r
11     read-xml xml-file set ] unit-test\r
12 [ "1.0" ] [ xml-file get xml-doc-prolog prolog-version ] unit-test\r
13 [ f ] [ xml-file get xml-doc-prolog prolog-standalone ] unit-test\r
14 [ "a" ] [ xml-file get name-space ] unit-test\r
15 [ "http://www.hello.com" ] [ xml-file get name-url ] unit-test\r
16 [ { "that" } ]\r
17     [ T{ name f "" "this" "http://d.de" } xml-file get\r
18     tag-props hash ] unit-test\r
19 [ t ] [ xml-file get tag-children second contained-tag? ] unit-test\r
20 [ t ] [ [ "<a></b>" string>xml ] catch xml-parse-error? ] unit-test\r
21 [ T{ comment f "This is where the fun begins!" } ] [\r
22     xml-file get xml-doc-before [ comment? ] find nip\r
23 ] unit-test\r
24 [ "entity" ] [ xml-file get [ entity? ] xml-find entity-name ] unit-test\r
25 [ "reference" ] [ xml-file get [ reference? ] xml-find reference-name ] unit-test\r
26 [ "xsl stylesheet=\"that-one.xsl\"" ] [\r
27     xml-file get xml-doc-after [ instruction? ] find nip instruction-text\r
28 ] unit-test\r
29 [ V{ "fa&g" } ] [ xml-file get "x" get-id tag-children ] unit-test\r
30 [ { "that" } ] [ xml-file get "this" prop-name-tag ] unit-test\r
31 [ "<?xml version=\"1.0\" encoding=\"iso-8859-1\" standalone=\"no\"?><a b=\"c\"/>" ]\r
32     [ "<a b='c'/>" string>xml xml>string ] unit-test\r
33 [ 32 ] [\r
34     "<math><times><add><number>1</number><number>3</number></add><neg><number>-8</number></neg></times></math>"\r
35     calc-arith\r
36 ] unit-test\r
37 [ "abcd" ] [\r
38     "<main>a<sub>bc</sub>d<nothing/></main>" string>xml\r
39     [ [ dup string? [ % ] [ drop ] if ] xml-each ] "" make\r
40 ] unit-test\r
41 [ "foo" ] [\r
42     "<a><b id='c'>%foo;</b><d id='e'/></a>" string>xml\r
43     "c" get-id tag-children [ reference? ] find nip\r
44     reference-name\r
45 ] unit-test\r