]> git.vpit.fr Git - perl/modules/Test-Leaner.git/blobdiff - lib/Test/Leaner.pm
Get rid of skip_all()
[perl/modules/Test-Leaner.git] / lib / Test / Leaner.pm
index 6ae6e2b154348affc6649264b90ebf6faf309d39..4aaa5e43b4dd07be15fddccb18dd02e879ef91fa 100644 (file)
@@ -30,6 +30,24 @@ our $VERSION = '0.01';
 When profiling some L<Test::More>-based test script that contained about 10 000 unit tests, I realized that 60% of the time was spent in L<Test::Builder> itself, even though every single test actually involved a costly C<eval STRING>.
 
 This module aims to be a partial replacement to L<Test::More> in those situations where you want to run a large number of simple tests.
+Its functions behave the same as their L<Test::More> counterparts, except for the following differences :
+
+=over 4
+
+=item *
+
+Stringification isn't forced on the test operands.
+However, L</ok> honors C<'bool'> overloading, L</is> honors C<'eq'> overloading and L</cmp_ok> honors whichever overloading category corresponds to the specified operator.
+
+=item *
+
+L</pass>, L</fail>, L</ok>, L</is>, L</isnt>, L</like>, L</unlike> and L</cmp_ok> are all guaranteed to return the truth value of the test.
+
+=item *
+
+C<use_ok>, C<require_ok>, C<can_ok>, C<isa_ok>, C<new_ok>, C<subtest>, C<explain>, C<TODO> blocks and C<todo_skip> 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<skip_all $reason>
-
-=cut
-
-sub skip_all {
- @_ = (skip_all => $_[0]);
- goto &plan;
-}
-
 =head2 C<< skip $reason => $count >>
 
 =cut
@@ -500,6 +501,60 @@ END {
  }
 }
 
+=pod
+
+L<Test::Leaner> also provides some functions of its own, which are never exported.
+
+=head2 C<tap_stream [ $fh ]>
+
+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<threads::shared> cannot reliably share filehandles.
+
+Defaults to C<STDOUT>.
+
+=cut
+
+sub tap_stream (;*) {
+ if (@_) {
+  $TAP_STREAM = $_[0];
+
+  my $fh = select $TAP_STREAM;
+  $|++;
+  select $fh;
+ }
+
+ return $TAP_STREAM;
+}
+
+tap_stream *STDOUT;
+
+=head2 C<diag_stream [ $fh ]>
+
+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</tap_stream>, it can only be used as a write accessor before you start any thread, as L<threads::shared> cannot reliably share filehandles.
+
+Defaults to C<STDERR>.
+
+=cut
+
+sub diag_stream (;*) {
+ if (@_) {
+  $DIAG_STREAM = $_[0];
+
+  my $fh = select $DIAG_STREAM;
+  $|++;
+  select $fh;
+ }
+
+ return $DIAG_STREAM;
+}
+
+diag_stream *STDERR;
+
 =head1 DEPENDENCIES
 
 L<perl> 5.6.