File: counter.t

package info (click to toggle)
libdata-perl-perl 0.002011-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 252 kB
  • sloc: perl: 364; makefile: 2
file content (32 lines) | stat: -rw-r--r-- 461 bytes parent folder | download | duplicates (4)
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
use Test::More;
use Data::Perl;
use Scalar::Util qw/refaddr/;

use strict;

# constructor
is ref(counter(1)), 'Data::Perl::Counter', 'constructor shortcut works';

my $c = counter(5);
is $$c, 5, 'nondefault set works';

# inc
$c->inc;
is $$c, 6, 'inc 1 works';

$c->inc(3);
is $$c, 9, 'inc n works';

# dec
$c = counter(4);
$c->dec;
is $$c, 3, 'dec 1 works';

$c->dec(2);
is $$c, 1, 'dec n works';

# reset
$c->reset;
is $$c, 0, 'reset works';

done_testing();