Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #24 from tonycoz/handle2

test handle() and have it return an IO::File instead of an IO::Handle
  • Loading branch information...
commit b9bd344a6519b64fab35adfcdfb913d155383e99 2 parents 95f0265 + e099bc1
@leejo leejo authored
Showing with 13 additions and 2 deletions.
  1. +2 −2 lib/CGI.pm
  2. +11 −0 t/upload.t
View
4 lib/CGI.pm
@@ -3897,8 +3897,8 @@ END_OF_FUNC
'handle' => <<'END_OF_FUNC',
sub handle {
my $self = shift;
- eval "require IO::Handle" unless IO::Handle->can('new_from_fd');
- return IO::Handle->new_from_fd(fileno $self,"<");
+ eval "require IO::File" unless IO::Handle->can('new_from_fd');
+ return IO::File->new_from_fd(fileno $self,"<");
}
END_OF_FUNC
View
11 t/upload.t
@@ -121,6 +121,17 @@ ok( defined $q->upload('300x300_gif') , 'upload_basic_4' );
is(tell($fh1), 1656, $test);
}
+{ # test handle() method
+ my $fh1 = $q->upload("300x300_gif");
+ my $rawhandle = $fh1->handle;
+ ok($rawhandle, "check handle()");
+ isnt($rawhandle, "300x300_gif", "no string overload");
+ # check it acts like a handle
+ seek($rawhandle, 0, 2);
+ is(tell($rawhandle), 1656, "check it acts like a handle");
+ ok(eval { $rawhandle->seek(0, 2); 1 }, "can call seek() on handle result");
+}
+
my $q2 = CGI->new;
{
Please sign in to comment.
Something went wrong with that request. Please try again.