Commits

Anonymous committed b33cd72

Modified Files:
t/02parsestring.t t/06nodetypes.t t/07nodelist.t
t/19encoding.t
cleaned the tests (fixed b0rked stuff in t/19encoding)

Comments (0)

Files changed (4)

t/02parsestring.t

 use Test;
 use Devel::Peek;
 
-BEGIN { plan tests => 13 };
+BEGIN { plan tests => 12 };
 use XML::LibXML;
 ok(1);
 
 my $parser = XML::LibXML->new();
 ok($parser);
+
 {
-my $doc = $parser->parse_string(<<'EOT');
+    my $doc = $parser->parse_string(<<'EOT');
 <test/>
 EOT
 
-ok($doc);
+    ok($doc);
 }
 
 eval {
 # phish: parse_xml_chunk tests
 
 my $chunk = "foo<a>bar<b/>foobar</a>" ;
-my $fragment = $parser->parse_xml_chunk( $chunk );
+my $fragment;
+
+eval {
+    $fragment = $parser->parse_xml_chunk( $chunk );
+};
 ok( $fragment );
 
 my $doc = $parser->parse_string(<<'EOT');
 my $r = $doc->getDocumentElement();
 ok($r);
 
-#warn "append fragment to dom\n";
-
 $r->appendChild( $fragment );
-# warn "appended!\n";
 my $str = $r->toString();
 
-# for some reason this does not work without an encoding ... 
-ok( "$str", encodeToUTF8("iso-8859-1","<test>$chunk</test>") );
-
-# bad fragment:
-
+# bad fragment tests
 my $badchunk = "foo<bar>";
-$fragment = $parser->parse_xml_chunk( $badchunk );
+eval {
+    $fragment = $parser->parse_xml_chunk( $badchunk );
+};
 ok( !$fragment );
 
 $badchunk = "foo</bar>foobar";
-$fragment = $parser->parse_xml_chunk( $badchunk );
+eval {
+    $fragment = $parser->parse_xml_chunk( $badchunk );
+};
 ok( !$fragment );
 
 $badchunk = "";
 
 use Test;
 use Devel::Peek;
-BEGIN { plan tests=>60; }
+BEGIN { plan tests=>65; }
 END {ok(0) unless $loaded;}
 use XML::LibXML;
 $loaded = 1;
 
 local $XML::LibXML::ORIGINAL_STRING = 1;
 
-my $vers   = "1.0";
-my $enc    = "iso-8859-1";
+my $version = "1.0";
+my $enc1    = "iso-8859-1";
+my $enc2    = "iso-8859-2";
+
 my $aname  = "test";
 my $avalue = "the value";
 my $bvalue = "other value";
 my $comment= "comment";
 my $cdata  = "unparsed";
 
-my $dom = XML::LibXML::Document->createDocument( $vers, $enc );
-if( defined $dom ) {
+print "# document tests\n";
+my $dom = XML::LibXML::Document->createDocument( $version, $enc1 );
+ok($dom);
 
-# node creation 1 (bound element)
+ok( $dom->getVersion, $version );
+ok( $dom->getEncoding, $enc1 );
+
+$dom->setEncoding($enc2);
+ok( $dom->getEncoding, $enc2 );
+$dom->setVersion( "2.0" );
+ok( $dom->getVersion, "2.0" );
+
+print "# node creation 1 (bound element)\n";
+
 my $elem1 = $dom->createElement( "A" );
-if ( defined $elem1 ) {
-    ok( $elem1->getType() == XML_ELEMENT_NODE );
-    ok( $elem1->getName() eq "A" );
+ok( $elem1 );
+ok( $elem1->getType(), XML_ELEMENT_NODE );
+ok( $elem1->getName(), "A" );
 
-    # warn "# Attribute tests";
+$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, $tstr );  
 
-    # set, reset and remove attribute
-    $elem1->setAttribute( $aname, $avalue );
-    ok( $elem1->getAttribute( $aname ) eq $avalue );
-    ok( $elem1->hasAttribute( $aname ) );
+$dom->setDocumentElement( $elem1 );
+my $te = $dom->getDocumentElement();
+  
+# in the first version it cause a method not found ... 
+ok( $estr, $te->toString() );
+ok( $elem1->isSameNode( $te ) );
+
+#####################################################
+print "# attribute tests\n";
+
+$elem1->setAttribute( $aname, $bvalue );
+ok( $elem1->hasAttribute( $aname ) );
+ok( $elem1->getAttribute( $aname ), $bvalue );
+$elem1->removeAttribute( $aname );
+ok( not $elem1->hasAttribute( $aname ) );
+
+my $attr = XML::LibXML::Attr->new( 'test', 'value' );
+ok( defined $attr && $attr->name() eq 'test' && $attr->getValue() eq 'value' );
+
+$attr->setValue( 'other' );
+ok( $attr->getValue(), 'other' );
+
+    
+###################################################
+print "# child node functions:\n";
+
+my $text = $dom->createTextNode( $testtxt );
+ok( $text );
+ok( $text->getType, XML_TEXT_NODE );
+ok( $text->getData(), $testtxt );
+
+$elem1->appendChild( $text );
+ok( $elem1->hasChildNodes() );
+
+my $tt = $elem1->getFirstChild();
+ok( $tt );
+ok( $text->isSameNode($tt) );
+
+$tt = $elem1->getLastChild();
+ok( $tt );
+ok( $tt->isSameNode($text) ) ;
+
+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 );
  
-  # toString test
-  my $estr = $elem1->toString();
-  my $tstr = "<A $aname=\"$avalue\"/>";
-  ok( $estr eq $tstr );  
+my $str = "";
 
-  $dom->setDocumentElement( $elem1 );
-  my $te = $dom->getDocumentElement();
-  
-  # in the first version it cause a method not found ... 
-  ok( $estr eq $te->toString() );
+print "# traversing tests\n";
 
-  #####################################################
-  # attribute tests
-
-  $elem1->setAttribute( $aname, $bvalue );
-  ok( $elem1->getAttribute( $aname ) eq $bvalue );
-  $elem1->removeAttribute( $aname );
-  ok( not $elem1->hasAttribute( $aname ) );
-    
-    # warn "# attribute w/out document";
-    # warn "# new";
-    my $attr = XML::LibXML::Attr->new( 'test', 'value' );
-    ok( defined $attr && $attr->name() eq 'test' && $attr->getValue() eq 'value' );
-
-    # warn "# reset";
-    $attr->setValue( 'other' );
-    # warn "# reset done";
-    # warn $attr->value . "\n";
-    ok( $attr->getValue(), 'other' );
-
-    my $attr2 = $dom->createAttribute( "deutsch", "uberflieger" );
-    ok( defined $attr2 &&
-        $attr2->getName() eq "deutsch" &&
-        $attr2->getValue() eq "uberflieger" );
-
-    $attr2->setValue( "druckeberger" );
-    # warn "> '". $attr2->getValue() . "'\n";
-    ok( $attr2->getValue() eq "druckeberger" );
-     
-  ###################################################
-  # child node functions:
-  my $text = $dom->createTextNode( $testtxt );
-    # warn "# child functions";
-  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 ) {
+my $c = $elem1->getFirstChild();
+while ( $c ) {
     if( $c->getType() == XML_TEXT_NODE ){
-	ok( $c->isa( "XML::LibXML::Text" ) );
-	$str .='t';
+    	ok( $c->isa( "XML::LibXML::Text" ) );
+	    $str .='t';
     }
     elsif( $c->getType() == XML_COMMENT_NODE ){
-	ok( $c->isa( "XML::LibXML::Comment" ) );
-	$str .='c';
+    	ok( $c->isa( "XML::LibXML::Comment" ) );
+	    $str .='c';
     }
     elsif( $c->getType() == XML_CDATA_SECTION_NODE ){
-	ok( $c->isa( "XML::LibXML::CDATASection" ) );
-	$str .='d';
+    	ok( $c->isa( "XML::LibXML::CDATASection" ) );
+	    $str .='d';
     }
     else{
-	$str .= '?';
+    	$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, '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';
     }
-    ok( $str , 'dct' ); 
+    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 , 'dct' ); 
 
-      # replace test
-    # warn "# replace test";
 
-    my $elem3 = $dom->createElement( "C" );
-    my $tn = $elem1->replaceChild( $elem3, $rem );
+print "# replace test\n";
 
-  $str = "";
-  $c = $elem1->getLastChild();
+my $elem3 = $dom->createElement( "C" );
+my $tn = $elem1->replaceChild( $elem3, $rem );
+ok( $tn->isSameNode( $rem ) );
 
-  while ( $c ) {
+$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, 'det' );    
-  ok( not defined $rem->getParentNode() && 
-      not defined $rem->getNextSibling() &&
-      not defined $rem->getPreviousSibling() );
+}
+ok( $str, 'det' );    
+ok( not defined $rem->getParentNode() && 
+    not defined $rem->getNextSibling() &&
+    not defined $rem->getPreviousSibling() );
 
