Shlomi Fish avatar Shlomi Fish committed 132dd27

Convert t/12html.t from Test.pm to Test::More.

Comments (0)

Files changed (1)

 use strict;
 use warnings;
 
-use Test;
-BEGIN { plan tests => 41 }
+# should be 41.
+use Test::More tests => 41;
+
 use XML::LibXML;
 use IO::File;
-ok(1);
+
+# TEST
+ok(1, ' TODO : Add test name');
 
 my $html = "example/test.html";
 
 my $parser = XML::LibXML->new();
 {
     my $doc = $parser->parse_html_file($html);
-    ok($doc);
+    # TEST
+    ok($doc, ' TODO : Add test name');
 }
 
 my $fh;
 
 seek($fh, 0, 0);
 
-ok($string);
+# TEST
+
+ok($string, ' TODO : Add test name');
 
 my $doc = $parser->parse_html_string($string);
 
-ok($doc);
+# TEST
+
+ok($doc, ' TODO : Add test name');
 
 undef $doc;
 
 $doc = $parser->parse_html_fh($fh);
 
-ok($doc);
+# TEST
+
+ok($doc, ' TODO : Add test name');
 
 $fh->close();
 
 };
 
 # ok( not $@ );
-ok( $htmldoc );
+# TEST
+ok( $htmldoc, ' TODO : Add test name' );
 
-print "parse_html_string with encoding...\n";
+# parse_html_string with encoding
 # encodings
 if (eval { require Encode; }) {
   use utf8;
 </html>
 EOHTML
    
-  ok( Encode::is_utf8($strhref) );
+  # TEST
+   
+  ok( Encode::is_utf8($strhref), ' TODO : Add test name' );
   $htmldoc = $parser->parse_html_string( $strhref );
-  ok( $htmldoc && $htmldoc->getDocumentElement );
-  ok($htmldoc->findvalue('//p/text()'), $utf_str);
+  # TEST
+  ok( $htmldoc && $htmldoc->getDocumentElement, ' TODO : Add test name' );
+  # TEST
+  is($htmldoc->findvalue('//p/text()'), $utf_str, ' TODO : Add test name');
 
   $htmldoc = $parser->parse_html_string( $strhref, 
 					 { 
 					   encoding => 'UTF-8' 
 					 }
 					);
-  ok( $htmldoc && $htmldoc->getDocumentElement );
-  ok($htmldoc->findvalue('//p/text()'), $utf_str);
+  # TEST
+  ok( $htmldoc && $htmldoc->getDocumentElement, ' TODO : Add test name' );
+  # TEST
+  is($htmldoc->findvalue('//p/text()'), $utf_str, ' TODO : Add test name');
 
 
   my $iso_str = Encode::encode('iso-8859-2', $strhref);
 					   encoding => 'iso-8859-2'
 					  }
 					);
-  ok( $htmldoc && $htmldoc->getDocumentElement );
-  ok($htmldoc->findvalue('//p/text()'), $utf_str);
+  # TEST
+  ok( $htmldoc && $htmldoc->getDocumentElement, ' TODO : Add test name' );
+  # TEST
+  is($htmldoc->findvalue('//p/text()'), $utf_str, ' TODO : Add test name');
 
   # w/ 'meta' charset
   $strhref = <<EOHTML;
 EOHTML
 
   $htmldoc = $parser->parse_html_string( $strhref, { encoding => 'UTF-8' });
-  ok( $htmldoc && $htmldoc->getDocumentElement );
-  ok($htmldoc->findvalue('//p/text()'), $utf_str);
+  # TEST
+  ok( $htmldoc && $htmldoc->getDocumentElement, ' TODO : Add test name' );
+  # TEST
+  is($htmldoc->findvalue('//p/text()'), $utf_str, ' TODO : Add test name');
 
   $iso_str = Encode::encode('iso-8859-2', $strhref);
   $htmldoc = $parser->parse_html_string( $iso_str );
-  ok( $htmldoc && $htmldoc->getDocumentElement );
-  ok($htmldoc->findvalue('//p/text()'), $utf_str);
+  # TEST
+  ok( $htmldoc && $htmldoc->getDocumentElement, ' TODO : Add test name' );
+  # TEST
+  is($htmldoc->findvalue('//p/text()'), $utf_str, ' TODO : Add test name');
 
   $htmldoc = $parser->parse_html_string( $iso_str, { encoding => 'iso-8859-2',
 						     URI => 'foo'
 						   } );
-  ok( $htmldoc && $htmldoc->getDocumentElement );
-  ok($htmldoc->findvalue('//p/text()'), $utf_str);
-  ok($htmldoc->URI, 'foo');
+  # TEST
+  ok( $htmldoc && $htmldoc->getDocumentElement, ' TODO : Add test name' );
+  # TEST
+  is($htmldoc->findvalue('//p/text()'), $utf_str, ' TODO : Add test name');
+  # TEST
+  is($htmldoc->URI, 'foo', ' TODO : Add test name');
 } else {
   skip("Encoding related tests require Encode") for 1..14;
 }
 
