File: storable.t

package info (click to toggle)
libhash-multivalue-perl 0.16-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 192 kB
  • sloc: perl: 270; makefile: 2
file content (24 lines) | stat: -rw-r--r-- 615 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use strict;
use Test::More;
use Hash::MultiValue;
use Storable qw(freeze thaw dclone);

my $l = [ qw( foo a bar baz foo b bar quux ) ];

my $hash = Hash::MultiValue->new( @$l );

is_deeply [ $hash->flatten ], $l, 'flattening works';

my $frozen = freeze $hash;
undef $hash;
$hash = thaw $frozen;
is_deeply [ $hash->flatten ], $l, '... even after deserialisation';

my $clone = dclone $hash;
is_deeply [ $clone->flatten ], $l, '... and cloning';

$clone->remove('foo');
my ($n_hash, $n_clone) = map scalar @{[$_->flatten]}, $hash, $clone;
ok $n_hash > $n_clone, '... which makes independent objects';

done_testing;