perl-modperl-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject cvs commit: modperl-2.0/t/response/TestCompat request.pm
Date Fri, 11 Apr 2003 07:34:04 GMT
stas        2003/04/11 00:34:03

  Modified:    .        Changes
               lib/Apache compat.pm
               t/response/TestCompat request.pm
  Log:
  Add a backcompat wrapper for $r->notes (mp2 supports only the
  APR::Table API)
  
  Revision  Changes    Path
  1.170     +3 -0      modperl-2.0/Changes
  
  Index: Changes
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/Changes,v
  retrieving revision 1.169
  retrieving revision 1.170
  diff -u -r1.169 -r1.170
  --- Changes	10 Apr 2003 02:00:19 -0000	1.169
  +++ Changes	11 Apr 2003 07:34:03 -0000	1.170
  @@ -10,6 +10,9 @@
   
   =item 1.99_09-dev
   
  +Add a backcompat wrapper for $r->notes (mp2 supports only the
  +APR::Table API) [Stas]
  +
   Add a script mp2bug and a target 'make bugreport', so people can use
   bugreporting during the build and after modperl is installed. [Stas]
   
  
  
  
  1.85      +9 -0      modperl-2.0/lib/Apache/compat.pm
  
  Index: compat.pm
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/lib/Apache/compat.pm,v
  retrieving revision 1.84
  retrieving revision 1.85
  diff -u -r1.84 -r1.85
  --- compat.pm	9 Mar 2003 08:57:55 -0000	1.84
  +++ compat.pm	11 Apr 2003 07:34:03 -0000	1.85
  @@ -239,6 +239,15 @@
           : scalar($r->table_get_set(scalar($r->err_headers_out), @_));
   }
   
  +{
  +    my $notes_sub = *Apache::RequestRec::notes{CODE};
  +    *Apache::RequestRec::notes = sub {
  +        my $r = shift;
  +        return wantarray()
  +            ?       ($r->table_get_set(scalar($r->$notes_sub), @_))
  +            : scalar($r->table_get_set(scalar($r->$notes_sub), @_));
  +    }
  +}
   
   sub register_cleanup {
       shift->pool->cleanup_register(@_);
  
  
  
  1.3       +29 -1     modperl-2.0/t/response/TestCompat/request.pm
  
  Index: request.pm
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/t/response/TestCompat/request.pm,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- request.pm	21 Oct 2002 20:18:10 -0000	1.2
  +++ request.pm	11 Apr 2003 07:34:03 -0000	1.3
  @@ -16,7 +16,7 @@
   sub handler {
       my $r = shift;
   
  -    plan $r, tests => 16;
  +    plan $r, tests => 20;
   
       $r->send_http_header('text/plain');
   
  @@ -69,6 +69,34 @@
                   my $got = $r->$sub_test($key);
                   ok t_cmp($exp, $got, "\$r->$sub_test unset()");
               }
  +        }
  +    }
  +
  +
  +    # $r->notes
  +    {
  +        my $key = 'notes-test';
  +        # get/set scalar context
  +        {
  +            my $val = 'ok';
  +            $r->notes($key => $val);
  +            ok t_cmp($r->notes->get($key), $val, "\$r->notes->get(\$key)");
  +            ok t_cmp($r->notes($key),      $val, "\$r->notes(\$key)");
  +        }
  +
  +        # unset
  +        {
  +            my $exp = undef;
  +            $r->notes($key => $exp);
  +            my $got = $r->notes($key);
  +            ok t_cmp($exp, $got, "\$r->notes unset()");
  +        }
  +
  +        # get/set list context
  +        {
  +            my @exp = qw(foo bar);
  +            $r->notes->add($key => $_) for @exp;
  +            ok t_cmp(\@exp, [ $r->notes($key) ], "\$r->notes in list context");
           }
       }
   
  
  
  

Mime
View raw message