Skip Menu |
 

This queue is for tickets about the Test-Builder-Tester CPAN distribution.

Report information
The Basics
Id: 11317
Status: open
Priority: 0/
Queue: Test-Builder-Tester

People
Owner: Nobody in particular
Requestors: chromatic [...] wgz.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: (no value)

Attachments


Subject: Add test_pass() to Match test_fail()
Download (untitled) / with headers
text/plain 134b
This patch adds a test_pass() function to simplify marking passing tests. This obviates the need to mark "ok 1" with the description.
Download test_pass.patch
text/x-diff 2.1k
--- lib/Test/Builder/Tester.pm~ 2005-01-29 13:40:10.000000000 -0800 +++ lib/Test/Builder/Tester.pm 2005-01-29 13:40:03.000000000 -0800 @@ -58,7 +58,7 @@ use Exporter; @ISA = qw(Exporter); -@EXPORT = qw(test_out test_err test_fail test_diag test_test line_num); +@EXPORT = qw(test_out test_err test_fail test_diag test_test line_num test_pass); # _export_to_level and import stolen directly from Test::More. I am # the king of cargo cult programming ;-) @@ -156,7 +156,7 @@ =head2 Methods -These are the six methods that are exported as default. +These are the seven methods that are exported as default. =over 4 @@ -179,12 +179,12 @@ test_out("ok 1"); test_out("ok 2"); -Once C<test_out> or C<test_err> (or C<test_fail> or C<test_diag>) have -been called once all further output from B<Test::Builder> will be -captured by B<Test::Builder::Tester>. This means that your will not -be able perform further tests to the normal output in the normal way -until you call C<test_test> (well, unless you manually meddle with the -output filehandles) +Once C<test_out> or C<test_err> (or C<test_fail>, C<test_pass>, or +C<test_diag>) have been called once all further output from B<Test::Builder> +will be captured by B<Test::Builder::Tester>. This means that your will not be +able perform further tests to the normal output in the normal way until you +call C<test_test> (well, unless you manually meddle with the output +filehandles) =cut @@ -242,6 +242,29 @@ $err->expect("# Failed test ($0 at line $line)"); } +=item test_pass + +Because the standard success message that B<Test::Builder> produces +whenever a test passes will be common in your test error +output, rather than forcing you to call C<test_out> with the string +all the time like so + + test_out("ok 1 - some test name here"); + +C<test_pass> exists as a convenience method that you can call instead. It +takes one optional argument, the test description from the test you expect to +pass. + +=cut + +sub test_pass(;$) +{ + my $mess = "ok 1"; + $mess .= ' - ' . shift if @_; + _start_testing() unless $testing; + $out->expect( $mess, @_ ); +} + =item test_diag As most of the remaining expected output to the error stream will be
From: Joseph Brenner (doom [...] kzsu.stanford.edu)
Download (untitled) / with headers
text/plain 593b
On Tue Feb 01 14:20:54 2005, CHROMATIC wrote: Show quoted text
> This patch adds a test_pass() function to simplify marking passing > tests. This obviates the need to mark "ok 1" with the description.
I just wanted to point out that the authors of "Perl Testing A Developer's Notebook", accidentally used this feature in one of their examples, which has the potential to cause quite a bit of confusion among readers who do not compulsively check errata lists. It may seem somewhat backwards, but it would be a good idea to expedite this patch, since the software is easier to update than dead trees.
Download (untitled) / with headers
text/plain 188b
I removed this along with test_fail() as I figure since it and test_pass() have a similar interface, if test_fail()'s interface is redesigned we're going to have to redo test_pass(), too.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.