Shlomi Fish avatar Shlomi Fish committed 42c7f20

Convert more to slurp().

Comments (0)

Files changed (2)

 use XML::LibXML;
 use XML::LibXML::Common qw(:libxml);
 
+use IO::Handle;
+
 sub is_empty_str 
 {
     my $s = shift;
     # -> to file handle
 
     {
-        require IO::File;
-        my $fh = new IO::File;
-        if ( $fh->open( "> example/testrun.xml" ) ) {
-            $doc->toFH( $fh );
-            $fh->close;
-            # TEST
-            ok(1, ' TODO : Add test name');
-            # now parse the file to check, if succeeded
-            my $tdoc = $parser->parse_file( "example/testrun.xml" );
-            # TEST
-            ok( $tdoc, ' TODO : Add test name' );
-            # TEST
-            ok( $tdoc->documentElement, ' TODO : Add test name' );
-            # TEST
-            is( $tdoc->documentElement->nodeName, "foo", ' TODO : Add test name' );
-            # TEST
-            is( $tdoc->documentElement->textContent, "bar", ' TODO : Add test name' );
-            unlink "example/testrun.xml" ;
-        }
+        open my $fh, '>', 'example/testrun.xml'
+            or die "Cannot open example/testrun.xml for writing - $!.";
+
+        $doc->toFH( $fh );
+        $fh->close;
+        # TEST
+        ok(1, ' TODO : Add test name');
+        # now parse the file to check, if succeeded
+        my $tdoc = $parser->parse_file( "example/testrun.xml" );
+        # TEST
+        ok( $tdoc, ' TODO : Add test name' );
+        # TEST
+        ok( $tdoc->documentElement, ' TODO : Add test name' );
+        # TEST
+        is( $tdoc->documentElement->nodeName, "foo", ' TODO : Add test name' );
+        # TEST
+        is( $tdoc->documentElement->textContent, "bar", ' TODO : Add test name' );
+        unlink "example/testrun.xml" ;
     }
 
     # -> to named file
 # $Id$
 
+use strict;
+use warnings;
+
 # Should be 38.
 use Test::More tests => 38;
 
-use strict;
-use warnings;
+use lib './t/lib';
+use TestHelpers;
 
 use XML::LibXML;
 use XML::LibXML::Common qw(:libxml);
     ok ($@, ' TODO : Add test name');
 
     undef $@;
-    my $dtd;
-    {
-        local $/;
-        open my $f, '<', $bad;
-        $dtd = <$f>;
-    }
+    my $dtd = slurp($bad);
+
     # TEST
     ok( length($dtd) > 5, ' TODO : Add test name' );
     eval { XML::LibXML::Dtd->parse_string($dtd) };
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.