— |
my $compiled = 0;
my $MyStr = Str->create_child_type(
name => 'MyStr' ,
constraint => sub { 1 },
inlined => sub {
++ $compiled ;
Str->inline_check( pop );
},
);
signature_for xyz => ( pos => [ $MyStr ] );
sub xyz {
my $got = shift ;
return scalar reverse $got ;
}
is(
$compiled ,
0,
'type constraint has not been compiled yet' ,
);
is( xyz( 'foo' ), 'oof' , 'function worked' );
is(
$compiled ,
1,
'type constraint has been compiled' ,
);
is( xyz( 'bar' ), 'rab' , 'function worked' );
is(
$compiled ,
1,
'type constraint has not been re-compiled' ,
);
done_testing;
|