diff options
Diffstat (limited to 't/30-hashref-alteration.t')
-rw-r--r-- | t/30-hashref-alteration.t | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/t/30-hashref-alteration.t b/t/30-hashref-alteration.t new file mode 100644 index 0000000..116353f --- /dev/null +++ b/t/30-hashref-alteration.t @@ -0,0 +1,51 @@ +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(); |