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
lib/Acme/Test/Buffy.pm view on Meta::CPAN
# return a true value (don't have to do this but it's nice)
return 1;
}
else
{
# We failed. We want to test Test::Builder to print something
# like:
# Failed test at line <line number>
# Expected 'Buffy' but got '<what we got>' instead
# that is to say we print failure first, _then_ the extra diag
# stuff that will help people debug the code better.
# print not okay with the right text ("not ok <number> - <text>")
$Tester->ok(0,$text);
# print diagnostics of *why* it failed. Don't just print to
# STDERR this is bad and wrong as it prevents the test output
# being properly caught. Note the "\n" on the end of the
# line.
$Tester->diag("Expected 'Buffy' but got '$maybe_buffy' instead\n");
t/01basic.t view on Meta::CPAN
###
# declare what we get if we get the right text
test_out("ok 1 - some text");
# run the test (somewhere between the test_out and the test_test
# meaning that the test output will be captured and not treated as a
# real test)
is_buffy("Buffy","some text");
# say we're done and compare what we got with what we thought we
# should have got
test_test("works when correct");
###
# check that when we give it the right thing we get the right thing
# back, even if we don't specify the name of the test
###
# declare what we get if we get the right text. Note we start from
# one again as we're numbering from the number of tests we're testing
# with test out.
test_out("ok 1 - is 'Buffy'");
# run the test (somewhere between the test_out and the test_test
# meaning that the test output will be captured and not treated as a
# real test)
is_buffy("Buffy");
# say we're done and compare what we got with what we thought we
# should have got
test_test("works when correct with default text");
###
# check that when we give it the wrong thing we get the right thing
# back, including useful diagnostic test.
###
# the right text we declare is now "not ok" whatever
test_out("not ok 1 - is 'Buffy'");
t/01basic.t view on Meta::CPAN
# and this has the diagnostic test that the module will print
# out. Check that it's right. Note no '\n' at end.
test_diag("Expected 'Buffy' but got 'buffy' instead");
# run the test (somewhere between the test_out and the test_test
# meaning that the test output will be captured and not treated as a
# real test)
is_buffy("buffy");
# say we're done and compare what we got with what we thought we
# should have got
test_test("works when incorrect");
# done.
( run in 0.648 second using v1.01-cache-2.11-cpan-483215c6ad5 )