Add the original source packages to maemo, source lenny
[dh-make-perl] / dev / i386 / libtest-simple-perl / libtest-simple-perl-0.80 / t / tbt_02fhrestore.t
1 #!/usr/bin/perl
2
3 use Test::Builder::Tester tests => 4;
4 use Test::More;
5 use Symbol;
6
7 # create temporary file handles that still point indirectly
8 # to the right place
9
10 my $orig_o = gensym; 
11 my $orig_t = gensym;
12 my $orig_f = gensym; 
13
14 tie *$orig_o, "My::Passthru", \*STDOUT;
15 tie *$orig_t, "My::Passthru", \*STDERR;
16 tie *$orig_f, "My::Passthru", \*STDERR;
17
18 # redirect the file handles to somewhere else for a mo
19
20 use Test::Builder;
21 my $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
29 test_out("ok 1 - tested");
30 ok(1,"tested");
31 test_test("standard test okay");
32
33 # now check that they were restored okay
34
35 ok($orig_o == $t->output(), "output file reconnected");
36 ok($orig_t == $t->todo_output(), "todo output file reconnected");
37 ok($orig_f == $t->failure_output(), "failure output file reconnected");
38
39 #####################################################################
40
41 package My::Passthru;
42
43 sub PRINT  {
44     my $self = shift;
45     my $handle = $self->[0];
46     print $handle @_;
47 }
48
49 sub TIEHANDLE {
50     my $class = shift;
51     my $self = [shift()];
52     return bless $self, $class;
53 }
54
55 sub READ {}
56 sub READLINE {}
57 sub GETC {}
58 sub FILENO {}