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