pike.git / lib / modules / Standards.pmod / testsuite.in

version» Context lines:

pike.git/lib/modules/Standards.pmod/testsuite.in:1: - test_true([["$Id: testsuite.in,v 1.10 2003/10/14 02:06:28 nilsson Exp $"]]); + test_true([["$Id: testsuite.in,v 1.11 2003/10/14 23:51:51 nilsson Exp $"]]);      // - Standards.ISO639_2   test_equal(Standards.ISO639_2.get_language("swe"),"Swedish")   test_equal(Standards.ISO639_2.get_language("xxx"),0)   test_true(sizeof(Standards.ISO639_2.list_languages())>400)   test_egual(Standards.ISO639_2.map_639_1("sv"),"swe")   test_egual(Standards.ISO639_2.map_639_1("xx"),0)   test_true(sizeof(Standards.ISO639_2.list_639_1())==163)   test_do(   class A {    inherit Standards.ISO639_2;    void create() {    foreach(indices(b_to_t), string symbol)    if(languages[symbol]) error("Overlap in symbol %s\n", symbol);    }   }(); )    - // - Standards.RDF - test_any_equal([[ -  object r = Standards.RDF(); -  object x = r->Resource(); -  r->add_statement( r->URIResource("http://www.example.org/index.html"), -  r->URIResource("http://purl.org/dc/elements/1.1/creator"), -  x ); -  object y = r->Resource(); -  r->add_statement( x, -  r->URIResource("http://www.example.org/terms/creation-date"), -  y ); -  r->add_statement( y, -  r->URIResource("http://pike.ida.liu.se/terms/ruppar"), -  r->LiteralResource("August 16, 1999") ); -  r->add_statement( x, -  r->URIResource("http://www.example.org/terms/language"), -  r->LiteralResource("English") ); -  return (multiset)(r->get_n_triples()/"\n"); - ]], (< /* 5 elements */ -  "", -  "_:Resource1 <http://www.example.org/terms/language> \"English\" .", -  "_:Resource1 <http://www.example.org/terms/creation-date> _:Resource4 .", -  "<http://www.example.org/index.html> <http://purl.org/dc/elements/1.1/creator> _:Resource1 .", -  "_:Resource4 <http://pike.ida.liu.se/terms/ruppar> \"August 16, 1999\" ." - >)) +     - test_do([[ add_constant("my_rdf", Standards.RDF()); ]]) - test_any([[ -  string nt="<http://www.w3.org/2001/08/rdf-test/> " -  "<http://purl.org/dc/elements/1.1/creator> \"Dave Beckett\" .\n" -  "<http://www.w3.org/2001/08/rdf-test/> <http://purl.org/dc/elements/1.1/creator>" -  " \"Jan Grant\" .\n" -  "<http://www.w3.org/2001/08/rdf-test/> <http://purl.org/dc/elements/1.1/publisher>" -  " _:a .\n" -  "_:a <http://purl.org/dc/elements/1.1/title>" -  " \"World Wide Web Consortium\" . \n" -  "_:a <http://purl.org/dc/elements/1.1/source>" -  " <http://www.w3.org/> .\n"; -  return my_rdf->parse_n_triples(nt); - ]], 5) - test_eq( sizeof(my_rdf), 5) - test_eq([[ sizeof(my_rdf->find_statements(0,0,0)) ]], 5) - test_eq([[ sizeof(Array.flatten(my_rdf->find_statements(0,0,0))) ]], 15) - test_eq([[ sizeof(my_rdf->find_statements( my_rdf-> -  get_resource("http://www.w3.org/2001/08/rdf-test/"),0,0)) ]], 3) - test_eq( my_rdf->get_resource(""), 0) - test_eq([[ sizeof(my_rdf->find_statements(0, my_rdf-> -  get_resource("http://purl.org/dc/elements/1.1/creator"),0)) ]], 2) - test_eq([[ sizeof(my_rdf->find_statements(0,0, my_rdf-> -  get_resource("http://www.w3.org/"))) ]], 1) - test_true([[ my_rdf->has_statement( @my_rdf->find_statements(0,0, my_rdf-> -  get_resource("http://www.w3.org/"))[0] ) ]]) - test_any([[ -  array stmt = my_rdf->find_statements(0,0, -  my_rdf->get_resource("http://www.w3.org/"))[0]; -  return my_rdf->has_statement( stmt[0], stmt[2], stmt[1] ); - ]], 0) - test_any([[ -  Standards.RDF.Resource r; -  r = my_rdf->find_statements(0, my_rdf-> -  get_resource("http://purl.org/dc/elements/1.1/publisher"), 0)[0][2]; -  return sizeof(my_rdf->find_statements(r,0,0)); - ]], 2) - test_do( my_rdf->add_statement( my_rdf->make_resource("Q://A"), -  my_rdf->make_resource("Q://B"), my_rdf->make_resource("Q://C") ) ) - test_true( has_value(my_rdf->get_n_triples(), "<Q://A> <Q://B> <Q://C> .") ) - test_true( objectp( my_rdf->reify( my_rdf->get_resource("Q://A"), -  my_rdf->get_resource("Q://B"), my_rdf->get_resource("Q://C") ) ) ) - test_any([[ -  Standards.RDF.Resource r=my_rdf->find_statements(0,my_rdf->rdf_type,0)[0][0]; -  return sizeof(my_rdf->find_statements(r,0,0)); - ]], 4) - test_do([[ -  Standards.RDF.Resource r=my_rdf->find_statements(0,my_rdf->rdf_type,0)[0][0]; -  my_rdf->add_statement(my_rdf->make_resource("Q://D"), -  my_rdf->make_resource("Q://E"), r); - ]]) - test_eq( sizeof(my_rdf), 10 ) - test_equal( sort(my_rdf->get_properties()->get_n_triple_name()), - ({ -  "<Q://E>", -  "<http://purl.org/dc/elements/1.1/creator>", -  "<http://purl.org/dc/elements/1.1/publisher>", -  "<http://purl.org/dc/elements/1.1/source>", -  "<http://purl.org/dc/elements/1.1/title>", -  "_:object", -  "_:predicate", -  "_:subject", -  "_:type" - }) ) - test_any([[ -  Standards.RDF.Resource r=my_rdf->find_statements(0,my_rdf->rdf_type,0)[0][0]; -  return my_rdf->dereify(r); - ]], 0) - test_eq( sizeof(my_rdf), 10 ) - test_do([[ -  my_rdf->remove_statement( -  @my_rdf->find_statements(my_rdf->get_resource("Q://D"),0,0)[0] ); - ]]) - test_eq( sizeof(my_rdf), 9 ) - test_any([[ -  Standards.RDF.Resource r=my_rdf->find_statements(0,my_rdf->rdf_type,0)[0][0]; -  return my_rdf->dereify(r); - ]], 1) - test_eq( sizeof(my_rdf), 6 ) - test_do([[ -  my_rdf->remove_statement( -  @my_rdf->find_statements(my_rdf->get_resource("Q://A"),0,0)[0] ); - ]]) - test_eq( sizeof(my_rdf), 5 ) - test_do( add_constant("my_rdf"); ) -  - define(test_lassila,[[test_any([[ -  object rdf = Standards.RDF(); -  rdf->parse_xml(#"$1"); -  return rdf->get_n_triples(); - ]], [[ "<http://www.w3.org/Home/Lassila> " -  "<http://description.org/schema/Creator> \"Ora Lassila\" .\n" ]]) ]]) - test_lassila([[ - <?xml version='1.0'?> - <rdf:RDF -  xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#' -  xmlns:s='http://description.org/schema/'> -  <rdf:Description about='http://www.w3.org/Home/Lassila'> -  <s:Creator>Ora Lassila</s:Creator> -  </rdf:Description> - </rdf:RDF> - ]]) - test_lassila([[ - <?xml version='1.0'?> - <RDF -  xmlns='http://www.w3.org/1999/02/22-rdf-syntax-ns#' -  xmlns:s='http://description.org/schema/'> -  <Description about='http://www.w3.org/Home/Lassila'> -  <s:Creator>Ora Lassila</s:Creator> -  </Description> - </RDF> - ]]) - test_lassila([[ - <?xml version='1.0'?> - <RDF xmlns='http://www.w3.org/1999/02/22-rdf-syntax-ns#'> -  <Description about='http://www.w3.org/Home/Lassila'> -  <s:Creator xmlns:s='http://description.org/schema/'>Ora Lassila</s:Creator> -  </Description> - </RDF> - ]]) - test_lassila([[ - <?xml version='1.0'?> - <RDF xmlns='http://www.w3.org/1999/02/22-rdf-syntax-ns#'> -  <Description about='http://www.w3.org/Home/Lassila'> -  <Creator xmlns='http://description.org/schema/'>Ora Lassila</Creator> -  </Description> - </RDF> - ]]) - test_lassila([[ - <RDF -  xmlns='http://www.w3.org/1999/02/22-rdf-syntax-ns#' -  xmlns:s='http://description.org/schema/'> -  <Description about='http://www.w3.org/Home/Lassila' -  s:Creator='Ora Lassila' /> - </RDF> - ]]) - define(test_xmlparse,[[test_any_equal([[ -  object rdf = Standards.RDF(); -  rdf->parse_xml(#"$1"); -  return (multiset)(rdf->get_n_triples()/"\n"); - ]], [[$2]]) ]]) - test_xmlparse(<RDF xmlns='http://www.w3.org/1999/02/22-rdf-syntax-ns#'/>, - (<"">)) - test_xmlparse([[ - <rdf:RDF -  xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#' -  xmlns:s='http://description.org/schema/'> -  <rdf:Description about=\"http://www.w3.org\"> -  <s:Publisher>World Wide Web Consortium</s:Publisher> -  <s:Title>W3C Home Page</s:Title> -  <s:Date>1998-10-03T02:27</s:Date> -  </rdf:Description> - </rdf:RDF> - ]],[[ (< -  "", -  "<http://www.w3.org> <http://description.org/schema/Date> \"1998-10-03T02:27\" .", -  "<http://www.w3.org> <http://description.org/schema/Title> \"W3C Home Page\" .", -  "<http://www.w3.org> <http://description.org/schema/Publisher> \"World Wide Web Consortium\" ." - >) ]]) - test_xmlparse([[ - <rdf:RDF -  xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#' -  xmlns:s='http://description.org/schema/'> -  <rdf:Description about=\"http://www.w3.org\" -  s:Publisher='World Wide Web Consortium' -  s:Title='W3C Home Page' -  s:Date='1998-10-03T02:27'/> - </rdf:RDF> - ]],[[ (< -  "", -  "<http://www.w3.org> <http://description.org/schema/Date> \"1998-10-03T02:27\" .", -  "<http://www.w3.org> <http://description.org/schema/Title> \"W3C Home Page\" .", -  "<http://www.w3.org> <http://description.org/schema/Publisher> \"World Wide Web Consortium\" ." - >) ]]) - test_xmlparse([[ - <rdf:RDF -  xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#' -  xmlns:s='http://description.org/schema/' -  xmlns:v='http://v.com/'> -  <rdf:Description about='http://www.w3.org/Home/Lassila'> -  <s:Creator rdf:resource='http://www.w3.org/staffId/85740'/> -  </rdf:Description> -  -  <rdf:Description about='http://www.w3.org/staffId/85740'> -  <v:Name>Ora Lassila</v:Name> -  <v:Email>lassila@w3.org</v:Email> -  </rdf:Description> - </rdf:RDF> - ]], [[ (< -  "", -  "<http://www.w3.org/staffId/85740> <http://v.com/Email> \"lassila@w3.org\" .", -  "<http://www.w3.org/staffId/85740> <http://v.com/Name> \"Ora Lassila\" .", -  "<http://www.w3.org/Home/Lassila> <http://description.org/schema/Creator> <http://www.w3.org/staffId/85740> ." - >) ]]) - test_xmlparse([[ - <rdf:RDF -  xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#' -  xmlns:s='http://description.org/schema/' -  xmlns:v='http://v.com/'> -  <rdf:Description about='http://www.w3.org/Home/Lassila'> -  <s:Creator> -  <rdf:Description about='http://www.w3.org/staffId/85740'> -  <v:Name>Ora Lassila</v:Name> -  <v:Email>lassila@w3.org</v:Email> -  </rdf:Description> -  </s:Creator> -  </rdf:Description> - </rdf:RDF> - ]], [[ (< -  "", -  "<http://www.w3.org/staffId/85740> <http://v.com/Email> \"lassila@w3.org\" .", -  "<http://www.w3.org/staffId/85740> <http://v.com/Name> \"Ora Lassila\" .", -  "<http://www.w3.org/Home/Lassila> <http://description.org/schema/Creator> <http://www.w3.org/staffId/85740> ." - >) ]]) - test_xmlparse([[ - <rdf:RDF -  xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#' -  xmlns:s='http://description.org/schema/' -  xmlns:v='http://v.com/'> -  <rdf:Description about='http://www.w3.org/Home/Lassila'> -  <s:Creator rdf:resource='http://www.w3.org/staffId/85740' -  v:Name='Ora Lassila' -  v:Email='lassila@w3.org' /> -  </rdf:Description> - </rdf:RDF> - ]], [[ (< -  "", -  "<http://www.w3.org/staffId/85740> <http://v.com/Email> \"lassila@w3.org\" .", -  "<http://www.w3.org/staffId/85740> <http://v.com/Name> \"Ora Lassila\" .", -  "<http://www.w3.org/Home/Lassila> <http://description.org/schema/Creator> <http://www.w3.org/staffId/85740> ." - >) ]]) -  - test_any_equal([[ -  object a = Standards.RDF(); -  a->add_statement( a->URIResource("http://a"), -  a->URIResource("http://b"), -  a->LiteralResource("x") ); -  object b = Standards.RDF(); -  b->add_statement( b->URIResource("http://a"), -  b->URIResource("http://b"), -  b->LiteralResource("x") ); -  object c = a|b; -  return (multiset)(c->get_n_triples()/"\n"); - ]], (< /* 5 elements */ -  "", -  "<http://a> <http://b> \"x\" .", -  "<http://a> <http://b> \"x\" .", - >)) -  - test_any_equal([[ -  object a = Standards.RDF(); -  a->add_statement( a->URIResource("http://a"), -  a->URIResource("http://b"), -  a->LiteralResource("x") ); -  object b = Standards.RDF(); -  b->add_statement( b->URIResource("http://a"), -  b->URIResource("http://c"), -  b->LiteralResource("x") ); -  object c = a|b; -  return (multiset)(c->get_n_triples()/"\n"); - ]], (< /* 5 elements */ -  "", -  "<http://a> <http://b> \"x\" .", -  "<http://a> <http://c> \"x\" .", - >)) -  - test_any_equal([[ -  object a = Standards.RDF(); -  a->add_statement( a->URIResource("http://a"), -  a->URIResource("http://b"), -  a->URIResource("http://c") ); -  object b = Standards.RDF(); -  b->add_statement( b->URIResource("http://a"), -  b->URIResource("http://b"), -  b->URIResource("http://c") ); -  object c = a|b; -  return (multiset)(c->get_n_triples()/"\n"); - ]], (< /* 5 elements */ -  "", -  "<http://a> <http://b> <http://c> .", - >)) -  -  +    // - Standards.URI   test_equal((string)Standards.URI("g:h", "http://a/b/c/d;p?q"), "g:h")   test_equal((string)Standards.URI("g", "http://a/b/c/d;p?q"), "http://a/b/c/g")   test_equal((string)Standards.URI("./g", "http://a/b/c/d;p?q"), "http://a/b/c/g")   test_equal((string)Standards.URI("g/", "http://a/b/c/d;p?q"), "http://a/b/c/g/")   test_equal((string)Standards.URI("/g", "http://a/b/c/d;p?q"), "http://a/g")   test_equal((string)Standards.URI("//g", "http://a/b/c/d;p?q"), "http://g")   test_equal((string)Standards.URI("?y", "http://a/b/c/d;p?q"), "http://a/b/c/?y")   test_equal((string)Standards.URI("g?y", "http://a/b/c/d;p?q"), "http://a/b/c/g?y")   test_equal((string)Standards.URI("#s", "http://a/b/c/d;p?q"), "http://a/b/c/d;p?q#s")