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