-  # remove test
-  # warn "# remove test\n";
 
-  $elem1->removeChild( $elem3 );
-  $str = "";
-  $c = $elem1->getLastChild();
-  while ( $c ) {
+# remove test
+print "# remove test\n";
+
+$tt = $elem1->removeChild( $elem3 );
+ok( $tt->isSameNode( $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, 'dt' );    
-  ok( not defined $elem3->getParentNode() && 
-      not defined $elem3->getNextSibling() &&
-      not defined $elem3->getPreviousSibling() ); 
+}
+ok( $str, 'dt' );    
 
-  # node moving in the tree ...
+ok( not defined $elem3->getParentNode() && 
+    not defined $elem3->getNextSibling() &&
+    not defined $elem3->getPreviousSibling() ); 
 
-  $elem1->appendChild( $elem3 );
-  $elem3->appendChild( $text );
-  $str = "";
-  $c = $elem1->getLastChild();
+# node moving in the tree ...
 
-  while ( $c ) {
+$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, 'et' );
-  ok( $elem3->hasChildNodes() && 
-      $elem3->getFirstChild()->getType() == XML_CDATA_SECTION_NODE && 
-      $elem3->getFirstChild()->getData() eq $cdata );
+}
+ok( $str, 'et' );
 
-  my $testtxt = "t�st";
-  my $elem = $dom->createElement( $testtxt );
-  ok( $elem->getName(), $testtxt );
-  $elem->appendTextNode( $testtxt );
-  $elem->appendTextChild($testtxt, $testtxt);
-  $elem->setAttribute( 'test', $testtxt );
+ok( $elem3->hasChildNodes() && 
+    $elem3->getFirstChild()->getType() == XML_CDATA_SECTION_NODE && 
+    $elem3->getFirstChild()->getData() eq $cdata );
 
