#!perl #use Test::More tests => 1; use Test::More qw/no_plan/; BEGIN { chdir 't' if -d 't'; unshift @INC, '../lib'; } { package Naughty; use base 'Exporter'; our @EXPORT = 'some_func'; sub some_func { 'naughty function. no biscuit' } } { package Unsuspecting; use strict::can; Naughty->import; sub new { bless {}, shift } sub _private { 'Unsuspecting _private' } } { package Unsuspecting::Subclass; our @ISA = 'Unsuspecting'; } ok my $new = Unsuspecting->can('new'), 'can() should return something if a package->can do something'; is ref $new, 'CODE', '... and that something should be a code reference'; ok my $object = Unsuspecting->$new, '... which we should be able to call'; is ref $object, 'Unsuspecting', '... and it should behave as we expect'; ok !Unsuspecting->can('some_func'), 'strict::can() should not report imported functions'; ok Unsuspecting::some_func(), '... even though the package can still call it'; ok !Unsuspecting->can('_private'), 'strict::can should ignore functions which begin with an underscore'; ok $new = Unsuspecting::Subclass->can('new'), 'can() should return something if a subclass->can do something'; is ref $new, 'CODE', '... and that something should be a code reference'; ok $object = Unsuspecting::Subclass->$new, '... which we should be able to call'; is ref $object, 'Unsuspecting::Subclass', '... and it should behave as we expect'; ok !Unsuspecting::Subclass->can('some_func'), 'strict::can() should not report imported functions'; ok !Unsuspecting::Subclass->can('_private'), 'strict::can should ignore functions which begin with an underscore';