1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
#!perl
use strict;
use warnings;
use lib 't/lib';
use Test::More tests => 2;
use Test::SmallWarn;
# must happen here to register warnings category
BEGIN { use_ok( 'UNIVERSAL::can', '-always_warn' ) };
{
package Demo;
sub new { bless {}, shift }
sub can
{
my ($self, $method) = @_;
return $self->SUPER::can( $method );
}
}
my $demo = Demo->new( 'Demo' );
{
no warnings;
warning_like { UNIVERSAL::can( $demo, 'new' ) }
qr/Called UNIVERSAL::can/,
'-always_warn flag should make module always warn';
}
|