diff options
Diffstat (limited to 't/release-pp-30-hashref-alteration.t')
-rw-r--r-- | t/release-pp-30-hashref-alteration.t | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/t/release-pp-30-hashref-alteration.t b/t/release-pp-30-hashref-alteration.t new file mode 100644 index 0000000..d1571cb --- /dev/null +++ b/t/release-pp-30-hashref-alteration.t @@ -0,0 +1,64 @@ + + +use Test::More; + +BEGIN { + unless ( $ENV{RELEASE_TESTING} ) { + plan skip_all => 'these tests are for release testing'; + } + + $ENV{PV_TEST_PERL} = 1; +} + +use strict; +use warnings; +use Test::More; + +use Params::Validate qw( validate SCALAR ); + +{ + my $p = { foo => 1 }; + + val($p); + + is_deeply( + $p, { foo => 1 }, + 'validate does not alter hashref passed to val' + ); + + val2($p); + + is_deeply( + $p, { foo => 1 }, + 'validate does not alter hashref passed to val, even with defaults being supplied' + ); +} + +sub val { + validate( + @_, { + foo => { optional => 1 }, + bar => { optional => 1 }, + baz => { optional => 1 }, + buz => { optional => 1 }, + }, + ); + + return; +} + +sub val2 { + validate( + @_, { + foo => { optional => 1 }, + bar => { default => 42 }, + baz => { optional => 1 }, + buz => { optional => 1 }, + }, + ); + + return; +} + +done_testing(); + |