diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2015-06-28 14:34:36 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2015-06-28 14:34:36 +0000 |
commit | 11197f6fc2fdd0d2a139a74ff1302244c4911e4e (patch) | |
tree | c5e13a504c33aa05b559c860f90eb8270d3e73c4 /t/23-readonly.t | |
download | Params-Validate-tarball-d5f9c31862173ed5facb22bfe7dc4e0ea407b02f.tar.gz |
Params-Validate-1.20HEADParams-Validate-1.20master
Diffstat (limited to 't/23-readonly.t')
-rw-r--r-- | t/23-readonly.t | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/t/23-readonly.t b/t/23-readonly.t new file mode 100644 index 0000000..a8b7ced --- /dev/null +++ b/t/23-readonly.t @@ -0,0 +1,39 @@ +use strict; +use warnings; + +use Test::Requires { + Readonly => '1.03', + 'Scalar::Util' => '1.20', +}; + +use Params::Validate qw(validate validate_pos SCALAR); +use Test::More; + +plan skip_all => 'These tests fail with Readonly 1.50 for some reason' + if Readonly::->VERSION() =~ /^v?1.5/; + +{ + 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' ); +} + +{ + Readonly my %spec => ( foo => { type => SCALAR } ); + my @p = ( foo => 'hello' ); + + eval { validate( @p, \%spec ) }; + is( $@, q{}, 'validate() call succeeded with Readonly spec hash' ); +} + +done_testing(); |