! Copyright (C) 2005, 2009 Daniel Ehrenberg ! See http://factorcode.org/license.txt for BSD license. USING: xml.data xml.writer tools.test fry xml kernel multiline xml.writer.private io.streams.string xml.traversal sequences io.encodings.utf8 io.files accessors io.directories ; IN: xml.writer.tests \ write-xml must-infer \ xml>string must-infer \ pprint-xml must-infer ! Add a test for pprint-xml with sensitive-tags [ "foo" ] [ T{ name { main "foo" } } name>string ] unit-test [ "foo" ] [ T{ name { space "" } { main "foo" } } name>string ] unit-test [ "ns:foo" ] [ T{ name { space "ns" } { main "foo" } } name>string ] unit-test : reprints-as ( to from -- ) [ '[ _ ] ] [ '[ _ string>xml xml>string ] ] bi* unit-test ; : pprint-reprints-as ( to from -- ) [ '[ _ ] ] [ '[ _ string>xml pprint-xml>string ] ] bi* unit-test ; : reprints-same ( string -- ) dup reprints-as ; "" reprints-same {" ]> bar "} {" ]> &foo; "} reprints-as {" ]> bar "} {" ]> &foo;"} pprint-reprints-as [ t ] [ "" dup string>xml-chunk xml>string = ] unit-test [ "" ] [ "" string>xml xml>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 [ "" ] [ "" xml>string ] unit-test : test-file "resource:basis/xml/writer/test.xml" ; [ ] [ "" string>xml test-file utf8 [ write-xml ] with-file-writer ] unit-test [ "x" ] [ test-file file>xml body>> name>> main>> ] unit-test [ ] [ test-file delete-file ] unit-test