geoff       2003/10/02 07:32:55

  Modified:    t/apache constants.t
  Log:
  tidy up the test a bit.  use t_cmp, print debug statements, etc...
  
  Revision  Changes    Path
  1.8       +55 -20    modperl-2.0/t/apache/constants.t
  
  Index: constants.t
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/t/apache/constants.t,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- constants.t       1 Oct 2003 20:03:11 -0000       1.7
  +++ constants.t       2 Oct 2003 14:32:54 -0000       1.8
  @@ -2,41 +2,76 @@
   use strict;
   use warnings FATAL => 'all';
   
  -use Test;
  +use Apache::Test;
  +use Apache::TestUtil;
   
   use Apache2 ();
  -use Apache::Const -compile => qw(DECLINED :http :common TAKE23 &OPT_EXECCGI
  -                                 DECLINE_CMD DIR_MAGIC_TYPE CRLF);
  -use Apache::Const; #defaults to :common
  +
  +# -compile puts constants into the Apache:: namespace
  +use Apache::Const -compile => qw(:http :common 
  +                                 TAKE23 &OPT_EXECCGI
  +                                 DECLINE_CMD DIR_MAGIC_TYPE 
  +                                 CRLF);
  +
  +# without -compile, constants are in the
  +# caller namespace.  also defaults to :common
  +use Apache::Const;
   
   plan tests => 16;
   
  -ok REDIRECT == 302;
  -ok AUTH_REQUIRED == 401;
  -ok OK == 0;
  -ok Apache::OK == 0;
  -ok Apache::DECLINED == -1;
  -ok Apache::HTTP_GONE == 410;
  -ok Apache::OPT_EXECCGI;
  +ok t_cmp(302, REDIRECT, 'REDIRECT');
  +
  +ok t_cmp(401, AUTH_REQUIRED, 'AUTH_REQUIRED');
  +
  +ok t_cmp(0, OK, 'OK');
  +
  +ok t_cmp(0, Apache::OK, 'Apache::OK');
  +
  +ok t_cmp(-1, Apache::DECLINED, 'Apache::DECLINED');
  +
  +ok t_cmp(410, Apache::HTTP_GONE, 'Apache::HTTP_GONE');
  +
  +ok t_cmp('httpd/unix-directory', 
  +         Apache::DIR_MAGIC_TYPE, 
  +         'Apache::DIR_MAGIC_TYPE');
  +
  +# the rest of the tests don't fit into the t_cmp() meme
  +# for one reason or anothre...
  +
  +print "testing Apache::OPT_EXECCGI is defined\n";
  +ok defined Apache::OPT_EXECCGI;
  +
  +print "testing Apache::DECLINE_CMD\n";
   ok Apache::DECLINE_CMD eq "\x07\x08";
  -ok Apache::DIR_MAGIC_TYPE eq "httpd/unix-directory";
  -# will fail on EBCDIC
  -# kudos to mod_perl if someone actually reports it
  -ok Apache::CRLF eq "\015\012";
   
  +# try and weed out EBCDIC - this is the test httpd uses
  +if (chr(0xC1) eq 'A') {
  +    print "testing Apache::CRLF (EBCDIC)\n";
  +    ok Apache::CRLF eq "\r\n";
  +}
  +else {
  +    print "testing Apache::CRLF (ASCII)\n";
  +    ok Apache::CRLF eq "\015\012";
  +
  +}
  +
  +print "testing M_GET not yet defined\n";
   ok ! defined &M_GET;
  +
   Apache::Const->import('M_GET');
  +
  +print "testing M_GET now defined\n";
   ok defined &M_GET;
   
  -for (qw(BOGUS :bogus)) {
  +for (qw(BOGUS :bogus -foobar)) {
  +
       eval { Apache::Const->import($_) };
  +
  +    print "testing bogus import $_\n";
       ok $@;
   }
   
  -eval { Apache::Const->import('-foobar') };
  -
  -ok $@;
  -
  +print "testing explicit call to compile()\n";
   eval { Apache::Const::compile() };
   
   ok $@;
  
  
  

Reply via email to