1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
package Counter;
use strict;
use warnings;
use parent 'Collector';
sub _counter
{
my $self = shift;
if (@_)
{
$self->{_counter} = shift;
}
return $self->{_counter};
}
sub _increment
{
my $self = shift;
$self->_counter($self->_counter + 1);
return;
}
sub _reset
{
my $self = shift;
$self->_counter(0);
return;
}
sub _calc_op_callback {
my $self = shift;
return sub {
return $self->_increment();
};
}
sub test
{
my ($self, $value, $blurb) = @_;
local $Test::Builder::Level = $Test::Builder::Level + 1;
Test::More::is ($self->_counter(), $value, $blurb);
$self->_reset;
return;
}
1;
|