home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / tsw / TSW_3.4.0.exe / Apache2 / perl / BaseCacheTester.pm < prev    next >
Encoding:
Perl POD Document  |  2003-04-15  |  2.8 KB  |  163 lines

  1. ######################################################################
  2. # $Id: BaseCacheTester.pm,v 1.8 2003/04/15 14:46:15 dclinton Exp $
  3. # Copyright (C) 2001-2003 DeWitt Clinton  All Rights Reserved
  4. #
  5. # Software distributed under the License is distributed on an "AS
  6. # IS" basis, WITHOUT WARRANTY OF ANY KIND, either expressed or
  7. # implied. See the License for the specific language governing
  8. # rights and limitations under the License.
  9. ######################################################################
  10.  
  11.  
  12. package Cache::BaseCacheTester;
  13.  
  14.  
  15. use strict;
  16.  
  17.  
  18. sub new
  19. {
  20.   my ( $proto, $base_test_count ) = @_;
  21.   my $class = ref( $proto ) || $proto;
  22.   my $self  = {};
  23.   bless ( $self, $class );
  24.  
  25.   $base_test_count = defined $base_test_count ? $base_test_count : 0 ;
  26.  
  27.   $self->_set_test_count( $base_test_count );
  28.  
  29.   return $self;
  30. }
  31.  
  32.  
  33. sub ok
  34. {
  35.   my ( $self ) = @_;
  36.  
  37.   my $test_count = $self->_get_test_count( );
  38.  
  39.   print "ok $test_count\n";
  40.  
  41.   $self->_increment_test_count( );
  42. }
  43.  
  44.  
  45. sub not_ok
  46. {
  47.   my ( $self, $message ) = @_;
  48.  
  49.   my $test_count = $self->_get_test_count( );
  50.  
  51.   print "not ok $test_count # failed '$message'\n";
  52.  
  53.   $self->_increment_test_count( );
  54. }
  55.  
  56.  
  57. sub skip
  58. {
  59.   my ( $self, $message ) = @_;
  60.  
  61.   my $test_count = $self->_get_test_count( );
  62.  
  63.   print "ok $test_count # skipped $message \n";
  64.  
  65.   $self->_increment_test_count( );
  66. }
  67.  
  68.  
  69. sub _set_test_count
  70. {
  71.   my ( $self, $test_count ) = @_;
  72.  
  73.   $self->{_Test_Count} = $test_count;
  74. }
  75.  
  76.  
  77. sub _get_test_count
  78. {
  79.   my ( $self ) = @_;
  80.  
  81.   return $self->{_Test_Count};
  82. }
  83.  
  84.  
  85. sub _increment_test_count
  86. {
  87.   my ( $self ) = @_;
  88.  
  89.   $self->{_Test_Count}++;
  90. }
  91.  
  92.  
  93. 1;
  94.  
  95.  
  96. __END__
  97.  
  98.  
  99. =pod
  100.  
  101. =head1 NAME
  102.  
  103. Cache::BaseCacheTester -- abstract cache tester base class
  104.  
  105. =head1 DESCRIPTION
  106.  
  107. BaseCacheTester provides functionality common to all instances of a
  108. class that will test cache implementations.
  109.  
  110. =head1 SYNOPSIS
  111.  
  112. BaseCacheTester provides functionality common to all instances of a
  113. class that will test cache implementations.
  114.  
  115.   package Cache::MyCacheTester;
  116.  
  117.   use vars qw( @ISA );
  118.   use Cache::BaseCacheTester;
  119.  
  120.   @ISA = qw( Cache::BaseCacheTester );
  121.  
  122. =head1 METHODS
  123.  
  124. =over
  125.  
  126. =item B<new( $base_test_count )>
  127.  
  128. Construct a new BaseCacheTester and initialize the test count to
  129. I<$base_test_count>.
  130.  
  131. =item B<ok( )>
  132.  
  133. Print a message to stdout in the form "ok $test_count" and
  134. incremements the test count.
  135.  
  136. =item B<not_ok( $message )>
  137.  
  138. Print a message to stdout in the form "not ok $test_count # I<$message> "
  139. and incremements the test count.
  140.  
  141. =item B<skip( $message )>
  142.  
  143. Print a message to stdout in the form "ok $test_count # skipped I<$message> "
  144. and incremements the test count.
  145.  
  146. =back
  147.  
  148. =head1 SEE ALSO
  149.  
  150. Cache::CacheTester, Cache::SizeAwareCacheTester
  151.  
  152. =head1 AUTHOR
  153.  
  154. Original author: DeWitt Clinton <dewitt@unto.net>
  155.  
  156. Last author:     $Author: dclinton $
  157.  
  158. Copyright (C) 2001-2003 DeWitt Clinton
  159.  
  160. =cut
  161.  
  162.  
  163.