-  @ta = $elem->getChildnodes();
-    # warn Devel::Peek::DumpArray(2 ,@ta );
-    # warn "\@TA HAS " , scalar( @ta), " ITEMS\n"; 
-  my ( $n1, $n2 ) = $elem->getChildnodes();
-  ok( $n1 && $n1->getData() eq $testtxt );
-  ok( $n2 && $n2->getName() eq $testtxt );
-  ok( $n2 && $n2->getLocalName() eq $testtxt );
+#################################################
+# explicit document fragment test
+print "# fragment tests \n";
 
-  ok( $elem->getAttribute( 'test' ) eq $testtxt );
+$elem4 = $dom->createElement("D");
 
-  #################################################
-  # explicit document fragment test
-    print "# fragment tests \n";
-  $frag = $dom->createDocumentFragment();
+$frag = $dom->createDocumentFragment();
 #   $frag = XML::LibXML::DocumentFragment->new();
-  ok( $frag );
-#  Devel::Peek::Dump( $frag );
-  $frag->appendChild( $n1 );
-  ok( $frag->hasChildNodes() );
-  ok( ($frag->childNodes)[0]->nodeValue, $testtxt );
-  ok( ($elem->childNodes)[0]->nodeName, $testtxt );
-  $frag->appendChild( $elem );
-    @ta = $frag->childNodes;
-  ok( scalar(@ta) , 2 );
+ok( $frag );
+$frag->appendChild( $elem4 );
 