-print "parse example/enc_latin2.html...\n";
+# parse example/enc_latin2.html
 # w/ 'meta' charset
 {
   use utf8;
   my $fh;
 
   $htmldoc = $parser->parse_html_file( $test_file );
-  ok( $htmldoc && $htmldoc->getDocumentElement );
-  ok($htmldoc->findvalue('//p/text()'), $utf_str);
+  # TEST
+  ok( $htmldoc && $htmldoc->getDocumentElement, ' TODO : Add test name' );
+  # TEST
+  is($htmldoc->findvalue('//p/text()'), $utf_str, ' TODO : Add test name');
   
   $htmldoc = $parser->parse_html_file( $test_file, { encoding => 'iso-8859-2',
 						     URI => 'foo'
 						   });
-  ok( $htmldoc && $htmldoc->getDocumentElement );
-  ok($htmldoc->findvalue('//p/text()'), $utf_str);
-  ok($htmldoc->URI, 'foo');
+  # TEST
+  ok( $htmldoc && $htmldoc->getDocumentElement, ' TODO : Add test name' );
+  # TEST
+  is($htmldoc->findvalue('//p/text()'), $utf_str, ' TODO : Add test name');
+  # TEST
+  is($htmldoc->URI, 'foo', ' TODO : Add test name');
   
   open $fh, '<', $test_file
     or die "Cannot open '$test_file' for reading - $!";
   $htmldoc = $parser->parse_html_fh( $fh );
   close $fh;
-  ok( $htmldoc && $htmldoc->getDocumentElement );
-  ok($htmldoc->findvalue('//p/text()'), $utf_str);
+  # TEST
+  ok( $htmldoc && $htmldoc->getDocumentElement, ' TODO : Add test name' );
+  # TEST
+  is($htmldoc->findvalue('//p/text()'), $utf_str, ' TODO : Add test name');
   
   open $fh, '<', $test_file
     or die "Cannot open '$test_file' for reading - $!";
 					    URI => 'foo',
 					  });
   close $fh;
-  ok( $htmldoc && $htmldoc->getDocumentElement );
-  ok($htmldoc->URI, 'foo');
-  ok($htmldoc->findvalue('//p/text()'), $utf_str);
+  # TEST
+  ok( $htmldoc && $htmldoc->getDocumentElement, ' TODO : Add test name' );
+  # TEST
+  is($htmldoc->URI, 'foo', ' TODO : Add test name');
+  # TEST
+  is($htmldoc->findvalue('//p/text()'), $utf_str, ' TODO : Add test name');
 
   if (1000*$] < 5008) {
     skip("skipping for Perl < 5.8") for 1..2;
         or die "Cannot open '$test_file' for reading - $!";
     $htmldoc = $parser->parse_html_fh( $fh, { encoding => 'UTF-8' });
     close $fh;
-    ok( $htmldoc && $htmldoc->getDocumentElement );
-    ok($htmldoc->findvalue('//p/text()'), $utf_str);
+    # TEST
+    ok( $htmldoc && $htmldoc->getDocumentElement, ' TODO : Add test name' );
+    # TEST
+    is($htmldoc->findvalue('//p/text()'), $utf_str, ' TODO : Add test name');
   }
 }
 
-print "parse example/enc2_latin2.html...\n";
+# parse example/enc2_latin2.html
 # w/o 'meta' charset
 {
   use utf8;
   my $fh;
 
   $htmldoc = $parser->parse_html_file( $test_file, { encoding => 'iso-8859-2' });
-  ok( $htmldoc && $htmldoc->getDocumentElement );
-  ok($htmldoc->findvalue('//p/text()'), $utf_str);
+  # TEST
+  ok( $htmldoc && $htmldoc->getDocumentElement, ' TODO : Add test name' );
+  # TEST
+  is($htmldoc->findvalue('//p/text()'), $utf_str, ' TODO : Add test name');
 
   open $fh, '<', $test_file
     or die "Cannot open '$test_file' for reading - $!";
   $htmldoc = $parser->parse_html_fh( $fh, { encoding => 'iso-8859-2' });
   close $fh;
-  ok( $htmldoc && $htmldoc->getDocumentElement );
-  ok($htmldoc->findvalue('//p/text()'), $utf_str);
+  # TEST
+  ok( $htmldoc && $htmldoc->getDocumentElement, ' TODO : Add test name' );
+  # TEST
+  is($htmldoc->findvalue('//p/text()'), $utf_str, ' TODO : Add test name');
 
   if (1000*$] < 5008) {
     skip("skipping for Perl < 5.8") for 1..2;
         or die "Cannot open '$test_file' for reading - $!";
     $htmldoc = $parser->parse_html_fh( $fh, { encoding => 'UTF-8' } );
     close $fh;
-    ok( $htmldoc && $htmldoc->getDocumentElement );
-    ok($htmldoc->findvalue('//p/text()'), $utf_str);
+    # TEST
+    ok( $htmldoc && $htmldoc->getDocumentElement, ' TODO : Add test name' );
+    # TEST
+    is($htmldoc->findvalue('//p/text()'), $utf_str, ' TODO : Add test name');
   }
 }
 
       $html => { recover => 1, suppress_errors => 1 }
      );
   };
-  ok(!$@);
-  ok($doc);
+  # TEST
+  ok (!$@, 'No exception was thrown.');
+  # TEST
+  ok ($doc, ' Parsing was succesful.');
   my $root = $doc && $doc->documentElement;
   my $val = $root && $root->findvalue('//input[@id="foo"]/@value');
-  ok($val eq 'working');
+  # TEST
+  is ($val, 'working', 'XPath');
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.