X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FTest%2FLeaner.pm;h=4aaa5e43b4dd07be15fddccb18dd02e879ef91fa;hb=a336a31d9cdb4fff3b625ccbc5e40b146052e730;hp=6ae6e2b154348affc6649264b90ebf6faf309d39;hpb=982694f9f93cdad187a51077b5e6c48a17792870;p=perl%2Fmodules%2FTest-Leaner.git diff --git a/lib/Test/Leaner.pm b/lib/Test/Leaner.pm index 6ae6e2b..4aaa5e4 100644 --- a/lib/Test/Leaner.pm +++ b/lib/Test/Leaner.pm @@ -30,6 +30,24 @@ our $VERSION = '0.01'; When profiling some L-based test script that contained about 10 000 unit tests, I realized that 60% of the time was spent in L itself, even though every single test actually involved a costly C. This module aims to be a partial replacement to L in those situations where you want to run a large number of simple tests. +Its functions behave the same as their L counterparts, except for the following differences : + +=over 4 + +=item * + +Stringification isn't forced on the test operands. +However, L honors C<'bool'> overloading, L honors C<'eq'> overloading and L honors whichever overloading category corresponds to the specified operator. + +=item * + +L, L, L, L, L, L, L and L are all guaranteed to return the truth value of the test. + +=item * + +C, C, C, C, C, C, C, C blocks and C are not implemented. + +=back =cut @@ -52,14 +70,7 @@ BEGIN { } } -my $TAP_STREAM = *STDOUT; -my $DIAG_STREAM = *STDERR; - -for ($TAP_STREAM, $DIAG_STREAM) { - my $fh = select $_; - $|++; - select $fh; -} +my ($TAP_STREAM, $DIAG_STREAM); my ($plan, $test, $failed, $no_diag, $done_testing); @@ -149,7 +160,6 @@ sub plan { our @EXPORT = qw< plan - skip_all skip done_testing pass @@ -199,15 +209,6 @@ sub import { goto &Exporter::import; } -=head2 C - -=cut - -sub skip_all { - @_ = (skip_all => $_[0]); - goto &plan; -} - =head2 C<< skip $reason => $count >> =cut @@ -500,6 +501,60 @@ END { } } +=pod + +L also provides some functions of its own, which are never exported. + +=head2 C + +Read/write accessor for the filehandle to which the tests are outputted. +On write, it also turns autoflush on onto C<$fh>. + +Note that it can only be used as a write accessor before you start any thread, as L cannot reliably share filehandles. + +Defaults to C. + +=cut + +sub tap_stream (;*) { + if (@_) { + $TAP_STREAM = $_[0]; + + my $fh = select $TAP_STREAM; + $|++; + select $fh; + } + + return $TAP_STREAM; +} + +tap_stream *STDOUT; + +=head2 C + +Read/write accessor for the filehandle to which the diagnostics are printed. +On write, it also turns autoflush on onto C<$fh>. + +Just like L, it can only be used as a write accessor before you start any thread, as L cannot reliably share filehandles. + +Defaults to C. + +=cut + +sub diag_stream (;*) { + if (@_) { + $DIAG_STREAM = $_[0]; + + my $fh = select $DIAG_STREAM; + $|++; + select $fh; + } + + return $DIAG_STREAM; +} + +diag_stream *STDERR; + =head1 DEPENDENCIES L 5.6.