summaryrefslogtreecommitdiff
path: root/lib/Test/Simple/t/is_fh.t
blob: 2661f6869f4beb7350343cb080bdd78f7c2253e5 (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
#!/usr/bin/perl -w

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

use strict;
use Test::More tests => 8;
use TieOut;

ok( !Test::Builder->_is_fh("foo"), 'string is not a filehandle' );
ok( !Test::Builder->_is_fh(''),    'empty string' );
ok( !Test::Builder->_is_fh(undef), 'undef' );

ok( open(FILE, '>foo') );
END { close FILE; unlink 'foo' }

ok( Test::Builder->_is_fh(*FILE) );
ok( Test::Builder->_is_fh(\*FILE) );
ok( Test::Builder->_is_fh(*FILE{IO}) );

tie *OUT, 'TieOut';
ok( Test::Builder->_is_fh(*OUT) );