summaryrefslogtreecommitdiff
path: root/cpan/Test-Simple/t/Builder/reset_outputs.t
blob: b199128ad387dab643abfaec099840e6b1f5c135 (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
31
32
33
34
35
#!perl -w

BEGIN {
    if( $ENV{PERL_CORE} ) {
        chdir 't';
        @INC = ('../lib', 'lib');
    }
    else {
        unshift @INC, 't/lib';
    }
}

use Test::Builder;
use Test::More 'no_plan';

{
    my $tb = Test::Builder->create();

    # Store the original output filehandles and change them all.
    my %original_outputs;

    open my $fh, ">", "dummy_file.tmp";
    END { 1 while unlink "dummy_file.tmp"; }
    for my $method (qw(output failure_output todo_output)) {
        $original_outputs{$method} = $tb->$method();
        $tb->$method($fh);
        is $tb->$method(), $fh;
    }

    $tb->reset_outputs;

    for my $method (qw(output failure_output todo_output)) {
        is $tb->$method(), $original_outputs{$method}, "reset_outputs() resets $method";
    }
}