Acme-Test-Buffy
view release on metacpan or search on metacpan
lib/Acme/Test/Buffy.pm view on Meta::CPAN
package Acme::Test::Buffy;
# turn on strict. If this was perl 5.6.0 I'd turn on warnings too, but
# testing scripts normally work on perls all the way back to 5.004
# so I can't say that.
use strict;
#use warnings;
# declare the global vars for exporter and isa and stuff. If this
# was 5.6.0 we could use our
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
# this is the first version of the module
$VERSION = "0.02";
# load the test builder class. This class contains all the methods
# that you use to emit test results.
use Test::Builder;
# get the tester. Despite being called 'new', this simply returns the
# one and only tester object - this is what is known as a singleton
# class. Essentially this means that all Test::Builder objects are
# one and the same object, and this is what allows all classes that
# make use of Test::Builder to print out "ok 1" "ok 2" etc without
# getting in each other's way and mucking up the order of the numbers
my $Tester = Test::Builder->new();
# this is loading exporter. Exporter is used to export functions
# from our namespace into the callers. i.e. it's a way to make
# 'is_buffy' be able to be called from within a testing script
use Exporter; # load the class
@ISA = qw(Exporter); # set it as the base class
@EXPORT = qw(is_buffy); # want to export 'is_buffy'
@EXPORT_OK = qw(); # no other optional functions
%EXPORT_TAGS = qw(); # no groups of functions
# write some pod documentation
=head1 NAME
Acme::Test::Buffy - example Test::Builder testing module
=head1 SYNOPSIS
use Test::More tests => 1;
use Acme::Test::Buffy;
is_buffy($foo, "test foo is Buffy");
=head1 DESCRIPTION
The reason for writing this module is to demonstrate how you
can write testing modules that work together with B<Test::Builder>.
It also shows how to test such modules with B<Test::Builder::Tester>.
Look at the source code (which is heavily commented) for further
enlightenment.
This module simply exports one testing function that tests if a string
is the same as "Buffy" (case sensitive.)
=cut
# here's where we define the subroutine "is_buffy" that will be
# exported. Note the prototype that does the right thing. More
# can be found out about prototypes in the 'perlsub' perldoc.
( run in 1.036 second using v1.01-cache-2.11-cpan-df04353d9ac )