perl-test-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tors...@apache.org
Subject svn commit: r1076739 - in /perl/Apache-Test/trunk: Changes lib/Apache/TestHandler.pm
Date Thu, 03 Mar 2011 19:21:46 GMT
Author: torsten
Date: Thu Mar  3 19:21:45 2011
New Revision: 1076739

URL: http://svn.apache.org/viewvc?rev=1076739&view=rev
Log:
Add $boolean parameter to Apache::TestHandler::ok and Apache::TestHandler::ok1
Add a few bits of documentation

Apache::TestHandler forgot to require Apache2::RequestRec

Modified:
    perl/Apache-Test/trunk/Changes
    perl/Apache-Test/trunk/lib/Apache/TestHandler.pm

Modified: perl/Apache-Test/trunk/Changes
URL: http://svn.apache.org/viewvc/perl/Apache-Test/trunk/Changes?rev=1076739&r1=1076738&r2=1076739&view=diff
==============================================================================
--- perl/Apache-Test/trunk/Changes (original)
+++ perl/Apache-Test/trunk/Changes Thu Mar  3 19:21:45 2011
@@ -8,6 +8,11 @@ Changes - Apache::Test change logfile
 
 =item 1.37-dev
 
+Add $boolean parameter to Apache::TestHandler::ok and Apache::TestHandler::ok1
+Add a few bits of documentation [Torsten Foertsch]
+
+Apache::TestHandler forgot to require Apache2::RequestRec [Torsten Foertsch]
+
 =item 1.36 February 2, 2011
 
 Skip sok.t unless perlio is enabled [Torsten Foertsch]

Modified: perl/Apache-Test/trunk/lib/Apache/TestHandler.pm
URL: http://svn.apache.org/viewvc/perl/Apache-Test/trunk/lib/Apache/TestHandler.pm?rev=1076739&r1=1076738&r2=1076739&view=diff
==============================================================================
--- perl/Apache-Test/trunk/lib/Apache/TestHandler.pm (original)
+++ perl/Apache-Test/trunk/lib/Apache/TestHandler.pm Thu Mar  3 19:21:45 2011
@@ -27,7 +27,8 @@ use Apache2::Const -compile => qw(OK NOT
 #see modperl-2.0/t/hooks/TestHooks/authen.pm
 
 if ($ENV{MOD_PERL} && require mod_perl2) {
-    require Apache2::RequestIO; # puts
+    require Apache2::RequestRec; # content_type
+    require Apache2::RequestIO;  # puts
 }
 
 #compat with 1.xx
@@ -35,17 +36,17 @@ my $send_http_header = Apache->can('send
 my $print = Apache2->can('print') || Apache2::RequestRec->can('puts');
 
 sub ok {
-    my $r = shift;
+    my ($r, $boolean) = @_;
     $r->$send_http_header;
     $r->content_type('text/plain');
-    $r->$print("ok");
+    $r->$print((@_>1 && !$boolean ? "not " : '')."ok");
     0;
 }
 
 sub ok1 {
-    my $r = shift;
+    my ($r, $boolean) = @_;
     Apache::Test::plan($r, tests => 1);
-    Apache::Test::ok(1);
+    Apache::Test::ok(@_==1 || $boolean);
     0;
 }
 
@@ -101,3 +102,74 @@ sub same_interp_fixup {
 
 1;
 __END__
+
+=encoding utf8
+
+=head1 NAME
+
+Apache::TestHandler - a few response handlers and helpers
+
+=head1 SYNOPSIS
+
+    package My::Test;
+    use Apache::TestHandler ();
+    sub handler {
+        my ($r) = @_;
+        my $result = do_my_test;
+        Apache::TestHandler::ok1 $r, $result;
+    }
+
+    sub handler2 {
+        my ($r) = @_;
+        my $result = do_my_test;
+        Apache::TestHandler::ok $r, $result;
+    }
+
+=head1 DESCRIPTION
+
+C<Apache::TestHandler> provides 2 very simple response handler.
+
+=head1 FUNCTIONS
+
+=over 4
+
+=item ok $r, $boolean
+
+The handler simply prints out C<ok> or C<not ok> depending on the
+optional C<$boolean> parameter.
+
+If C<$boolean> is omitted C<true> is assumed.
+
+=item ok1 $r, $boolean
+
+This handler implements a simple response-only test. It can be used on its
+own to check if for a certain URI the response phase is reached. Or it
+can be called like a normal function to print out the test result. The
+client side is automatically created as described in
+L<http://perl.apache.org/docs/general/testing/testing.html#Developing_Response_only_Part_of_a_Test>.
+
+C<$boolean> is optional. If omitted C<true> is assumed.
+
+=item same_interp_counter
+
+=item same_interp_fixup
+
+TODO
+
+=back
+
+=head1 SEE ALSO
+
+The Apache-Test tutorial:
+L<http://perl.apache.org/docs/general/testing/testing.html>.
+
+L<Apache::Test>.
+
+=head1 AUTHOR
+
+Doug MacEachern, Geoffrey Young, Stas Bekman, Torsten Förtsch and others.
+
+Questions can be asked at the test-dev <at> httpd.apache.org list
+For more information see: http://httpd.apache.org/test/.
+
+=cut



Mime
View raw message