-  $domroot = $dom->documentElement;
+ok( $frag->hasChildNodes() );
+ok( ($frag->childNodes)[0]->nodeName, "D" );
 
-  # @ta = $domroot->childNodes;
-  # warn "root has ",scalar( @ta ) ," elements\n"; 
-  $domroot->appendChild( $frag );
-  @ta =$frag->childNodes;
-  ok( scalar(@ta), 0 );
-  @ta =$domroot->childNodes;
-  ok( scalar(@ta), 4 );
-  ok( ($domroot->childNodes)[2]->nodeValue, $testtxt );
-  #  warn $domroot->toString();
-  $frag->appendChild( ($domroot->childNodes)[2] );
-  $frag->appendChild( ($domroot->childNodes)[2] );
+$domroot = $dom->documentElement;
+
+# @ta = $domroot->childNodes;
+# warn "root has ",scalar( @ta ) ," elements\n"; 
+$domroot->appendChild( $frag );
+@ta =$frag->childNodes;
+ok( scalar(@ta), 0 );
+
+@ta =$domroot->childNodes;
+ok( scalar(@ta), 3 );
+# ok( ($domroot->childNodes)[2]->nodeName, $elem4->nodeName );
+
+$frag->appendChild( ($domroot->childNodes)[1] );
+$frag->appendChild( ($domroot->childNodes)[1] );
   
-   # warn scalar( $frag->childNodes ), "\n";
+$cnode = ($domroot->childNodes)[0];
 
-  $cnode = ($domroot->childNodes)[1];
-  ok( $cnode );
-  ok( $cnode->nodeName, 'C');
-  $domroot->replaceChild( $frag, $cnode );
-  ok( scalar($frag->childNodes), 0 );
-  ok( scalar($domroot->childNodes), 3 ); # its 2 because the first node in the fragment is text
-                        # and so is the preceeding node in domroot
-  # warn $domroot->toString();
+ok( $cnode );
+ok( $cnode->nodeValue, $testtxt);
 
-}
-print "# end fragment tests\n";
+ok( scalar($domroot->childNodes), 1 );
+$domroot->replaceChild( $frag, $cnode );
+ok( scalar($frag->childNodes), 0 );
+ok( scalar($domroot->childNodes), 2 ); 
 
+# warn $domroot->toString();
 
-# node creation 2 (unbound element)
-#
+print "# node creation 2 (unbound element)\n";
+
 # 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" );
+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() );
+ok( $elem2 );
+ok( defined $elem2 && $elem2->getType() == XML_ELEMENT_NODE );
+ok( defined $elem2 && $elem2->getName() eq "B" );
 
-  $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 ) );
+# much easier to test if no owner document is set ...
+ok( not defined $elem2->getOwnerDocument() );
 
+$elem2->setAttribute( $aname, $avalue );
+ok( $elem2->getAttribute( $aname ), $avalue );
+$elem2->setAttribute( $aname, $bvalue );
+ok( $elem2->getAttribute( $aname ), $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() );
-  }
- }
-}
+
+print "# document switching!\n";
+
+$elem3 = $dom->createElement( "C" );
+$elem2->appendChild( $elem3 );
+ok( not defined $elem3->getOwnerDocument() );
+
+print "# end tests \n";
 # of the test code):
 
 # this performs general dom tests
