! Copyright (C) 2005, 2006 Daniel Ehrenberg ! See http://factorcode.org/license.txt for BSD license. IN: xml.tests USING: kernel xml tools.test io namespaces make sequences xml.errors xml.entities.html parser strings xml.data io.files xml.writer xml.utilities state-parser continuations assocs sequences.deep accessors io.streams.string ; ! This is insufficient \ read-xml must-infer SYMBOL: xml-file [ ] [ "resource:basis/xml/tests/test.xml" [ file>xml ] with-html-entities xml-file set ] unit-test [ "1.0" ] [ xml-file get prolog>> version>> ] unit-test [ f ] [ xml-file get prolog>> standalone>> ] unit-test [ "a" ] [ xml-file get space>> ] unit-test [ "http://www.hello.com" ] [ xml-file get url>> ] unit-test [ "that" ] [ xml-file get T{ name f "" "this" "http://d.de" } swap at ] unit-test [ t ] [ xml-file get children>> second contained-tag? ] unit-test [ "" string>xml ] [ xml-parse-error? ] must-fail-with [ T{ comment f "This is where the fun begins!" } ] [ xml-file get before>> [ comment? ] find nip ] unit-test [ "xsl stylesheet=\"that-one.xsl\"" ] [ xml-file get after>> [ instruction? ] find nip text>> ] unit-test [ V{ "fa&g" } ] [ xml-file get "x" get-id children>> ] unit-test [ "that" ] [ xml-file get "this" swap at ] unit-test [ "" ] [ "" string>xml xml>string ] unit-test [ "abcd" ] [ "
abcd
" string>xml [ [ dup string? [ % ] [ drop ] if ] deep-each ] "" make ] unit-test [ "abcd" ] [ "
abcd
" string>xml [ string? ] deep-filter concat ] unit-test [ "foo" ] [ "
foo" string>xml "c" get-id children>string ] unit-test [ "foo" ] [ "" string>xml "y" over at swap "z" [ tuck ] dip swap set-at T{ name f "blah" "z" f } swap at ] unit-test [ "foo" ] [ "" string>xml children>string ] unit-test [ "bar baz" ] [ "bar" string>xml [ " baz" append ] map xml>string ] unit-test [ "\n\n bar\n" ] [ " bar " string>xml pprint-xml>string ] unit-test [ "" string>xml ] must-fail [ ] [ "" string>xml drop ] unit-test [ T{ element-decl f "br" "EMPTY" } ] [ "" string>xml-chunk first ] unit-test [ T{ element-decl f "p" "(#PCDATA|emph)*" } ] [ "" string>xml-chunk first ] unit-test [ T{ element-decl f "%name.para;" "%content.para;" } ] [ "" string>xml-chunk first ] unit-test [ T{ element-decl f "container" "ANY" } ] [ "" string>xml-chunk first ] unit-test [ T{ doctype-decl f "foo" } ] [ "" string>xml-chunk first ] unit-test [ T{ doctype-decl f "foo" } ] [ "" string>xml-chunk first ] unit-test [ T{ doctype-decl f "foo" T{ system-id f "blah.dtd" } } ] [ "" string>xml-chunk first ] unit-test [ T{ doctype-decl f "foo" T{ system-id f "blah.dtd" } } ] [ "" string>xml-chunk first ] unit-test [ t ] [ "" dup string>xml-chunk [ write-xml-chunk ] with-string-writer = ] unit-test [ "foo" ] [ "&bar;" string>xml children>string ] unit-test [ V{ "hello" } ] [ "hello" string>xml-chunk ] unit-test [ 958 ] [ [ "ξ" string>xml-chunk ] with-html-entities first first ] unit-test