1use strict;
2use Test::More;
3use Hash::MultiValue;
4use Storable qw(freeze thaw dclone);
5
6my $l = [ qw( foo a bar baz foo b bar quux ) ];
7
8my $hash = Hash::MultiValue->new( @$l );
9
10is_deeply [ $hash->flatten ], $l, 'flattening works';
11
12my $frozen = freeze $hash;
13undef $hash;
14$hash = thaw $frozen;
15is_deeply [ $hash->flatten ], $l, '... even after deserialisation';
16
17my $clone = dclone $hash;
18is_deeply [ $clone->flatten ], $l, '... and cloning';
19
20$clone->remove('foo');
21my ($n_hash, $n_clone) = map scalar @{[$_->flatten]}, $hash, $clone;
22ok $n_hash > $n_clone, '... which makes independent objects';
23
24done_testing;
25