pike.git / lib / modules / Parser.pmod / XML.pmod / testsuite.in

version» Context lines:

pike.git/lib/modules/Parser.pmod/XML.pmod/testsuite.in:19:   test_tree_eq([[ ("<a>hej &x.y; hopp</a>")->render_xml(); ]],   [[ "<a>hej &amp;x.y; hopp</a>" ]])   test_tree_eq([[ ("<a>hej &x.y; hopp</a>")->render_xml(1); ]],   [[ "<a>hej &x.y; hopp</a>" ]])   test_eq([[ (string)Parser.XML.Tree.parse_input("<a><b> <c/> </b></a>") ]],   [[ "<a><b> <c/> </b></a>" ]])   test_tree_eq([[ ("<p>a<![CDATA[b]""]>c</p>")[0][0]->get_text() ]],   [[ "abc" ]])   test_tree_eq([[ ("<?xml version=\"1.0\"?><!DOCTYPE greeting SYSTEM \"hello.dtd\"><!-- comment -- --><x/>")->render_xml() ]],   [[ "<?xml version='1.0' encoding='utf-8'?><!DOCTYPE greeting SYSTEM \"hello.dtd\"><!-- comment -- --><x/>" ]]) + test_tree_eq([[ ("<x><a foo='x\"'/><b bar=\"x'y\"/></x>")->render_xml() ]], + [[ "<x><a foo='x\"'/><b bar=\"x'y\"/></x>" ]])      // Check that any xml and/or doctype header survives the parsing.   // Check also that the headers are rendered properly.   test_tree_eq([[ ("<?xml version='1.0' encoding='iso-8859-1'?><!DOCTYPE foo [ <!ELEMENT foo (foo)*> ]><foo><foo/><foo/></foo>")->render_xml() ]],    [[ "<?xml version='1.0' encoding='iso-8859-1'?><!DOCTYPE foo [ <!ELEMENT foo (foo)*> ]><foo><foo/><foo/></foo>" ]])   test_tree_eq([[ ("<?xml version='1.0' encoding='utf-8'?><!DOCTYPE foo PUBLIC \"-//EN\" \"foo.dtd\" ><foo><foo/><foo/></foo>")->render_xml() ]],    [[ "<?xml version='1.0' encoding='utf-8'?><!DOCTYPE foo PUBLIC \"-//EN\" \"foo.dtd\"><foo><foo/><foo/></foo>" ]])    -  + dnl You could argue that the decoding should cause an error as 0x2122 + dnl is outside of iso-8859-1, but we could just manipulate the text + dnl node instead. + test_eq([[ Parser.XML.Tree.parse_input("<?xml version='1.0' encoding='iso-8859-1'?><a>\x2122</a>")->render_xml() ]], "<?xml version='1.0' encoding='iso-8859-1'?><a>&#2122;</a>" ) + test_eq([[ Parser.XML.Tree.parse_input("<?xml version='1.0' encoding='iso-8859-1'?><a>\x2122</a>")->render_xml(0,0,"utf-8") ]], "<?xml version='1.0' encoding='utf-8'?><a>\342\204\242</a>" ) +  + test_eq([[ Parser.XML.Tree.parse_input("\xef\xbb\xbf<i></i>")->render_xml() ]], "<i/>") +    test_any([[      class A {    inherit Parser.XML.Tree.RootNode;    public array(Parser.XML.Tree.AbstractSimpleNode) mChildren = ({});   };      return sizeof(A("<!-- --><!-- --><x/>")->mChildren);   ]], 3)   
pike.git/lib/modules/Parser.pmod/XML.pmod/testsuite.in:105:    </div>    </content>    </entry>   </feed>");   ]])      test_eq([[Parser.XML.Tree.simple_parse_input(xmlblob)->render_xml()]], xmlblob)   test_eq([[Parser.XML.Tree.simple_parse_input(xmlblob, UNDEFINED,    Parser.XML.Tree.PARSE_ENABLE_NAMESPACES)->render_xml()]], xmlblob)    + // Test of implicit xml: namespace. + test_do([[add_constant("xmlblob", "<?xml version='1.0' encoding='utf-8'?><foo xml:lang='bar' xmlns='gazonk:'/>");]]) + test_eq([[Parser.XML.Tree.simple_parse_input(xmlblob)->render_xml()]], xmlblob) + test_eq([[Parser.XML.Tree.simple_parse_input(xmlblob, UNDEFINED, +  Parser.XML.Tree.PARSE_ENABLE_NAMESPACES)->render_xml()]], xmlblob) +  + // Test InfoKOM 803815. + test_do([[add_constant("xmlblob", #"<?xml version='1.0' encoding='UTF-8'?><foo xmlns='http://bar.com/test' xmlns:bar='http://foo.com/bar/'> +  <hej bar:gazonk='hopp' xml:lang='sv-SE'> +  <tag>test</tag> +  </hej> + </foo>");]]) + test_eq([[Parser.XML.Tree.simple_parse_input(xmlblob)->render_xml()]], xmlblob) + test_eq([[Parser.XML.Tree.simple_parse_input(xmlblob, UNDEFINED, +  Parser.XML.Tree.PARSE_ENABLE_NAMESPACES)->render_xml()]], xmlblob) +  + // Test of explicit xml: namespace. + test_do([[add_constant("xmlblob", "<?xml version='1.0' encoding='utf-8'?><foo xml:lang='bar' xmlns='gazonk:' xmlns:xml='http://www.w3.org/XML/1998/namespace'/>");]]) + test_eq([[Parser.XML.Tree.simple_parse_input(xmlblob)->render_xml()]], xmlblob) + test_eq([[Parser.XML.Tree.simple_parse_input(xmlblob, UNDEFINED, +  Parser.XML.Tree.PARSE_ENABLE_NAMESPACES)->render_xml()]], xmlblob) +  + // Test detection of invalid namespaces. + test_do([[add_constant("xmlblob", "<?xml version='1.0' encoding='utf-8'?><foo xml:lang='bar' xmlns='gazonk:' xmlns:xml='http://www.w3.org/XML/1998/invalid'/>");]]) + test_eq([[Parser.XML.Tree.simple_parse_input(xmlblob)->render_xml()]], xmlblob) + test_eval_error([[Parser.XML.Tree.simple_parse_input(xmlblob, UNDEFINED, +  Parser.XML.Tree.PARSE_ENABLE_NAMESPACES);]]) + test_do([[add_constant("xmlblob", "<?xml version='1.0' encoding='utf-8'?><foo xml:lang='bar' xmlns='gazonk:' xmlns:invalid='http://www.w3.org/XML/1998/namespace'/>");]]) + test_eq([[Parser.XML.Tree.simple_parse_input(xmlblob)->render_xml()]], xmlblob) + test_eval_error([[Parser.XML.Tree.simple_parse_input(xmlblob, UNDEFINED, +  Parser.XML.Tree.PARSE_ENABLE_NAMESPACES);]]) + test_do([[add_constant("xmlblob", "<?xml version='1.0' encoding='utf-8'?><foo xml:lang='bar' xmlns='gazonk:' xmlns:xmlns='http://www.w3.org/2000/xmlns/'/>");]]) + test_eq([[Parser.XML.Tree.simple_parse_input(xmlblob)->render_xml()]], xmlblob) + test_eval_error([[Parser.XML.Tree.simple_parse_input(xmlblob, UNDEFINED, +  Parser.XML.Tree.PARSE_ENABLE_NAMESPACES);]]) + test_do([[add_constant("xmlblob", "<?xml version='1.0' encoding='utf-8'?><foo xml:lang='bar' xmlns='gazonk:' xmlns:xmlns='http://www.w3.org/2000/invalid/'/>");]]) + test_eq([[Parser.XML.Tree.simple_parse_input(xmlblob)->render_xml()]], xmlblob) + test_eval_error([[Parser.XML.Tree.simple_parse_input(xmlblob, UNDEFINED, +  Parser.XML.Tree.PARSE_ENABLE_NAMESPACES);]]) + test_do([[add_constant("xmlblob", "<?xml version='1.0' encoding='utf-8'?><foo xml:lang='bar' xmlns='gazonk:' xmlns:invalid='http://www.w3.org/2000/xmlns/'/>");]]) + test_eq([[Parser.XML.Tree.simple_parse_input(xmlblob)->render_xml()]], xmlblob) + test_eval_error([[Parser.XML.Tree.simple_parse_input(xmlblob, UNDEFINED, +  Parser.XML.Tree.PARSE_ENABLE_NAMESPACES);]]) +    test_do([[add_constant("xmlblob");]])    -  + test_any([[ +  object o=Parser.XML.Tree.parse_input("<x><a/><b/><c/></x>"); +  o[0][1]->replace_node( ({ Parser.XML.Tree.ElementNode("q",([])), Parser.XML.Tree.ElementNode("r",([])) }) ); +  return (string)o; + ]], "<x><a/><q/><r/><c/></x>") +    // NSTree      // XML NS section 2      test_any_equal([[   object x=Parser.XML.NSTree.parse_input(#"   <x>    <!-- No namespace here. -->   </x>");   x=x[0];