diff options
author | Jesse Luehrs <doy@tozt.net> | 2012-07-18 16:43:57 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2012-07-18 16:43:57 -0500 |
commit | b275579910d410e7f9ecff88cccdeb673191d332 (patch) | |
tree | b1ca4397924ad7a0dd46e9f693edca7eba82a9cf /t/response-body.t | |
parent | a2986198eb809d38bd99e7c56cd80e27ff6394f0 (diff) | |
download | web-request-b275579910d410e7f9ecff88cccdeb673191d332.tar.gz web-request-b275579910d410e7f9ecff88cccdeb673191d332.zip |
import the Plack::Response test suite
Diffstat (limited to 't/response-body.t')
-rw-r--r-- | t/response-body.t | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/t/response-body.t b/t/response-body.t new file mode 100644 index 0000000..39e2e03 --- /dev/null +++ b/t/response-body.t @@ -0,0 +1,41 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; + +use File::Temp; +use FindBin; +use URI; +use Web::Response; + +sub r($) { + my $res = Web::Response->new(status => 200); + $res->body(@_); + return $res->finalize->[2]; +} + +is_deeply r "Hello World", [ "Hello World" ]; +is_deeply r [ "Hello", "World" ], [ "Hello", "World" ]; + +{ + open my $fh, "$FindBin::Bin/body.t"; + is_deeply r $fh, $fh; +} + +{ + my $foo = "bar"; + open my $io, "<", \$foo; + is_deeply r $io, $io; +} + +{ + my $uri = URI->new("foo"); # stringified object + is_deeply r $uri, [ $uri ]; +} + +{ + my $tmp = File::Temp->new; # File::Temp has stringify method, but it is-a IO::Handle. + is_deeply r $tmp, $tmp; +} + +done_testing; |