Hash-Map
view release on metacpan or search on metacpan
t/02_functional_style.t view on Meta::CPAN
#!perl -T
use strict;
use warnings;
use Test::More tests => 8 + 1;
use Test::NoWarnings;
use Test::Differences;
BEGIN {
use_ok( 'Hash::Map', qw(hash_map hashref_map) );
}
eq_or_diff(
{
hash_map(
{
a => 11,
b => 12,
c => 13,
},
[ qw(a b) ],
)
},
{
a => 11,
b => 12,
},
'hash_map copy_keys',
);
eq_or_diff(
scalar hashref_map(
{
a => 21,
b => 22,
c => 23,
},
[
qw(b c),
sub {
isa_ok(
shift,
'Hash::Map',
'check object in hashref_map copy_keys',
);
return "p_$_";
},
],
),
{
p_b => 22,
p_c => 23,
},
'hashref_map copy_keys (with sub is map_keys)',
);
eq_or_diff(
scalar hashref_map(
{
a => 31,
b => 32,
c => 33,
},
{
a => q{b},
b => q{c},
},
( run in 0.641 second using v1.01-cache-2.11-cpan-e1769b4cff6 )