5 if( $ENV{PERL_CORE} ) {
7 @INC = ('../lib', 'lib');
10 unshift @INC, 't/lib';
15 use Test::More tests => 20;
21 local $SIG{__WARN__} = sub { $warnings .= join '', @_ };
23 my $TB = Test::Builder->new;
25 $TB->is_eq($warnings, '', ' no warnings');
30 $TB->is_eq($warnings, $_[0]);
35 $TB->like($warnings, $_[0]);
40 my $Filename = quotemeta $0;
43 is( undef, undef, 'undef is undef');
46 isnt( undef, 'foo', 'undef isnt foo');
49 isnt( undef, '', 'undef isnt an empty string' );
50 isnt( undef, 0, 'undef isnt zero' );
52 Test::More->builder->is_num(undef, undef, 'is_num()');
53 Test::More->builder->isnt_num(23, undef, 'isnt_num()');
56 like( undef, '/.*/', 'undef is like anything' );
57 warnings_like(qr/Use of uninitialized value.* at $Filename line 45\.\n/);
59 eq_array( [undef, undef], [undef, 23] );
62 eq_hash ( { foo => undef, bar => undef },
63 { foo => undef, bar => 23 } );
66 eq_set ( [undef, undef, 12], [29, undef, undef] );
70 eq_hash ( { foo => undef, bar => { baz => undef, moo => 23 } },
71 { foo => undef, bar => { baz => undef, moo => 23 } } );
76 cmp_ok( undef, '<=', 2, ' undef <= 2' );
77 warnings_like(qr/Use of uninitialized value.* at cmp_ok \[from $Filename line 64\] line 1\.\n/);
81 my $tb = Test::More->builder;
84 my $caught = tie *CATCH, 'TieOut';
85 my $old_fail = $tb->failure_output;
86 $tb->failure_output(\*CATCH);
88 $tb->failure_output($old_fail);
90 is( $caught->read, "# undef\n" );
94 $tb->maybe_regex(undef);
95 is( $caught->read, '' );