Use $SIG{__WARN__}.
{
my $warnings = '';
local $SIG{__WARN__} = sub { $warnings . join '', @_ };
use Test::More tests => 2;
is( undef, undef, 'undef is undef' );
is( $warnings, '', ' no warnings' );
}
Use the same technique to check for expected warnings.
See Test-Simple/t/undef.t for more examples.