-# local $XML::LibXML::ORIGINAL_STRING = 1;
 my $file    = "example/dromeds.xml";
 my $string = q{
 <B lang="eng">hump</B>
-<!-- thingi in german -->
-<B lang="ger">Hocker</B>
+<B lang="ger">Hoecker</B>
 };
 my $camel = 'A';
 my $tstr  = qq{<$camel>$string</$camel>};
 
-my $string2 = "Hocker";
+my $string2 = "Hoecker";
 
 
 # init the file parser
 
     my $data = $bs[1]->getData();
     ok( $bs[1]->getData() eq $string2 );
-
-#    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() );
 }
 # warn "Doc fragments shall be destroyed here!\n";
 
 use Test;
 
 BEGIN { 
-    my $tests = 25;  
-    $tests = 6 if $] < 5.006;
+    my $tests        = 2;
+    my $basics       = 1;
+    my $magic        = 6;    
+
+    $tests += $basics;  
+    $tests += $magic if $] >= 5.006;
+
+    if ( defined $ENV{TEST_LANGUAGES} ) {
+        if ( $ENV{TEST_LANGUAGES} eq "all" ) {
+            $tests += 2*$basics;
+            $tests += 2*$magic if $] >= 5.006;
+        }
+        elsif ( $ENV{TEST_LANGUAGES} eq "EUC-JP"
+                or $ENV{TEST_LANGUAGES} eq "KIO8-R" ) {
+            $tests += $basics;  
+            $tests += $magic if $] >= 5.006;
+        }
+        
+    }
+
+
     plan tests => $tests;
 }
 
 ok(1);
 
 my $p = XML::LibXML->new();
-ok($p);
 
 # encoding tests
 # ok there is the UTF16 test still missing
 
-my $do_kio8r = 1;
-
 my $tstr_utf8       = 'test';
-my $tstr_iso_latin1 = "t\xE4st";
-my $tstr_euc_jp     = '������������';
-my $tstr_kio8r       = '�����';
+my $tstr_iso_latin1 = "t�st";
 
 my $domstrlat1 = q{<?xml version="1.0" encoding="iso-8859-1"?>
 <t�st>t�st</t�st>
 };
 
-my $domstrjp = q{<?xml version="1.0" encoding="EUC-JP"?>
-<������������>������������</������������>
-};
+print "# simple encoding interface\n";
 
-my $domstrkio=q{<?xml version="1.0" encoding="KIO8-R"?>
-<�����>�����</�����>
-};
-
-# simple encoding interface
 ok( decodeFromUTF8( 'UTF-8' ,
                      encodeToUTF8('UTF-8', $tstr_utf8 ) ),
     $tstr_utf8 );
                      encodeToUTF8('iso-8859-1', $tstr_iso_latin1 ) ),
     $tstr_iso_latin1 );
 
