Acme-Test-42
view release on metacpan or search on metacpan
lib/Acme/Test/42.pm view on Meta::CPAN
package Acme::Test::42;
use strict;
our $VERSION = 0.1;
use Test::Builder::Module;
our @ISA = qw(Test::Builder::Module);
our @EXPORT = qw(ok not_ok);
my $CLASS = __PACKAGE__;
sub ok($;$) {
return $CLASS->builder->ok($_[0] eq 42, $_[1]);
}
sub not_ok($;$) {
return $CLASS->builder->ok($_[0] ne 42, $_[1]);
}
42;
__END__
=head1 NAME
Acme::Test::42 - Test the answer to ultimate question
=head1 SYNOPSIS
use Acme::Test::42 qw(no_plan);
# . . .
ok($answer, 'Answer to the question');
not_ok($answer / 2, 'Not an answer');
=head1 ABSTRACT
Acme::Test::42 provides a mechanism for probing if the answer is correct.
=head1 DESCRIPTION
Acme::Test::42 exports two subroutines, C<ok> and C<not_ok>, each of them expects two arguments:
the answer and optional comment.
The module is based on standard L<Test::Builder> and follows the L<TAP> standard but unlike
Test::Simple and Test::More does not expect true or false values and checks if the given
value is an answer to the ultimate question of life, the Universe, and everything.
Perl people often use this answer in their talks
(see L<http://www.slideshare.net/newsearch/slideshow?q=perl>) and as a boolean value
returned by Perl packages (see L<Acme::ReturnValue>), which makes Acme::Test::42 so important.
t/42_test.t view on Meta::CPAN
use Acme::Test::42 qw(no_plan);
use strict;
ok(42, 'Bare 42');
ok("42", '42 as a string');
ok(42.0, '42 as a number');
not_ok(42.01, 'Above');
not_ok(41.99, 'Below');
ok(answer_to_the_ultimateq_question_of_life_the_universe_and_everything(), 'Answer to the Ultimate Question of Life, the Universe, and Everything');
sub answer_to_the_ultimateq_question_of_life_the_universe_and_everything {
42
}
( run in 0.588 second using v1.01-cache-2.11-cpan-cc502c75498 )