perl-modperl-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From do...@apache.org
Subject cvs commit: modperl-2.0/t/response/TestModperl dir_config.pm
Date Tue, 13 Nov 2001 18:35:08 GMT
dougm       01/11/13 10:35:08

  Modified:    t/modperl .cvsignore
               t/response/TestAPI request_rec.pm server_rec.pm
  Added:       t/response/TestModperl dir_config.pm
  Log:
  giving dir_config its own test
  
  Revision  Changes    Path
  1.6       +1 -0      modperl-2.0/t/modperl/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/t/modperl/.cvsignore,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- .cvsignore	2001/11/13 18:09:19	1.5
  +++ .cvsignore	2001/11/13 18:35:08	1.6
  @@ -3,3 +3,4 @@
   printf.t
   print.t
   pnotes.t
  +dir_config.t
  
  
  
  1.12      +1 -96     modperl-2.0/t/response/TestAPI/request_rec.pm
  
  Index: request_rec.pm
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/t/response/TestAPI/request_rec.pm,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- request_rec.pm	2001/11/13 18:09:19	1.11
  +++ request_rec.pm	2001/11/13 18:35:08	1.12
  @@ -11,7 +11,7 @@
   sub handler {
       my $r = shift;
   
  -    plan $r, tests => 49;
  +    plan $r, tests => 41;
   
       #Apache->request($r); #PerlOptions +GlobalRequest takes care
       my $gr = Apache->request;
  @@ -89,81 +89,6 @@
   
       #user
   
  -    #<- dir_config tests ->#
  -
  -    # this test doesn't test all $r->dir_config->*(), since
  -    # dir_config() returns a generic APR::Table which is tested in
  -    # apr/table.t.
  -
  -    # object test
  -    my $dir_config = $r->dir_config;
  -    ok defined $dir_config && ref($dir_config) eq 'APR::Table';
  -
  -    # PerlAddVar ITERATE2 test
  -    {
  -        my $key = make_key('1');
  -        my @received = $dir_config->get($key);
  -        my @expected = qw(1_SetValue 2_AddValue 3_AddValue 4_AddValue);
  -        ok t_cmp(
  -                 \@expected,
  -                 \@received,
  -                 "testing PerlAddVar ITERATE2",
  -                )
  -    }
  -
  -    {
  -        my $key = make_key('0');
  -
  -        # object interface test in a scalar context (for a single
  -        # PerlSetVar key)
  -        ok t_cmp("SetValue0",
  -                 $dir_config->get($key),
  -                 qq{\$dir_config->get("$key")});
  -
  -        #  direct fetch test in a scalar context (for a single
  -        #  PerlSetVar)
  -        ok t_cmp("SetValue0",
  -                 $r->dir_config($key),
  -                 qq{\$r->dir_config("$key")});
  -    }
  -
  -    # test non-existent key
  -    {
  -        my $key = make_key();
  -        ok t_cmp(undef,
  -                 $r->dir_config($key),
  -                 qq{\$r->dir_config("$key")});
  -    }
  -
  -    # test set interface
  -    {
  -        my $key = make_key();
  -        my $val = "DirConfig";
  -        $r->dir_config($key => $val);
  -        ok t_cmp($val,
  -                 $r->dir_config($key),
  -                 qq{\$r->dir_config($key => $val)});
  -    }
  -
  -    # test unset interface
  -    {
  -        my $key = make_key();
  -        $r->dir_config($key => 'whatever');
  -        $r->dir_config($key => undef);
  -        ok t_cmp(undef,
  -                 $r->dir_config($key),
  -                 qq{\$r->dir_config($key => undef)});
  -    }
  -
  -    # test PerlSetVar set in base config
  -    {
  -        my $key = make_key('_set_in_Base');
  -        ok t_cmp("BaseValue",
  -                 $r->dir_config($key),
  -                 qq{\$r->dir_config("$key")});
  -    }
  -
  -    #no_cache
       ok $r->no_cache || 1;
   
       {
  @@ -209,26 +134,6 @@
       Apache::OK;
   }
   
  -my $key_base = "TestAPI__request_rec_Key";
  -my $counter  = 0;
  -sub make_key{
  -    return $key_base .
  -        (defined $_[0]
  -            ? $_[0]
  -            : unpack "H*", pack "n", ++$counter . rand(100) );
  -}
   1;
   __END__
  -<Base>
  -    PerlSetVar TestAPI__request_rec_Key_set_in_Base BaseValue
  -</Base>
   PerlOptions +GlobalRequest
  -
  -PerlSetVar TestAPI__request_rec_Key0 SetValue0
  -
  -
  -PerlSetVar TestAPI__request_rec_Key1 ToBeLost
  -PerlSetVar TestAPI__request_rec_Key1 1_SetValue
  -PerlAddVar TestAPI__request_rec_Key1 2_AddValue
  -PerlAddVar TestAPI__request_rec_Key1 3_AddValue 4_AddValue
  -
  
  
  
  1.6       +1 -47     modperl-2.0/t/response/TestAPI/server_rec.pm
  
  Index: server_rec.pm
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/t/response/TestAPI/server_rec.pm,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- server_rec.pm	2001/10/10 02:55:15	1.5
  +++ server_rec.pm	2001/11/13 18:35:08	1.6
  @@ -14,7 +14,7 @@
   
       my $s = $r->server;
   
  -    plan $r, tests => 21;
  +    plan $r, tests => 17;
   
       ok $s;
   
  @@ -60,46 +60,6 @@
   
       ok $s->limit_req_fields;
   
  -    
  -    #<- dir_config tests ->#
  -
  -    # this test doesn't test all $s->dir_config->*(), since
  -    # dir_config() returns a generic APR::Table which is tested in
  -    # apr/table.t.
  -
  -    # object test
  -    my $dir_config = $s->dir_config;
  -    ok defined $dir_config && ref($dir_config) eq 'APR::Table';
  -
  -    # PerlAddVar ITERATE2 test
  -    {
  -        my $key = 'TestAPI__server_rec_Key_set_in_Base';
  -        my @received = $dir_config->get($key);
  -        my @expected = qw(1_SetValue 2_AddValue 3_AddValue);
  -        ok t_cmp(
  -                 \@expected,
  -                 \@received,
  -                 "testing PerlAddVar ITERATE2 in $s",
  -                )
  -    }
  -
  -    {
  -        # base server test
  -        my $bs = Apache->server;
  -        ok t_cmp(
  -               'Apache::Server',
  -               ($bs && ref($bs)),
  -               "base server's object retrieval"
  -              );
  -
  -        my $key = 'TestAPI__server_rec_Key_set_in_Base';
  -        ok t_cmp(
  -               '1_SetValue',
  -               scalar ($bs->dir_config->get($key)),
  -               "read dir_config of the base server"
  -              );
  -    }
  -
       Apache::OK;
   
   }
  @@ -107,9 +67,3 @@
   1;
   
   __END__
  -<Base>
  -    PerlSetVar TestAPI__server_rec_Key_set_in_Base 1_SetValue
  -    PerlAddVar TestAPI__server_rec_Key_set_in_Base 2_AddValue 3_AddValue
  -</Base>
  -PerlSetVar TestAPI__server_rec_Key_set_in_Base WhatEver
  -
  
  
  
  1.1                  modperl-2.0/t/response/TestModperl/dir_config.pm
  
  Index: dir_config.pm
  ===================================================================
  package TestModperl::dir_config;
  
  use strict;
  use warnings FATAL => 'all';
  
  use Apache::Test;
  use Apache::TestUtil;
  
  use Apache::Const -compile => 'OK';
  
  sub handler {
      my $r = shift;
  
      plan $r, tests => 12;
  
      #Apache::RequestRec::dir_config tests
  
      # this test doesn't test all $r->dir_config->*(), since
      # dir_config() returns a generic APR::Table which is tested in
      # apr/table.t.
  
      # object test
      my $dir_config = $r->dir_config;
      ok defined $dir_config && ref($dir_config) eq 'APR::Table';
  
      # PerlAddVar ITERATE2 test
      {
          my $key = make_key('1');
          my @received = $dir_config->get($key);
          my @expected = qw(1_SetValue 2_AddValue 3_AddValue 4_AddValue);
  
          ok t_cmp(\@expected, \@received,
                   'testing PerlAddVar ITERATE2');
      }
  
      {
          my $key = make_key('0');
  
          # object interface test in a scalar context (for a single
          # PerlSetVar key)
          ok t_cmp('SetValue0',
                   $dir_config->get($key),
                   qq{\$dir_config->get("$key")});
  
          #  direct fetch test in a scalar context (for a single
          #  PerlSetVar)
          ok t_cmp('SetValue0',
                   $r->dir_config($key),
                   qq{\$r->dir_config("$key")});
      }
  
      # test non-existent key
      {
          my $key = make_key();
  
          ok t_cmp(undef,
                   $r->dir_config($key),
                   qq{\$r->dir_config("$key")});
      }
  
      # test set interface
      {
          my $key = make_key();
          my $val = "DirConfig";
  
          $r->dir_config($key => $val);
  
          ok t_cmp($val,
                   $r->dir_config($key),
                   qq{\$r->dir_config($key => "$val")});
      }
  
      # test unset interface
      {
          my $key = make_key();
  
          $r->dir_config($key => 'whatever');
          $r->dir_config($key => undef);
  
          ok t_cmp(undef,
                   $r->dir_config($key),
                   qq{\$r->dir_config($key => undef)});
      }
  
      # test PerlSetVar set in base config
      {
          my $key = make_key('_set_in_Base');
  
          ok t_cmp("BaseValue",
                   $r->dir_config($key),
                   qq{\$r->dir_config("$key")});
      }
  
      #Apache::Server::dir_config tests
  
      my $s = $r->server;
  
      # this test doesn't test all $s->dir_config->*(), since
      # dir_config() returns a generic APR::Table which is tested in
      # apr/table.t.
  
      # object test
      $dir_config = $s->dir_config;
      ok defined $dir_config && ref($dir_config) eq 'APR::Table';
  
      # PerlAddVar ITERATE2 test
      {
          my $key = 'TestModperl__server_rec_Key_set_in_Base';
          my @received = $dir_config->get($key);
          my @expected = qw(1_SetValue 2_AddValue 3_AddValue);
  
          ok t_cmp(\@expected, \@received,
                   "testing PerlAddVar ITERATE2 in $s");
      }
  
      {
          # base server test
          my $bs = Apache->server;
          ok t_cmp('Apache::Server',
                   ($bs && ref($bs)),
                   "base server's object retrieval");
  
          my $key = 'TestModperl__server_rec_Key_set_in_Base';
          ok t_cmp('1_SetValue',
                   scalar ($bs->dir_config->get($key)),
                   "read dir_config of the base server");
      }
  
      Apache::OK;
  }
  
  my $key_base = "TestModperl__request_rec_Key";
  my $counter  = 0;
  
  sub make_key {
      return $key_base .
          (defined $_[0]
              ? $_[0]
              : unpack "H*", pack "n", ++$counter . rand(100));
  }
  1;
  __END__
  <Base>
      PerlSetVar TestModperl__request_rec_Key_set_in_Base BaseValue
  
      PerlSetVar TestModperl__server_rec_Key_set_in_Base 1_SetValue
      PerlAddVar TestModperl__server_rec_Key_set_in_Base 2_AddValue 3_AddValue
  </Base>
  
  PerlSetVar TestModperl__request_rec_Key0 SetValue0
  
  PerlSetVar TestModperl__request_rec_Key1 ToBeLost
  PerlSetVar TestModperl__request_rec_Key1 1_SetValue
  PerlAddVar TestModperl__request_rec_Key1 2_AddValue
  PerlAddVar TestModperl__request_rec_Key1 3_AddValue 4_AddValue
  
  PerlSetVar TestModperl__server_rec_Key_set_in_Base WhatEver
  
  
  

Mime
View raw message