4 if( $ENV{PERL_CORE} ) {
6 @INC = ('../lib', 'lib');
14 use Test::More tests => 18;
20 local $SIG{__WARN__} = sub { $warnings .= join '', @_ };
22 my $TB = Test::Builder->new;
24 $TB->is_eq($warnings, '', ' no warnings');
29 $TB->is_eq($warnings, $_[0]);
34 $TB->like($warnings, "/$_[0]/");
39 my $Filename = quotemeta $0;
42 is( undef, undef, 'undef is undef');
45 isnt( undef, 'foo', 'undef isnt foo');
48 isnt( undef, '', 'undef isnt an empty string' );
49 isnt( undef, 0, 'undef isnt zero' );
52 like( undef, '/.*/', 'undef is like anything' );
53 warnings_like("Use of uninitialized value.* at $Filename line 45\\.\n");
55 eq_array( [undef, undef], [undef, 23] );
58 eq_hash ( { foo => undef, bar => undef },
59 { foo => undef, bar => 23 } );
62 eq_set ( [undef, undef, 12], [29, undef, undef] );
66 eq_hash ( { foo => undef, bar => { baz => undef, moo => 23 } },
67 { foo => undef, bar => { baz => undef, moo => 23 } } );
72 cmp_ok( undef, '<=', 2, ' undef <= 2' );
73 warnings_like("Use of uninitialized value.* at $Filename line 64\\.\n");
77 my $tb = Test::More->builder;
80 my $caught = tie *CATCH, 'TieOut';
81 my $old_fail = $tb->failure_output;
82 $tb->failure_output(\*CATCH);
84 $tb->failure_output($old_fail);
86 is( $caught->read, "# undef\n" );
90 $tb->maybe_regex(undef);
91 is( $caught->read, '' );