Debian Codegraph @

t/lib/Counter.pm

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