summaryrefslogtreecommitdiff
path: root/t/lib/Test/More/Catch.pm
blob: aed94682d4da185ca48479fddaa10cff3cfc4c1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# For testing Test::More;
package Catch;

my $out = tie *Test::Simple::TESTOUT, 'Catch';
tie *Test::More::TESTOUT, 'Catch', $out;
my $err = tie *Test::More::TESTERR, 'Catch';
tie *Test::Simple::TESTERR, 'Catch', $err;

# We have to use them to shut up a "used only once" warning.
() = (*Test::More::TESTOUT, *Test::More::TESTERR);

sub caught { return $out, $err }


sub PRINT  {
    my $self = shift;
    $$self .= join '', @_;
}

sub TIEHANDLE {
    my($class, $self) = @_;
    my $foo = '';
    $self = $self || \$foo;
    return bless $self, $class;
}
sub READ {}
sub READLINE {}
sub GETC {}

1;