Test::Simple/More/Builder 0.42 -> 0.44
[p5sagit/p5-mst-13.2.git] / lib / Test / Simple / t / undef.t
CommitLineData
89c1e84a 1#!/usr/bin/perl -w
2
33459055 3BEGIN {
a9153838 4 if( $ENV{PERL_CORE} ) {
5 chdir 't';
89c1e84a 6 @INC = ('../lib', 'lib');
7 }
8 else {
9 unshift @INC, 't/lib';
a9153838 10 }
33459055 11}
12
d020a79a 13use strict;
89c1e84a 14use Test::More tests => 14;
15use TieOut;
d020a79a 16
17BEGIN { $^W = 1; }
18
19my $warnings = '';
a9153838 20local $SIG{__WARN__} = sub { $warnings .= join '', @_ };
d020a79a 21
22is( undef, undef, 'undef is undef');
23is( $warnings, '', ' no warnings' );
24
25isnt( undef, 'foo', 'undef isnt foo');
26is( $warnings, '', ' no warnings' );
27
a9153838 28isnt( undef, '', 'undef isnt an empty string' );
29isnt( undef, 0, 'undef isnt zero' );
30
d020a79a 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
89c1e84a 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' );