-if ( decodeFromUTF8( 'KIO8-R' , 
-                      encodeToUTF8('KIO8-R', $tstr_kio8r ) ),
-     $tstr_kio8r ) {
-    ok(1);
-}
-else {
-    warn "# skip kio8-r tests no encoder!\n";
-    ok(1);
-    $do_kio8r = 0;
-}
-
-ok( decodeFromUTF8( 'EUC-JP' , encodeToUTF8('EUC-JP', $tstr_euc_jp ) ),
-    $tstr_euc_jp );
-
-
 if ( $] < 5.006 ) {
     warn "\nskip magic encoding tests on this platform\n";
     exit(0);
 }
 else {
-    warn "\n# magic encoding tests\n";
+    print "# magic encoding tests\n";
+
+    my $dom_latin1 = XML::LibXML::Document->new('1.0', 'iso-8859-1');
+    my $elemlat1   = $dom_latin1->createElement( $tstr_iso_latin1 );
+
+    ok( decodeFromUTF8( 'iso-8859-1' ,
+                        $elemlat1->nodeName()),
+        $tstr_iso_latin1 );
+
+    $dom_latin1->setDocumentElement( $elemlat1 );
+    
+    ok( decodeFromUTF8( 'iso-8859-1' ,$elemlat1->toString()),
+        "<$tstr_iso_latin1/>");
+    ok( $elemlat1->toString(1), "<$tstr_iso_latin1/>");
+
+    $elemlat1->appendText( $tstr_iso_latin1 );
+
+    ok( decodeFromUTF8( 'iso-8859-1' ,$elemlat1->string_value()),
+        $tstr_iso_latin1);
+    ok( $elemlat1->string_value(1), $tstr_iso_latin1);
+
+    ok( $dom_latin1->toString(), $domstrlat1 );
+
 }
 
-my $dom_latin1 = XML::LibXML::Document->new('1.0', 'iso-8859-1');
-my $elemlat1 = $dom_latin1->createElement( $tstr_iso_latin1 );
+exit(0) unless defined $ENV{TEST_LANGUAGES};
 
-ok( decodeFromUTF8( 'iso-8859-1' ,
-                    $elemlat1->nodeName()),
-    $tstr_iso_latin1 );
+if ( $ENV{TEST_LANGUAGES} eq 'all' or $ENV{TEST_LANGUAGES} eq "EUC-JP" ) {
+    print "# japanese encoding (EUC-JP)\n";
 
-$dom_latin1->setDocumentElement( $elemlat1 );
+    my $tstr_euc_jp     = '������������';
+    my $domstrjp = q{<?xml version="1.0" encoding="EUC-JP"?>
+<������������>������������</������������>
+};
 
-my $dom_euc_jp = XML::LibXML::Document->new('1.0', 'EUC-JP');
-$elemjp = $dom_euc_jp->createElement( $tstr_euc_jp );
+    ok( decodeFromUTF8( 'EUC-JP' , encodeToUTF8('EUC-JP', $tstr_euc_jp ) ),
+        $tstr_euc_jp );
+    
 
-ok( decodeFromUTF8( 'EUC-JP' , $elemjp->nodeName()),
-    $tstr_euc_jp );
+    if ( $] >= 5.006 ) {
+        my $dom_euc_jp = XML::LibXML::Document->new('1.0', 'EUC-JP');
+        $elemjp = $dom_euc_jp->createElement( $tstr_euc_jp );
 
-$dom_euc_jp->setDocumentElement( $elemjp );
 
+        ok( decodeFromUTF8( 'EUC-JP' , $elemjp->nodeName()),
+            $tstr_euc_jp );
+        ok( decodeFromUTF8( 'EUC-JP' ,$elemjp->toString()),
+            "<$tstr_euc_jp/>");
+        ok( $elemjp->toString(1), "<$tstr_euc_jp/>");
 
-my ($dom_kio8, $elemkio8);
+        $dom_euc_jp->setDocumentElement( $elemjp );
+        $elemjp->appendText( $tstr_euc_jp );
 
-if ( $do_kio8r == 1 ) {
-    $dom_kio8 = XML::LibXML::Document->new('1.0', 'KIO8-R');
-    $elemkio8 = $dom_kio8->createElement( $tstr_kio8r );
+        ok( decodeFromUTF8( 'EUC-JP' ,$elemjp->string_value()),
+            $tstr_euc_jp);
+        ok( $elemjp->string_value(1), $tstr_euc_jp);
 
-    ok( decodeFromUTF8( 'KIO8-R' ,$elemkio8->nodeName()), 
-        $tstr_kio8r );
+        ok( $dom_euc_jp->toString(), $domstrjp );
+    }   
 
-    $dom_kio8->setDocumentElement( $elemkio8 );
-}
-else {
-    ok(1);ok(1);ok(1);ok(1);ok(1);ok(1);ok(1);
 }
 
