File: write.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 (31 lines) | stat: -rw-r--r-- 534 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use strict;
use Test::More;
use Hash::MultiValue;

my $hash = Hash::MultiValue->new(
    foo => 'a',
    foo => 'b',
    bar => 'baz',
);

$hash->add(baz => 33);
is $hash->{baz}, 33;

my $new_hash = $hash->clone;
is_deeply $hash, $new_hash;

$new_hash->add('xyz' => 'zzy');
$hash->remove('foo');

is_deeply [ sort keys %$hash ], [ qw(bar baz) ];
is_deeply [ $hash->keys ], [ qw(bar baz) ];

$hash->add('bar'); # no-op add
is $hash->{'bar'}, 'baz';

$hash->clear;
is_deeply $hash, {};
isa_ok $hash, 'Hash::MultiValue';


done_testing;