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

version» Context lines:

pike.git/lib/modules/Parser.pmod/XML.pmod/testsuite.in:1:   START_MARKER - // $Id$ +       // DOM      // Tree      define(test_tree_eq,[[    test_eq(Parser.XML.Tree.parse_input $1 ,$2)    test_eq(Parser.XML.Tree.simple_parse_input $1 ,$2)    test_eq(Parser.XML.Tree.RootNode $1 ,$2)    test_eq(Parser.XML.Tree.SimpleRootNode $1 ,$2)
pike.git/lib/modules/Parser.pmod/XML.pmod/testsuite.in:38:   test_any([[      class A {    inherit Parser.XML.Tree.RootNode;    public array(Parser.XML.Tree.AbstractSimpleNode) mChildren = ({});   };      return sizeof(A("<!-- --><!-- --><x/>")->mChildren);   ]], 3)    + // Tests of namespace handling in normal-mode. + test_any([[ +  // InfoKOM 731715 +  object root = Parser.XML.Tree.simple_parse_input("<root/>"); +  object sub = +  Parser.XML.Tree.SimpleNode(Parser.XML.Tree.XML_ELEMENT, "sub", +  ([ "foo" : "bar" ]), ""); +  root->get_elements("root")[0]->add_child(sub); +  return root->render_xml(); + ]], "<root><sub foo='bar'/></root>")    -  + test_any([[ +  // InfoKOM 731484 +  return Parser.XML.Tree.simple_parse_input( +  "<feed xmlns='http://www.w3.org/2005/Atom'\n" +  " xmlns:example='http://www.example.com/example'>\n" +  " <entry>\n" +  " <category example:test='yes' label='Test' example:test='yes' term='test' />\n" +  " </entry>\n" +  "</feed>")->render_xml(); + ]], "<feed xmlns='http://www.w3.org/2005/Atom'" +  " xmlns:example='http://www.example.com/example'>\n" +  " <entry>\n" +  " <category example:test='yes' label='Test' term='test'/>\n" +  " </entry>\n" +  "</feed>") +  + test_do([[ +  add_constant("xmlblob", + #"<?xml version='1.0' encoding='utf-8'?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:A='http://example.com/dtd'> +  <generator>Grubba</generator> +  <id>urn:uuid:4baeaeb4-7125-463a-9b68-a7005a7548bb</id> +  <title>Namespace Test</title> +  <updated>2012-09-28T16:02:16+02:00</updated> +  <entry> +  <title>Namespace Test</title> +  <id>urn:uuid:e73d603c-c287-47c8-b17c-c9e35981d64a</id> +  <link href='urn:uuid:e73d603c-c287-47c8-b17c-c9e35981d64a' rel='self'/> +  <updated>2012-09-28T16:02:16+02:00</updated> +  <author> +  <name>Grubba</name> +  </author> +  <A:user user-name='grubba'>Grubba</A:user> +  <category A:example='yes' A:priority='300' scheme='http://example.com/dtd' term='example'/> +  <A:a> +  <A:b date='2010-10-01'> +  <A:c yes='no'/> +  </A:b> +  </A:a> +  <content type='xhtml'> +  <div xmlns='http://www.w3.org/1999/xhtml'> +  <div A:id='1' class='text' id='e73ab900-f76d-41f7-8576-6be10519e31b' name='text'> +  <h1 class='headline'>Namespace Test</h1> +  <p class='normal'>This is a test of whether namespaces work in Parser.XML.Tree.</p> +  </div> +  <div class='image' id='68788699-d986-418a-8ca2-2a058ab86625' name='image'> +  <img class='image' src='/some/path/to/an/image.jpg'/> +  </div> +  </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");]]) +    // NSTree      // XML NS section 2      test_any_equal([[   object x=Parser.XML.NSTree.parse_input(#"   <x>    <!-- No namespace here. -->   </x>");   x=x[0];