File Coverage

blib/lib/Cache/BaseCacheTester.pm
Criterion Covered Total %
statement 20 28 71.4
branch 1 2 50.0
condition 1 3 33.3
subroutine 6 8 75.0
pod 4 4 100.0
total 32 45 71.1


line stmt bran cond sub pod time code
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 4     4   60 use strict;
  4         108  
  4         125  
16              
17              
18             sub new
19             {
20 6     6 1 3055   my ( $proto, $base_test_count ) = @_;
21 6   33     102   my $class = ref( $proto ) || $proto;
22 6         57   my $self = {};
23 6         152   bless ( $self, $class );
24              
25 6 50       114   $base_test_count = defined $base_test_count ? $base_test_count : 0 ;
26              
27 6         94   $self->_set_test_count( $base_test_count );
28              
29 6         160   return $self;
30             }
31              
32              
33             sub ok
34             {
35 158     158 1 1451   my ( $self ) = @_;
36              
37 158         1626   my $test_count = $self->_get_test_count( );
38              
39 158         28483   print "ok $test_count\n";
40              
41 158         1781   $self->_increment_test_count( );
42             }
43              
44              
45             sub not_ok
46             {
47 0     0 1 0   my ( $self, $message ) = @_;
48              
49 0         0   my $test_count = $self->_get_test_count( );
50              
51 0         0   print "not ok $test_count # failed '$message'\n";
52              
53 0         0   $self->_increment_test_count( );
54             }
55              
56              
57             sub skip
58             {
59 0     0 1 0   my ( $self, $message ) = @_;
60              
61 0         0   my $test_count = $self->_get_test_count( );
62              
63 0         0   print "ok $test_count # skipped $message \n";
64              
65 0         0   $self->_increment_test_count( );
66             }
67              
68              
69             sub _set_test_count
70             {
71 6     6   59   my ( $self, $test_count ) = @_;
72              
73 6         177   $self->{_Test_Count} = $test_count;
74             }
75              
76              
77             sub _get_test_count
78             {
79 160     160   1523   my ( $self ) = @_;
80              
81 160         1759   return $self->{_Test_Count};
82             }
83              
84              
85             sub _increment_test_count
86             {
87 158     158   4988   my ( $self ) = @_;
88              
89 158         5620   $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