summaryrefslogtreecommitdiff
path: root/lib/Test/Simple/t/undef.t
blob: 00ce8b19370c83e286f6fcd92c2ccb00b8f87c53 (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/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 => 14;
use TieOut;

BEGIN { $^W = 1; }

my $warnings = '';
local $SIG{__WARN__} = sub { $warnings .= join '', @_ };

is( undef, undef,           'undef is undef');
is( $warnings, '',          '  no warnings' );

isnt( undef, 'foo',         'undef isnt foo');
is( $warnings, '',          '  no warnings' );

isnt( undef, '',            'undef isnt an empty string' );
isnt( undef, 0,             'undef isnt zero' );

like( undef, '/.*/',        'undef is like anything' );
is( $warnings, '',          '  no warnings' );

eq_array( [undef, undef], [undef, 23] );
is( $warnings, '',          'eq_array()  no warnings' );

eq_hash ( { foo => undef, bar => undef },
          { foo => undef, bar => 23 } );
is( $warnings, '',          'eq_hash()   no warnings' );

eq_set  ( [undef, undef, 12], [29, undef, undef] );
is( $warnings, '',          'eq_set()    no warnings' );


eq_hash ( { foo => undef, bar => { baz => undef, moo => 23 } },
          { foo => undef, bar => { baz => undef, moo => 23 } } );
is( $warnings, '',          'eq_hash()   no warnings' );


my $tb = Test::More->builder;

use TieOut;
my $caught = tie *CATCH, 'TieOut';
my $old_fail = $tb->failure_output;
$tb->failure_output(\*CATCH);
diag(undef);
$tb->failure_output($old_fail);

is( $caught->read, "# undef\n" );
is( $warnings, '',          'diag(undef)  no warnings' );