1#!/usr/bin/perl -w
2
3BEGIN {
4    if( $ENV{PERL_CORE} ) {
5        chdir 't';
6        @INC = ('../lib', 'lib');
7    }
8    else {
9        unshift @INC, 't/lib';
10    }
11}
12
13use strict;
14use Test::More tests => 14;
15use TieOut;
16
17BEGIN { $^W = 1; }
18
19my $warnings = '';
20local $SIG{__WARN__} = sub { $warnings .= join '', @_ };
21
22is( undef, undef,           'undef is undef');
23is( $warnings, '',          '  no warnings' );
24
25isnt( undef, 'foo',         'undef isnt foo');
26is( $warnings, '',          '  no warnings' );
27
28isnt( undef, '',            'undef isnt an empty string' );
29isnt( undef, 0,             'undef isnt zero' );
30
31like( undef, '/.*/',        'undef is like anything' );
32is( $warnings, '',          '  no warnings' );
33
34eq_array( [undef, undef], [undef, 23] );
35is( $warnings, '',          'eq_array()  no warnings' );
36
37eq_hash ( { foo => undef, bar => undef },
38          { foo => undef, bar => 23 } );
39is( $warnings, '',          'eq_hash()   no warnings' );
40
41eq_set  ( [undef, undef, 12], [29, undef, undef] );
42is( $warnings, '',          'eq_set()    no warnings' );
43
44
45eq_hash ( { foo => undef, bar => { baz => undef, moo => 23 } },
46          { foo => undef, bar => { baz => undef, moo => 23 } } );
47is( $warnings, '',          'eq_hash()   no warnings' );
48
49
50my $tb = Test::More->builder;
51
52use TieOut;
53my $caught = tie *CATCH, 'TieOut';
54my $old_fail = $tb->failure_output;
55$tb->failure_output(\*CATCH);
56diag(undef);
57$tb->failure_output($old_fail);
58
59is( $caught->read, "# undef\n" );
60is( $warnings, '',          'diag(undef)  no warnings' );
61