Subject: | Add test_pass() to Match test_fail() |
This patch adds a test_pass() function to simplify marking passing tests. This obviates the need to mark "ok 1" with the description.
--- 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