5 use Test::More tests => 11;
8 tie my %tied, 'Tie::ExtraHash';
9 %tied = (apple => 'tree', cow => 'field');
10 my %hash = (apple => 'tree', cow => 'field');
13 is_deeply(\%hash, \%tied, "TIEHASH");
14 ok(tied(%tied), "TIEHASH really does tie");
17 is_deeply([sort keys %hash], [sort keys %tied], "FIRSTKEY/NEXTKEY");
18 is_deeply([sort values %hash], [sort values %tied], "FIRSTKEY/NEXTKEY");
21 ok(exists($tied{apple}) && exists($hash{apple}),
22 'EXISTS works when it exists');
25 delete($tied{apple}); delete($hash{apple});
26 ok(!exists($tied{apple}) && !exists($hash{apple}),
27 'EXISTS works when it doesn\'t exist (as does DELETE)');
30 $tied{house} = $hash{house} = 'town';
31 ok($tied{house} eq 'town' && $tied{house} eq $hash{house},
35 %tied = (); %hash = ();
36 ok(tied(%tied), "still tied after CLEAR");
37 is_deeply(\%tied, \%hash, "CLEAR");
40 is(scalar(%tied), scalar(%hash), "SCALAR");