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
|
use strict;
use warnings;
use Params::Validate qw(validate validate_pos SCALAR);
use Test::More;
BEGIN {
eval "use Readonly";
if ( $@ || !defined $Readonly::XS::VERSION ) {
plan skip_all => 'Need Readonly::XS and Readonly for this test';
}
else {
}
}
{
Readonly my $spec => { foo => 1 };
my @p = ( foo => 'hello' );
eval { validate( @p, $spec ) };
is( $@, q{}, 'validate() call succeeded with Readonly spec hashref' );
}
{
Readonly my $spec => { type => SCALAR };
my @p = 'hello';
eval { validate_pos( @p, $spec ) };
is( $@, q{}, 'validate_pos() call succeeded with Readonly spec hashref' );
}
done_testing();
|