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: testsuite.in,v 1.7 2005/12/18 03:34:50 nilsson Exp $ + // $Id: testsuite.in,v 1.8 2005/12/18 14:31:44 nilsson Exp $      // 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.Node $1 ,$2)    test_eq(Parser.XML.Tree.SimpleNode $1 ,$2)
pike.git/lib/modules/Parser.pmod/XML.pmod/testsuite.in:105:   r += ({ x[3]->get_ns() });   r += ({ x[3]->get_attributes() });   r += ({ x[3]->get_ns_attributes() });   return r;   ]], ({ 0, ([]), ([ "http://ecommerce.org/schema":    ([ "taxClass":"exempt" ]) ]) }) )      // XML NS section 5.1      test_any_equal([[ - object x=Parser.XML.NSTree.parse_input(#" - <?xml version=\"1.0\"?> + object x=Parser.XML.NSTree.parse_input(#"<?xml version=\"1.0\"?>   <!-- all elements here are explicitly in the HTML namespace -->   <html:html xmlns:html='http://www.w3.org/TR/REC-html40'>    <html:head><html:title>Frobnostication</html:title></html:head>    <html:body><html:p>Moved to    <html:a href='http://frob.com'>here.</html:a></html:p></html:body>   </html:html>");   x=x[2];   array r = ({});   r += ({ x->get_ns() });   r += ({ x->get_default_ns() });   r += ({ x[0]->get_ns() });   r += ({ x[0]->get_default_ns() });   r += ({ x[3][0][1]->get_attributes()->href });   return r;   ]], ({ "http://www.w3.org/TR/REC-html40", 0, 0, 0,    "http://frob.com" }) )      test_any_equal([[ - object x=Parser.XML.NSTree.parse_input(#" - <?xml version=\"1.0\"?> + object x=Parser.XML.NSTree.parse_input(#"<?xml version=\"1.0\"?>   <!-- both namespace prefixes are available throughout -->   <bk:book xmlns:bk='urn:loc.gov:books'    xmlns:isbn='urn:ISBN:0-395-36341-6'>    <bk:title>Cheaper by the Dozen</bk:title>    <isbn:number>1568491379</isbn:number>   </bk:book>");   x=x[2];   array r = ({});   r += ({ x->get_ns() });   r += ({ x->get_defined_nss() });   r += ({ x[1]->get_ns() });   r += ({ x[3]->get_ns() });   return r;   ]], ({ "urn:loc.gov:books", ([ "bk":"urn:loc.gov:books",    "isbn":"urn:ISBN:0-395-36341-6" ]),    "urn:loc.gov:books", "urn:ISBN:0-395-36341-6" }) )      // XML NS section 5.2      test_any_equal([[ - object x=Parser.XML.NSTree.parse_input(#" - <?xml version=\"1.0\"?> + object x=Parser.XML.NSTree.parse_input(#"<?xml version=\"1.0\"?>   <!-- initially, the default namespace is \"books\" -->   <book xmlns='urn:loc.gov:books'    xmlns:isbn='urn:ISBN:0-395-36341-6'>    <title>Cheaper by the Dozen</title>    <isbn:number>1568491379</isbn:number>    <notes>    <!-- make HTML the default namespace for some commentary -->    <p xmlns='urn:w3-org-ns:HTML'>    This is a <i>funny</i> book!    </p>
pike.git/lib/modules/Parser.pmod/XML.pmod/testsuite.in:212:   array args = ({    "xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'",    "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'",    "xmlns:xsd='http://www.w3.org/2001/XMLSchema'",    "xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/'",    "soap:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'" });   for(int i; i<120; i++)    Parser.XML.NSTree.parse_input("<soap:Envelope "+Array.permute(args,i)*" "+"/>");   ]])    +    // Simple    -  + test_do([[Parser.XML.Simple()->parse("<!DOCTYPE root [\n<!NOTATION JPGformat>\n]>\n", lambda(mixed ...args){} )]]) + test_do([[Parser.XML.Simple()->parse_dtd("%hej;\n", lambda(mixed ... args){}, 1, 2, 3)]]) +  + test_any([[ +  string error; +  object o = Parser.XML.Simple(); +  o->compat_allow_errors (0); +  o->parse("<a></a><foo/>", +  lambda (string type, string name, mapping attrs, string data) { +  if (type == "error") error = data; +  }); +  return error; + ]], "There can not be more than one element on the top level.") + test_any([[ +  string error; +  object o = Parser.XML.Simple(); +  o->compat_allow_errors ("7.2"); +  o->parse("<a></a><foo/>", +  lambda (string type, string name, mapping attrs, string data) { +  if (type == "error") error = data; +  }); +  return error; + ]], 0) +  + test_any([[ +  string error; +  object o = Parser.XML.Simple(); +  o->compat_allow_errors (0); +  o->parse ("<?xml version='1.0'?> <?herk?> <!-- herk --> " +  "<!DOCTYPE foo SYSTEM 'blurk.dtd'> <?herk?> <!-- herk --> " +  "<foo/> <?herk?> <!-- herk --> ", +  lambda (string type, string name, mapping attrs, string data) { +  if (type == "error") error = data; +  }); +  return error; + ]], 0) + test_any([[ +  string error; +  object o = Parser.XML.Simple(); +  o->compat_allow_errors (0); +  o->parse ("<?xml version='1.0'?> <?herk?> <!-- herk --> " +  "<foo/> <?herk?> <!-- herk --> ", +  lambda (string type, string name, mapping attrs, string data) { +  if (type == "error") error = data; +  }); +  return error; + ]], 0) + test_any([[ +  string error; +  object o = Parser.XML.Simple(); +  o->compat_allow_errors (0); +  o->parse (" <?herk?> <!-- herk --> " +  "<!DOCTYPE foo SYSTEM 'blurk.dtd'> <?herk?> <!-- herk --> " +  "<foo/> <?herk?> <!-- herk --> ", +  lambda (string type, string name, mapping attrs, string data) { +  if (type == "error") error = data; +  }); +  return error; + ]], 0) + test_any([[ +  string error; +  object o = Parser.XML.Simple(); +  o->compat_allow_errors (0); +  o->parse (" <?herk?> <!-- herk --> " +  "<foo/> <?herk?> <!-- herk --> ", +  lambda (string type, string name, mapping attrs, string data) { +  if (type == "error") error = data; +  }); +  return error; + ]], 0) +  + test_any([[ +  string error; +  int got_header; +  object o = Parser.XML.Simple(); +  o->compat_allow_errors (0); +  o->parse ("<?xml ?> <?herk?> <!-- herk --> " +  "<!DOCTYPE foo SYSTEM 'blurk.dtd'> <?herk?> <!-- herk --> " +  "<foo/> <?herk?> <!-- herk --> ", +  lambda (string type, string name, mapping attrs, string data) { +  if (type == "error") error = data; +  if (type == "<?xml") got_header = 1; +  }); +  return error || got_header; + ]], "Required version attribute missing in XML header.") + test_any([[ +  string error; +  int got_header; +  object o = Parser.XML.Simple(); +  o->compat_allow_errors ("7.6"); +  o->parse ("<?xml ?> <?herk?> <!-- herk --> " +  "<!DOCTYPE foo SYSTEM 'blurk.dtd'> <?herk?> <!-- herk --> " +  "<foo/> <?herk?> <!-- herk --> ", +  lambda (string type, string name, mapping attrs, string data) { +  if (type == "error") error = data; +  if (type == "<?xml") got_header = 1; +  }); +  return error || got_header; + ]], 1) +  + test_any([[ +  string error; +  int got_header; +  object o = Parser.XML.Simple(); +  o->compat_allow_errors (0); +  o->parse (" <?xml version='1.0'?> <?herk?> <!-- herk --> " +  "<!DOCTYPE foo SYSTEM 'blurk.dtd'> <?herk?> <!-- herk --> " +  "<foo/> <?herk?> <!-- herk --> ", +  lambda (string type, string name, mapping attrs, string data) { +  if (type == "error") error = data; +  if (type == "<?xml") got_header = 1; +  }); +  return error || got_header; + ]], "XML header must be at the first byte in the document.") + test_any([[ +  string error; +  int got_header; +  object o = Parser.XML.Simple(); +  o->compat_allow_errors ("7.6"); +  o->parse (" <?xml version='1.0'?> <?herk?> <!-- herk --> " +  "<!DOCTYPE foo SYSTEM 'blurk.dtd'> <?herk?> <!-- herk --> " +  "<foo/> <?herk?> <!-- herk --> ", +  lambda (string type, string name, mapping attrs, string data) { +  if (type == "error") error = data; +  if (type == "<?xml") got_header = 1; +  }); +  return error || got_header; + ]], "XML header must be at the first byte in the document.") +  + test_any([[ +  string error; +  int got_header; +  object o = Parser.XML.Simple(); +  o->compat_allow_errors (0); +  o->parse (" <?herk?> <!-- herk --> " +  "<!DOCTYPE foo SYSTEM 'blurk.dtd'> <?herk?> <!-- herk --> " +  "<?xml version='1.0'?> <?herk?> <!-- herk --> " +  "<foo/> <?herk?> <!-- herk --> ", +  lambda (string type, string name, mapping attrs, string data) { +  if (type == "error") error = data; +  if (type == "<?xml") got_header = 1; +  }); +  return error || got_header; + ]], "XML header must be at the first byte in the document.") + test_any([[ +  string error; +  int got_header; +  object o = Parser.XML.Simple(); +  o->compat_allow_errors ("7.6"); +  o->parse (" <?herk?> <!-- herk --> " +  "<!DOCTYPE foo SYSTEM 'blurk.dtd'> <?herk?> <!-- herk --> " +  "<?xml version='1.0'?> <?herk?> <!-- herk --> " +  "<foo/> <?herk?> <!-- herk --> ", +  lambda (string type, string name, mapping attrs, string data) { +  if (type == "error") error = data; +  if (type == "<?xml") got_header = 1; +  }); +  return error || got_header; + ]], "XML header must be at the first byte in the document.") +  + test_any([[ +  string error; +  object o = Parser.XML.Simple(); +  o->compat_allow_errors (0); +  o->parse ("<?xml version='1.0'?> <?herk?> <!-- herk --> " +  "<!DOCTYPE foo SYSTEM 'blurk.dtd'> <?herk?> <!-- herk --> " +  "<!DOCTYPE foo SYSTEM 'blurk.dtd'> <?herk?> <!-- herk --> " +  "<foo/> <?herk?> <!-- herk --> ", +  lambda (string type, string name, mapping attrs, string data) { +  if (type == "error") error = data; +  }); +  return error; + ]], "Multiple DOCTYPE declarations are not allowed.") + test_any([[ +  string error; +  object o = Parser.XML.Simple(); +  o->compat_allow_errors ("7.6"); +  o->parse ("<?xml version='1.0'?> <?herk?> <!-- herk --> " +  "<!DOCTYPE foo SYSTEM 'blurk.dtd'> <?herk?> <!-- herk --> " +  "<!DOCTYPE foo SYSTEM 'blurk.dtd'> <?herk?> <!-- herk --> " +  "<foo/> <?herk?> <!-- herk --> ", +  lambda (string type, string name, mapping attrs, string data) { +  if (type == "error") error = data; +  }); +  return error; + ]], 0) +  + test_any([[ +  string error; +  object o = Parser.XML.Simple(); +  o->compat_allow_errors (0); +  o->parse ("<?xml version='1.0'?> <?herk?> <!-- herk --> " +  "<foo/> <?herk?> <!-- herk --> " +  "<!DOCTYPE foo SYSTEM 'blurk.dtd'> <?herk?> <!-- herk --> ", +  lambda (string type, string name, mapping attrs, string data) { +  if (type == "error") error = data; +  }); +  return error; + ]], "DOCTYPE must occur before the root element.") + test_any([[ +  string error; +  object o = Parser.XML.Simple(); +  o->compat_allow_errors ("7.2"); +  o->parse ("<?xml version='1.0'?> <?herk?> <!-- herk --> " +  "<foo/> <?herk?> <!-- herk --> " +  "<!DOCTYPE foo SYSTEM 'blurk.dtd'> <?herk?> <!-- herk --> ", +  lambda (string type, string name, mapping attrs, string data) { +  if (type == "error") error = data; +  }); +  return error; + ]], 0) +  + test_any([[ +  string error; +  object o = Parser.XML.Simple(); +  o->compat_allow_errors (0); +  o->parse ("<?xml version='1.0'?> <?herk?> <!-- herk --> " +  "<foo><!DOCTYPE foo SYSTEM 'blurk.dtd'></foo> <?herk?> <!-- herk --> ", +  lambda (string type, string name, mapping attrs, string data) { +  if (type == "error") error = data; +  }); +  return error; + ]], "DOCTYPE must occur before the root element.") + test_any([[ +  string error; +  object o = Parser.XML.Simple(); +  o->compat_allow_errors ("7.6"); +  o->parse ("<?xml version='1.0'?> <?herk?> <!-- herk --> " +  "<foo><!DOCTYPE foo SYSTEM 'blurk.dtd'></foo> <?herk?> <!-- herk --> ", +  lambda (string type, string name, mapping attrs, string data) { +  if (type == "error") error = data; +  }); +  return error; + ]], 0) +  + test_any([[ +  string error; +  object o = Parser.XML.Simple(); +  o->compat_allow_errors (0); +  o->parse ("<?xml version='1.0'?> <?herk?> <!-- herk --> " +  "<!DOCTYPE foo SYSTEM 'blurk.dtd'> <?herk?> <!-- herk --> ", +  lambda (string type, string name, mapping attrs, string data) { +  if (type == "error") error = data; +  }); +  return error; + ]], "Root element missing.") + test_any([[ +  string error; +  object o = Parser.XML.Simple(); +  o->compat_allow_errors ("7.6"); +  o->parse ("<?xml version='1.0'?> <?herk?> <!-- herk --> " +  "<!DOCTYPE foo SYSTEM 'blurk.dtd'> <?herk?> <!-- herk --> ", +  lambda (string type, string name, mapping attrs, string data) { +  if (type == "error") error = data; +  }); +  return error; + ]], 0) +  + test_any([[ +  string error; +  object o = Parser.XML.Simple(); +  o->compat_allow_errors (0); +  o->parse ("<?xml version='1.0'?> <?herk?> <!-- herk --> " +  "<foo>mupp</foo> <?herk?> <!-- herk --> " +  "<![CDATA[gnork]""]> <?herk?> <!-- herk --> ", +  lambda (string type, string name, mapping attrs, string data) { +  if (type == "error") error = data; +  }); +  return error; + ]], "All data must be inside tags") + test_any([[ +  string error; +  object o = Parser.XML.Simple(); +  o->compat_allow_errors ("7.6"); +  o->parse ("<?xml version='1.0'?> <?herk?> <!-- herk --> " +  "<foo>mupp</foo> <?herk?> <!-- herk --> " +  "<![CDATA[gnork]""]> <?herk?> <!-- herk --> ", +  lambda (string type, string name, mapping attrs, string data) { +  if (type == "error") error = data; +  }); +  return error; + ]], "All data must be inside tags") + test_any([[ +  string error; +  object o = Parser.XML.Simple(); +  o->compat_allow_errors ("7.2"); +  o->parse ("<?xml version='1.0'?> <?herk?> <!-- herk --> " +  "<foo>mupp</foo> <?herk?> <!-- herk --> " +  "<![CDATA[gnork]""]> <?herk?> <!-- herk --> ", +  lambda (string type, string name, mapping attrs, string data) { +  if (type == "error") error = data; +  }); +  return error; + ]], 0) +  + test_any([[ +  string error; +  object o = Parser.XML.Simple(); +  o->compat_allow_errors (0); +  o->parse ("<?xml version='1.0'?> <?herk?> <!-- herk --> " +  "<![CDATA[gnork]""]> <?herk?> <!-- herk --> " +  "<foo>mupp</foo> <?herk?> <!-- herk --> ", +  lambda (string type, string name, mapping attrs, string data) { +  if (type == "error") error = data; +  }); +  return error; + ]], "All data must be inside tags") + test_any([[ +  string error; +  object o = Parser.XML.Simple(); +  o->compat_allow_errors ("7.6"); +  o->parse ("<?xml version='1.0'?> <?herk?> <!-- herk --> " +  "<![CDATA[gnork]""]> <?herk?> <!-- herk --> " +  "<foo>mupp</foo> <?herk?> <!-- herk --> ", +  lambda (string type, string name, mapping attrs, string data) { +  if (type == "error") error = data; +  }); +  return error; + ]], 0) + test_any([[ +  string error; +  object o = Parser.XML.Simple(); +  o->compat_allow_errors ("7.2"); +  o->parse ("<?xml version='1.0'?> <?herk?> <!-- herk --> " +  "<![CDATA[gnork]""]> <?herk?> <!-- herk --> " +  "<foo>mupp</foo> <?herk?> <!-- herk --> ", +  lambda (string type, string name, mapping attrs, string data) { +  if (type == "error") error = data; +  }); +  return error; + ]], 0) +  + test_any([[ +  string error; +  object o = Parser.XML.Simple(); +  o->compat_allow_errors (0); +  o->parse ("<?xml version='1.0'?> <?herk?> <!-- herk --> " +  "<foo>mupp</foo> <?herk?> <!-- herk --> " +  "gnork <?herk?> <!-- herk --> ", +  lambda (string type, string name, mapping attrs, string data) { +  if (type == "error") error = data; +  }); +  return error; + ]], "All data must be inside tags") + test_any([[ +  string error; +  object o = Parser.XML.Simple(); +  o->compat_allow_errors ("7.6"); +  o->parse ("<?xml version='1.0'?> <?herk?> <!-- herk --> " +  "<foo>mupp</foo> <?herk?> <!-- herk --> " +  "gnork <?herk?> <!-- herk --> ", +  lambda (string type, string name, mapping attrs, string data) { +  if (type == "error") error = data; +  }); +  return error; + ]], "All data must be inside tags") + test_any([[ +  string error; +  object o = Parser.XML.Simple(); +  o->compat_allow_errors ("7.2"); +  o->parse ("<?xml version='1.0'?> <?herk?> <!-- herk --> " +  "<foo>mupp</foo> <?herk?> <!-- herk --> " +  "gnork <?herk?> <!-- herk --> ", +  lambda (string type, string name, mapping attrs, string data) { +  if (type == "error") error = data; +  }); +  return error; + ]], "All data must be inside tags") +    // Validating   END_MARKER