1#!/usr/bin/perl
2
3BEGIN {
4    if( $ENV{PERL_CORE} ) {
5        chdir 't';
6        @INC = '../lib';
7    }
8}
9
10use Test::Builder::Tester tests => 4;
11use Test::More;
12use Symbol;
13
14# create temporary file handles that still point indirectly
15# to the right place
16
17my $orig_o = gensym;
18my $orig_t = gensym;
19my $orig_f = gensym;
20
21tie *$orig_o, "My::Passthru", \*STDOUT;
22tie *$orig_t, "My::Passthru", \*STDERR;
23tie *$orig_f, "My::Passthru", \*STDERR;
24
25# redirect the file handles to somewhere else for a mo
26
27use Test::Builder;
28my $t = Test::Builder->new();
29
30$t->output($orig_o);
31$t->failure_output($orig_f);
32$t->todo_output($orig_t);
33
34# run a test
35
36test_out("ok 1 - tested");
37ok(1,"tested");
38test_test("standard test okay");
39
40# now check that they were restored okay
41
42ok($orig_o == $t->output(), "output file reconnected");
43ok($orig_t == $t->todo_output(), "todo output file reconnected");
44ok($orig_f == $t->failure_output(), "failure output file reconnected");
45
46#####################################################################
47
48package My::Passthru;
49
50sub PRINT  {
51    my $self = shift;
52    my $handle = $self->[0];
53    print $handle @_;
54}
55
56sub TIEHANDLE {
57    my $class = shift;
58    my $self = [shift()];
59    return bless $self, $class;
60}
61
62sub READ {}
63sub READLINE {}
64sub GETC {}
65sub FILENO {}
66