}
}
-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);
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.
Their L<Test::More> counterparts behave the same, but it is not documented anywhere.
+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.