Commits

(no ...@9ae0c189-cd1f-4510-a509-f4891f5cf20d  committed d6ba350

This commit was manufactured by cvs2svn to create tag
'XML-LibXML-0_92'.

  • Participants
  • Parent commits 4243349
  • Tags XML-LibXML-0_92

Comments (0)

Files changed (5)

File t/01basic.t

-use Test;
-BEGIN { plan tests => 2 }
-END { ok(0) unless $loaded }
-use XML::LibXML;
-$loaded = 1;
-ok(1);
-
-my $p = XML::LibXML->new();
-ok($p);

File t/02parsestring.t

-use Test;
-BEGIN { plan tests => 4 };
-use XML::LibXML;
-ok(1);
-
-my $parser = XML::LibXML->new();
-ok($parser);
-
-my $doc = $parser->parse_string(<<'EOT');
-<xml/>
-EOT
-
-ok($doc);
-
-eval {
-    my $fail = $parser->parse_string(<<'EOT');
-<foo>&</foo>
-EOT
-};
-ok($@);
-
-# warn "doc is: ", $doc2->toString, "\n";

File t/06nodetypes.t

-# Before `make install' is performed this script should be runnable with
-# `make test'. After `make install' it should work as `perl test.pl'
-
-use Test;
-
-BEGIN { plan tests=>38; }
-END {ok(0) unless $loaded;}
-use XML::LibXML;
-$loaded = 1;
-ok($loaded);
-
-######################### End of black magic.
-
-# Insert your test code below (better if it prints "ok 13"
-# (correspondingly "not ok 13") depending on the success of chunk 13
-# of the test code):
-
-# this script performs element node tests
-
-my $vers   = "1.0";
-my $enc    = "iso-8859-1";
-my $aname  = "test";
-my $avalue = "the value";
-my $bvalue = "other value";
-my $testtxt= "text";
-my $comment= "comment";
-my $cdata  = "unparsed";
-
-my $dom = XML::LibXML::Document->createDocument( $vers, $enc );
-if( defined $dom ) {
-
-# node creation 1 (bound element)
-my $elem1 = $dom->createElement( "A" );
-if ( defined $elem1 ) {
-  ok( $elem1->getType() == XML_ELEMENT_NODE );
-  ok( $elem1->getName() eq "A" );
-
-  # set, reset and remove attribute
-  $elem1->setAttribute( $aname, $avalue );
-  ok( $elem1->getAttribute( $aname ) eq $avalue );
-  ok( $elem1->hasAttribute( $aname ) );
- 
-  # toString test
-  my $estr = $elem1->toString();
-  my $tstr = "<A $aname=\"$avalue\"/>";
-  ok( $estr eq $tstr );  
-
-  $dom->setDocumentElement( $elem1 );
-  my $te = $dom->getDocumentElement();
-  
-  # in the first version it cause a method not found ... 
-  ok( $estr eq $te->toString() );
-
-
-  $elem1->setAttribute( $aname, $bvalue );
-  ok( $elem1->getAttribute( $aname ) eq $bvalue );
-  $elem1->removeAttribute( $aname );
-  ok( not $elem1->hasAttribute( $aname ) );
-
-  # child node functions:
-  my $text = $dom->createTextNode( $testtxt );
-  ok( defined $text && $text->getType == XML_TEXT_NODE );
-  ok( defined $text && $text->getData() eq $testtxt );
-
-  $elem1->appendChild( $text );
-  ok( $elem1->hasChildNodes() );
-
-  # test if first child works
-  my $tt = $elem1->getFirstChild();
-  ok( defined $tt && ( $tt->getData() eq $text->getData() ) ) ;
-
-  # test if last child works 
-  $tt = $elem1->getLastChild();
-  ok( defined $tt && ( $tt->getData() eq $text->getData() ) ) ;
-
-  my @children = $elem1->getChildnodes();
-  ok( scalar( @children ) == 1 ); 
-
-  # test bugs in classification
-  ok( $tt->isa("XML::LibXML::Text") );
-  
-  $text = $dom->createComment( $comment ); 
-  ok( $text->isa("XML::LibXML::Comment") );
-  $elem1->appendChild( $text );
-
-
-  $text = $dom->createCDATASection( $cdata ); 
-  ok( $text->isa("XML::LibXML::CDATASection") );
-  $elem1->appendChild( $text );
- 
-  my $str = "";
-
-  # forward traversing
-  my $c = $elem1->getFirstChild();
-  while ( $c ) {
-    if( $c->getType() == XML_TEXT_NODE ){
-	ok( $c->isa( "XML::LibXML::Text" ) );
-	$str .='t';
-    }
-    elsif( $c->getType() == XML_COMMENT_NODE ){
-	ok( $c->isa( "XML::LibXML::Comment" ) );
-	$str .='c';
-    }
-    elsif( $c->getType() == XML_CDATA_SECTION_NODE ){
-	ok( $c->isa( "XML::LibXML::CDATASection" ) );
-	$str .='d';
-    }
-    else{
-	$str .= '?';
-    }
-    $c = $c->getNextSibling();
-  }
-  ok( $str eq 'tcd' );
- 
-  # reverse traversing
-  $str = "";
-  my $rem = undef;
-  $c = $elem1->getLastChild();
-  while ( $c ) {
-    if( $c->getType() == XML_TEXT_NODE ){
-	ok( $c->isa( "XML::LibXML::Text" ) );
-	$str .='t';
-    }
-    elsif( $c->getType() == XML_COMMENT_NODE ){
-	ok( $c->isa( "XML::LibXML::Comment" ) );
-	$rem = $c;
-	$str .='c';
-    }
-    elsif( $c->getType() == XML_CDATA_SECTION_NODE ){
-	ok( $c->isa( "XML::LibXML::CDATASection" ) );
-	$str .='d';
-    }
-    else{
-	$str .= '?';
-    }
-    $c = $c->getPreviousSibling();
-  }
-  ok( $str eq 'dct' ); 
-
-  # replace test
-
-  my $elem3 = $dom->createElement( "C" );
-  $elem1->replaceChild( $elem3, $rem );
-	
-  $str = "";
-  $c = $elem1->getLastChild();
-  while ( $c ) {
-    if( $c->getType() == XML_TEXT_NODE )            {$str .='t';}
-    elsif( $c->getType() == XML_COMMENT_NODE )      {$str .='c';}
-    elsif( $c->getType() == XML_CDATA_SECTION_NODE ){$str .='d';}
-    elsif( $c->getType() == XML_ELEMENT_NODE )      {$str .='e';}
-    else{$str .= '?';}
-    $c = $c->getPreviousSibling();
-  }
-  ok( $str eq 'det' );    
-  ok( not defined $rem->getParentNode() && 
-      not defined $rem->getNextSibling() &&
-      not defined $rem->getPreviousSibling() );
-
-  # remove test
-
-  $elem1->removeChild( $elem3 );
-  $str = "";
-  $c = $elem1->getLastChild();
-  while ( $c ) {
-    if( $c->getType() == XML_TEXT_NODE )            {$str .='t';}
-    elsif( $c->getType() == XML_COMMENT_NODE )      {$str .='c';}
-    elsif( $c->getType() == XML_CDATA_SECTION_NODE ){$str .='d';}
-    elsif( $c->getType() == XML_ELEMENT_NODE )      {$str .='e';}
-    else{$str .= '?';}
-    $c = $c->getPreviousSibling();
-  }
-  ok( $str eq 'dt' );    
-  ok( not defined $elem3->getParentNode() && 
-      not defined $elem3->getNextSibling() &&
-      not defined $elem3->getPreviousSibling() ); 
-
-  # node moving in the tree ...
-
-  $elem1->appendChild( $elem3 );
-  $elem3->appendChild( $text );
-  $str = "";
-  $c = $elem1->getLastChild();
-  while ( $c ) {
-    if( $c->getType() == XML_TEXT_NODE )            {$str .='t';}
-    elsif( $c->getType() == XML_COMMENT_NODE )      {$str .='c';}
-    elsif( $c->getType() == XML_CDATA_SECTION_NODE ){$str .='d';}
-    elsif( $c->getType() == XML_ELEMENT_NODE )      {$str .='e';}
-    else{$str .= '?';}
-    $c = $c->getPreviousSibling();
-  }
-  ok( $str eq 'et' && 
-      $elem3->hasChildNodes() && 
-      $elem3->getFirstChild()->getType() == XML_CDATA_SECTION_NODE && 
-      $elem3->getFirstChild()->getData() eq $cdata );
-}
-
-# node creation 2 (unbound element)
-#
-# NOTE!
-#
-# this should only be a virtual thing! you should never everdo such a
-# thing. create nodes allways through a document, otherwise the node
-# might not be in UTF-8 which confuses XSLT, toString etc.
-#
-#
-# these tests are ment to test logical correctness!
-
- my $elem2 = XML::LibXML::Element->new( "B" );
- if ( defined $elem2 ) {
-  ok( defined $elem2 && $elem2->getType() == XML_ELEMENT_NODE );
-  ok( defined $elem2 && $elem2->getName() eq "B" );
-  # much easier to test if no owner document is set ...
-  ok( defined $elem2 && not defined $elem2->getOwnerDocument() );
-
-  $elem2->setAttribute( $aname, $avalue );
-  ok( $elem2->getAttribute( $aname ) eq $avalue );
-  $elem2->setAttribute( $aname, $bvalue );
-  ok( $elem2->getAttribute( $aname ) eq $bvalue );
-  $elem2->removeAttribute( $aname );
-  ok( not $elem2->hasAttribute( $aname ) );
-
-
-  # nessecary document switch test!
-  my $elem3 = $dom->createElement( "C" );
-  if ( defined $elem3 ) {
-	$elem2->appendChild( $elem3 );
-	ok( not defined $elem3->getOwnerDocument() );
-  }
-
- }
-}

File t/07nodelist.t

-# Before `make install' is performed this script should be runnable with
-# `make test'. After `make install' it should work as `perl test.pl'
-
-use Test;
-BEGIN { plan tests=>8; }
-END {ok(0) unless $loaded;}
-use XML::LibXML;
-$loaded = 1;
-ok($loaded);
-
-######################### End of black magic.
-
-# Insert your test code below (better if it prints "ok 13"
-# (correspondingly "not ok 13") depending on the success of chunk 13
-# of the test code):
-
-# this performs general dom tests
-my $file    = "example/dromeds.xml";
-my $string = q{
-<B lang="eng">hump</B>
-<!-- thingi in german -->
-<B lang="ger">H�cker</B>
-};
-my $camel = 'A';
-my $tstr  = qq{<$camel>$string</$camel>};
-
-my $string2 = "H�cker";
-
-
-# init the file parser
-my $parser = XML::LibXML->new();
-$dom    = $parser->parse_file( $file );
-
-if ( defined $dom ) {
-    # get the root document
-    $elem   = $dom->getDocumentElement(); 
-    ok( defined $elem && $elem->getName() eq "dromedaries" );
-
-    if( defined $elem ) {
-        my @nodelist = $elem->getElementsByTagName( "species" );
-        ok( scalar(@nodelist) == 3 );
-        return unless scalar(@nodelist) == 3;
-        my $lama = $nodelist[1];
-        ok( defined $lama && $lama->getAttribute( "name" ) eq "Llama" );
-    }	
-  
-    # we need to create a new document since dromeds is in ASCII ...
-    my $doc = XML::LibXML::Document->new( '1.0', 'iso-8859-1' );
-    my $elem2 = $doc->createElement( $camel );
-    $doc->setDocumentElement( $elem2 ); 
-
-    $elem2->appendWellBalancedChunk( $string );
-    ok(  $elem2->toString() eq $tstr );
- 
-    my @bs = $elem2->getElementsByTagName('B');
-    ok( ( scalar( @bs ) == 2 ) &&
-        ( $bs[0]->getAttribute( 'lang' ) eq "eng" ) && 
-        ( $bs[1]->getAttribute( 'lang' ) eq "ger" ) );
-
-    my $elem3 = $doc->createElement('C');
-    $elem3->setAttribute( "value", $string2 );
-
-
-    ok( $elem3->toString() eq "<C value=\"$string2\"/>" );
-  
-    # test if the output of simple text nodes will be correct as well
-    $elem4 = $doc->createTextNode( $string2 );
-    ok( $string2 eq $elem4->toString() );
-}

File t/08findnodes.t

-use Test;
-BEGIN { plan tests=>5; }
-END {ok(0) unless $loaded;}
-use XML::LibXML;
-$loaded = 1;
-ok($loaded);
-
-# to test if findnodes works.
-# i added findnodes to the node class, so a query can be started
-# everywhere. Since I use only the 
-
-my $file    = "example/dromeds.xml";
-
-# init the file parser
-my $parser = XML::LibXML->new();
-$dom    = $parser->parse_file( $file );
-
-if ( defined $dom ) {
-  # get the root document
-  $elem   = $dom->getDocumentElement();
-  
-  # first very simple path starting at root
-  my @list   = $elem->findnodes( "species" );
-  ok( scalar(@list) == 3 );
-
-  # a simple query starting somewhere ...
-  my $node = $list[0];
-  my @slist = $node->findnodes( "humps" );
-  ok( scalar(@slist) == 1 );
-
-  # find a single node
-  @list   = $elem->findnodes( "species[\@name='Llama']" );
-  ok( scalar( @list ) == 1 );
-  
-  # find with not conditions
-  @list   = $elem->findnodes( "species[\@name!='Llama']/disposition" );
-  ok( scalar(@list) == 2 );
-}