-# "magic" decoding 
+if ( $ENV{TEST_LANGUAGES} eq 'all' or $ENV{TEST_LANGUAGES} eq "KIO8-R" ) {
+    print "# cyrillic encoding (KIO8-R)\n";
 
-ok( decodeFromUTF8( 'iso-8859-1' ,$elemlat1->toString()),
-    "<$tstr_iso_latin1/>");
-ok( decodeFromUTF8( 'EUC-JP' ,$elemjp->toString()),
-    "<$tstr_euc_jp/>");
+    my $tstr_kio8r       = '�����';
+    my $domstrkio = q{<?xml version="1.0" encoding="KIO8-R"?>
+<�����>�����</�����>
+};
+    
+    ok( decodeFromUTF8( 'KIO8-R' , 
+                         encodeToUTF8('KIO8-R', $tstr_kio8r ) ),
+        $tstr_kio8r );    
 
-if ( $do_kio8r == 1 ) {
-    ok( decodeFromUTF8( 'KIO8-R' ,$elemkio8->toString()), 
-    "<$tstr_kio8r/>");
+    if ( $] >= 5.006 ) {
+        my ($dom_kio8, $elemkio8);
+
+        $dom_kio8 = XML::LibXML::Document->new('1.0', 'KIO8-R');
+        $elemkio8 = $dom_kio8->createElement( $tstr_kio8r );
+
+        ok( decodeFromUTF8( 'KIO8-R' ,$elemkio8->nodeName()), 
+            $tstr_kio8r );
+
+        ok( decodeFromUTF8( 'KIO8-R' ,$elemkio8->toString()), 
+            "<$tstr_kio8r/>");
+        ok( $elemkio8->toString(1), "<$tstr_kio8r/>");
+
+        $elemkio8->appendText( $tstr_kio8r );
+
+        ok( decodeFromUTF8( 'KIO8-R' ,$elemkio8->string_value()),
+            $tstr_kio8r);
+        ok( $elemkio8->string_value(1),
+            $tstr_kio8r);
+        $dom_kio8->setDocumentElement( $elemkio8 );
+
+        ok( $dom_kio8->toString(),
+            $domstrkio );
+        
+    }
 }
-
-ok( $elemlat1->toString(1), "<$tstr_iso_latin1/>");
-ok( $elemjp->toString(1), "<$tstr_euc_jp/>");
-if ( $do_kio8r == 1 ) {
-    ok( $elemkio8->toString(1), "<$tstr_kio8r/>");
-}
-
-$elemlat1->appendText( $tstr_iso_latin1 );
-$elemjp->appendText( $tstr_euc_jp );
-
-if ( $do_kio8r == 1 ) {
-    $elemkio8->appendText( $tstr_kio8r );
-}
-
-ok( decodeFromUTF8( 'iso-8859-1' ,$elemlat1->string_value()),
-    $tstr_iso_latin1);
-ok( decodeFromUTF8( 'EUC-JP' ,$elemjp->string_value()),
-    $tstr_euc_jp);
-
-if ( $do_kio8r == 1 ) {
-    ok( decodeFromUTF8( 'KIO8-R' ,$elemkio8->string_value()),
-        $tstr_kio8r);
-}
-
-ok( $elemlat1->string_value(1), $tstr_iso_latin1);
-ok( $elemjp->string_value(1), $tstr_euc_jp);
-
-if ( $do_kio8r == 1 ) {
-    ok( $elemkio8->string_value(1),
-        $tstr_kio8r);
-}
-
-ok( $dom_latin1->toString(), $domstrlat1 );
-ok( $dom_euc_jp->toString(), $domstrjp );
-
-if ( $do_kio8r == 1 ) {
-    ok( $dom_kio8->toString(),
-        $domstrkio );
-}