Acme-PETEK-Testkit
view release on metacpan or search on metacpan
lib/Acme/PETEK/Testkit.pm view on Meta::CPAN
package Acme::PETEK::Testkit;
use strict;
use vars qw($VERSION);
=head1 NAME
Acme::PETEK::Testkit - Perl module codebase for Tester's Toolkit
=head1 VERSION
Version 1.00
=cut
$VERSION = '1.00';
=head1 SYNOPSIS
This Perl module is intended to be a collection of sample code for
the Tester's Toolkit presentation at YAPC::NA 2005 by the author.
=for example begin
use Acme::PETEK::Testkit;
my $c = Acme::PETEK::Testkit->new;
$c->incr;
=for example end
=begin testing
my $c = Acme::PETEK::Testkit->new;
$c->incr;
cmp_ok($c->value,'==',1,'incr sends value to 1');
=end testing
=head1 CONSTRUCTOR
=head2 $kit = Acme::PETEK::Testkit->new()
Creates a new C<Acme::PETEK::Testkit> object,
which will be used for the object interface below.
=cut
sub new {
my $class = shift;
my $self = {
_counter => 0,
};
return bless $self, $class;
}
=head1 OBJECT METHODS
=head2 $kit->reset( $int );
Resets the value of the stored counter, optionally setting it to $int.
=cut
sub reset {
my ($self, $int) = @_;
$int = 0 unless defined($int);
$self->{'_counter'} = $int;
return $self->value;
}
=head2 $kit->incr( $int );
Increment the counter by 1. If C<$int> is provided, increment by that.
Returns the current value of the counter.
=cut
sub incr {
my ($self, $int) = @_;
$int = 1 unless defined($int);
$self->{'_counter'} += $int;
return $self->value;
}
=head2 $kit->decr( $int );
Decrement the counter by 1. If C<$int> is provided, decrement by that.
Returns the current value of the counter.
=cut
sub decr {
my ($self, $int) = @_;
$int = 1 unless defined($int);
$self->{'_counter'} -= $int;
return $self->value;
}
=head2 $kit->value;
Returns the current value of the counter.
=cut
sub value {
my $self = shift;
return $self->{'_counter'};
}
=head2 $kit->sign
Returns "positive" or "negative" based on the value of the counter.
( run in 2.216 seconds using v1.01-cache-2.11-cpan-524268b4103 )