3 |
use warnings; |
use warnings; |
4 |
use strict; |
use strict; |
5 |
|
|
6 |
use Test::More tests => 7; |
use Test::More tests => 8; |
7 |
use lib 'lib'; |
use lib 'lib'; |
8 |
use Data::Dump qw/dump/; |
use Data::Dump qw/dump/; |
9 |
|
|
11 |
use_ok( 'Redis::Hash' ); |
use_ok( 'Redis::Hash' ); |
12 |
} |
} |
13 |
|
|
14 |
my $h; |
ok( my $o = tie( my %h, 'Redis::Hash', 'test-redis-hash' ), 'tie' ); |
|
|
|
|
ok( my $o = tie( %$h, 'Redis::Hash', 'test-redis-hash' ), 'tie' ); |
|
15 |
|
|
16 |
isa_ok( $o, 'Redis::Hash' ); |
isa_ok( $o, 'Redis::Hash' ); |
17 |
|
|
18 |
$h = {}; |
$o->CLEAR(); |
19 |
|
|
20 |
|
ok( ! keys %h, 'empty' ); |
21 |
|
|
22 |
ok( ! %$h, 'empty' ); |
ok( %h = ( 'foo' => 42, 'bar' => 1, 'baz' => 99 ), '=' ); |
23 |
|
|
24 |
ok( $h = { 'foo' => 42, 'bar' => 1, 'baz' => 99 }, '=' ); |
is_deeply( [ sort keys %h ], [ 'bar', 'baz', 'foo' ], 'keys' ); |
25 |
|
|
26 |
is_deeply( $h, { bar => 1, baz => 99, foo => 42 }, 'values' ); |
is_deeply( \%h, { bar => 1, baz => 99, foo => 42, }, 'structure' ); |
27 |
|
|
28 |
is_deeply( [ keys %$h ], [ 'bar', 'baz', 'foo' ], 'keys' ); |
ok( my $mem = $o->info->{used_memory}, 'info' ); |
29 |
|
diag "used memory $mem"; |
30 |
|
|
|
diag dump( $h ); |
|