]> git.imager.perl.org - imager.git/commitdiff
test Imager::IO::new_fh() itself with a perlio handle
authorTony Cook <tony@develop-help.com>
Mon, 21 Jan 2013 10:10:30 +0000 (21:10 +1100)
committerTony Cook <tony@develop-help.com>
Mon, 21 Jan 2013 10:10:30 +0000 (21:10 +1100)
t/t07iolayer.t

index ba0c886ddce9bb0985328fe1408591a9cf4313ff..f80ed89e7139d329899aa9a1d5ed5e6f096178ed 100644 (file)
@@ -1,6 +1,7 @@
 #!perl -w
 use strict;
-use Test::More tests => 270;
+use Test::More tests => 274;
+use Imager::Test qw(is_image);
 # for SEEK_SET etc, Fcntl doesn't provide these in 5.005_03
 use IO::Seekable;
 use Config;
@@ -838,7 +839,7 @@ SKIP:
 SKIP:
 {
   $Config{useperlio}
-    or skip "PerlIO::scalar requires perlio", 9;
+    or skip "PerlIO::scalar requires perlio", 13;
 
   my $foo;
   open my $fh, "+<", \$foo;
@@ -853,6 +854,22 @@ SKIP:
   is($data, "temore", "perlio: check we read back what we wrote");
   is($io->close, 0, "perlio: close it");
   is($foo, "temore", "perlio: check it got to the scalar properly");
+
+  my $io2 = Imager::IO->new_fh($fh);
+  ok($io2, "new_fh() can make an I/O layer object from a scalar fh");
+  close $fh;
+
+  my $im = Imager->new(xsize => 10, ysize => 10);
+  $foo = "";
+  open my $fh2, ">", \$foo;
+  ok($im->write(fh => $fh2, type => "pnm"), "can write image to scalar fh")
+    or print "# ", $im->errstr, "\n";
+
+  close $fh2;
+  open my $fh3, "<", \$foo;
+  my $im2 = Imager->new(fh => $fh3);
+  ok($im2, "read image from a scalar fh");
+  is_image($im, $im2, "check they match");
 }
 
 {