Redis::Hash tie with optional prefix
[perl-Redis.git] / t / 20-Redis-Hash.t
diff --git a/t/20-Redis-Hash.t b/t/20-Redis-Hash.t
new file mode 100755 (executable)
index 0000000..4bef8a5
--- /dev/null
@@ -0,0 +1,30 @@
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+
+use Test::More tests => 7;
+use lib 'lib';
+use Data::Dump qw/dump/;
+
+BEGIN {
+       use_ok( 'Redis::Hash' );
+}
+
+my $h;
+
+ok( my $o = tie( %$h, 'Redis::Hash', 'test-redis-hash' ), 'tie' );
+
+isa_ok( $o, 'Redis::Hash' );
+
+$h = {};
+
+ok( ! %$h, 'empty' );
+
+ok( $h = { 'foo' => 42, 'bar' => 1, 'baz' => 99 }, '=' );
+
+is_deeply( $h, { bar => 1, baz => 99, foo => 42 }, 'values' );
+
+is_deeply( [ keys %$h ], [ 'bar', 'baz', 'foo' ], 'keys' );
+
+diag dump( $h );