File: multi.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 (27 lines) | stat: -rw-r--r-- 502 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
use strict;
use Test::More;
use Hash::MultiValue;

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

is "$hash->{foo}", 'b';
is ref $hash->{foo}, '';
my @foo = $hash->get_all('foo');
is_deeply \@foo, [ 'a', 'b' ];
is_deeply [ sort keys %$hash ], [ 'bar', 'baz', 'foo' ];
is_deeply [ $hash->keys ], [ 'foo', 'foo', 'bar', 'baz' ];
is $hash->{baz} + 2, 35;

is $hash->get_one('bar'), 'baz';

eval {
    $hash->get_one('foo');
};
ok $@;

done_testing;