1#!/usr/bin/perl -w 2# HARNESS-NO-FORK 3 4BEGIN { 5 if( $ENV{PERL_CORE} ) { 6 chdir 't'; 7 @INC = ('../lib', 'lib'); 8 } 9 else { 10 unshift @INC, 't/lib'; 11 } 12} 13 14use strict; 15use Test::More tests => 21; 16 17BEGIN { $^W = 1; } 18 19my $warnings = ''; 20local $SIG{__WARN__} = sub { $warnings .= join '', @_ }; 21 22my $TB = Test::Builder->new; 23sub no_warnings { 24 $TB->is_eq($warnings, '', ' no warnings'); 25 $warnings = ''; 26} 27 28sub warnings_is { 29 $TB->is_eq($warnings, $_[0]); 30 $warnings = ''; 31} 32 33sub warnings_like { 34 $TB->like($warnings, $_[0]); 35 $warnings = ''; 36} 37 38 39my $Filename = quotemeta $0; 40 41 42is( undef, undef, 'undef is undef'); 43no_warnings; 44 45isnt( undef, 'foo', 'undef isnt foo'); 46no_warnings; 47 48isnt( undef, '', 'undef isnt an empty string' ); 49isnt( undef, 0, 'undef isnt zero' ); 50 51Test::More->builder->is_num(undef, undef, 'is_num()'); 52Test::More->builder->isnt_num(23, undef, 'isnt_num()'); 53 54#line 45 55like( undef, qr/.*/, 'undef is like anything' ); 56no_warnings; 57 58eq_array( [undef, undef], [undef, 23] ); 59no_warnings; 60 61eq_hash ( { foo => undef, bar => undef }, 62 { foo => undef, bar => 23 } ); 63no_warnings; 64 65eq_set ( [undef, undef, 12], [29, undef, undef] ); 66no_warnings; 67 68 69eq_hash ( { foo => undef, bar => { baz => undef, moo => 23 } }, 70 { foo => undef, bar => { baz => undef, moo => 23 } } ); 71no_warnings; 72 73 74#line 74 75cmp_ok( undef, '<=', 2, ' undef <= 2' ); 76warnings_like(qr/Use of uninitialized value.* at \(eval in cmp_ok\) $Filename line 74\.\n/); 77 78 79 80my $tb = Test::More->builder; 81 82SKIP: { 83 skip("Test cannot be run with this formatter", 2) 84 unless $tb->{Stack}->top->format->isa('Test::Builder::Formatter'); 85 86 my $err = ''; 87 $tb->failure_output(\$err); 88 diag(undef); 89 $tb->reset_outputs; 90 91 is( $err, "# undef\n" ); 92 no_warnings; 93} 94 95 96$tb->maybe_regex(undef); 97no_warnings; 98 99 100# test-more.googlecode.com #42 101{ 102 is_deeply([ undef ], [ undef ]); 103 no_warnings; 104} 105