Acme::PETEK::Testkit - Perl module codebase for Tester's Toolkit


Acme-PETEK-Testkit documentation Contained in the Acme-PETEK-Testkit distribution.

Index


Code Index:

NAME

Top

Acme::PETEK::Testkit - Perl module codebase for Tester's Toolkit

VERSION

Top

Version 1.00

SYNOPSIS

Top

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.

  use Acme::PETEK::Testkit;
  my $c = Acme::PETEK::Testkit->new;
  $c->incr;

CONSTRUCTOR

Top

$kit = Acme::PETEK::Testkit->new()

Creates a new Acme::PETEK::Testkit object, which will be used for the object interface below.

OBJECT METHODS

Top

$kit->reset( $int );

Resets the value of the stored counter, optionally setting it to $int.

$kit->incr( $int );

Increment the counter by 1. If $int is provided, increment by that. Returns the current value of the counter.

$kit->decr( $int );

Decrement the counter by 1. If $int is provided, decrement by that. Returns the current value of the counter.

$kit->value;

Returns the current value of the counter.

$kit->sign

Returns "positive" or "negative" based on the value of the counter.

CLASS METHODS

Top

add($int, $int)

Adds the two integers together and returns the result.

subtract($int, $int)

Subtracts the second integer from the first and returns the result.

AUTHOR

Top

Pete Krawczyk, <petek@cpan.org>

BUGS

Top

Fix 'em yourself! :-)

ALSO SEE

Top

Slides from the presentation are available at http://www.bsod.net/~petek/slides/.

COPYRIGHT & LICENSE

Top


Acme-PETEK-Testkit documentation Contained in the Acme-PETEK-Testkit distribution.
package Acme::PETEK::Testkit;

use strict;
use vars qw($VERSION);

$VERSION = '1.00';

sub new {
	my $class = shift;
	my $self = {
		_counter => 0,
	};
	return bless $self, $class;
}

sub reset {
	my ($self, $int) = @_;
	$int = 0 unless defined($int);
	$self->{'_counter'} = $int;
	return $self->value;
}

sub incr {
	my ($self, $int) = @_;
	$int = 1 unless defined($int);
	$self->{'_counter'} += $int;
	return $self->value;
}

sub decr {
	my ($self, $int) = @_;
	$int = 1 unless defined($int);
	$self->{'_counter'} -= $int;
	return $self->value;
}

sub value {
	my $self = shift;
	return $self->{'_counter'};
}

sub sign {
	my $self = shift;
	return 'negative' if $self->{'_counter'} < 0;
	return 'positive';
}

sub add {
	my ($int1, $int2) = @_;
	return $int1 + $int2;
}

sub subtract {
	my ($int1, $int2) = @_;
	return $int1 - $int2;
}

1; # End of Acme::PETEK::Testkit