Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add test for tied file handles

  • Loading branch information...
commit 0a65c7628fa394f7c24a18e023f5ff7b546b52df 1 parent 941852d
Bastian Blank authored
Showing with 37 additions and 0 deletions.
  1. +37 −0 t/06_streams.t
View
37 t/06_streams.t
@@ -0,0 +1,37 @@
+use strict;
+use warnings;
+use CGI;
+use CGI::Emulate::PSGI;
+use Test::More;
+
+my $app_input = CGI::Emulate::PSGI->handler(
+ sub {
+ read(\*STDIN, undef, 0, 0);
+ },
+);
+
+my $app_errors = CGI::Emulate::PSGI->handler(
+ sub {
+ print STDERR "TEST";
+ },
+);
+
+my $stream_input = StreamInput->new;
+$app_input->({ REQUEST_METHOD => 'GET', 'psgi.input' => $stream_input, 'psgi.errors' => \*STDERR });
+
+is $stream_input->{CALLED}, 1;
+
+my $stream_errors = StreamErrors->new;
+$app_errors->({ REQUEST_METHOD => 'GET', 'psgi.input' => \*STDIN, 'psgi.errors' => $stream_errors });
+
+is $stream_errors->{CALLED}, "TEST";
+
+done_testing;
+
+package StreamInput;
+sub new { bless({}, shift) }
+sub read { my $self = shift; $self->{CALLED} = 1 }
+
+package StreamErrors;
+sub new { bless({}, shift) }
+sub print { my $self = shift; $self->{CALLED} = shift }
Please sign in to comment.
Something went wrong with that request. Please try again.