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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
use strict;
use warnings;
use Test::More;
my $invalid_prototypes;
BEGIN {
package TestExporter1;
$INC{"TestExporter1.pm"} = 1;
use Exporter;
our @ISA = qw(Exporter);
our @EXPORT = qw(guff welp farb tube truck);
sub guff { rand(1) }
sub welp () { rand(1) }
sub farb ($) { rand(1) }
no warnings;
eval q{
sub tube (plaf) { rand(1) }
sub truck (-1) { rand(1) }
1;
} and $invalid_prototypes = 1;
}
BEGIN {
package TestRole1;
use Role::Tiny;
use TestExporter1;
}
BEGIN {
package SomeClass;
use Role::Tiny::With;
use TestExporter1;
with 'TestRole1';
eval { guff };
::is $@, '',
'composing matching function with no prototype works';
eval { welp };
::is $@, '',
'composing matching function with empty prototype works';
eval { farb 1 };
::is $@, '',
'composing matching function with ($) prototype works';
if ($invalid_prototypes) {
eval { &tube };
::is $@, '',
'composing matching function with invalid prototype works';
eval { &truck };
::is $@, '',
'composing matching function with invalid -1 prototype works';
}
}
done_testing;
|