'Tie::RefHash' =>
{
'MAINTAINER' => 'nuffin',
- 'DISTRIBUTION' => 'NUFFIN/Tie-RefHash-1.38.tar.gz',
+ 'DISTRIBUTION' => 'FLORA/Tie-RefHash-1.39.tar.gz',
'FILES' => q[cpan/Tie-RefHash],
'UPSTREAM' => 'cpan',
},
use vars qw/$VERSION/;
-$VERSION = "1.38";
+$VERSION = "1.39";
use 5.005;
This version of Tie::RefHash seems to no longer work with 5.004. This has not
been throughly investigated. Patches welcome ;-)
+=head1 LICENSE
+
+This program is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself
+
=head1 MAINTAINER
Yuval Kogman E<lt>nothingmuch@woobling.orgE<gt>
sub STORABLE_freeze {
my ( $self, $is_cloning ) = @_;
my ( $refs, $reg ) = @$self;
- return ( $storable_format_version, [ values %$refs ], $reg );
+ return ( $storable_format_version, [ values %$refs ], $reg || {} );
}
sub STORABLE_thaw {
use Storable qw/dclone nfreeze thaw/;
$\ = "\n";
-print "1..24";
+print "1..42";
sub ok ($$) {
print ( ( $_[0] ? "" : "not " ), "ok - $_[1]" );
isa_ok( tied(%$clone), "Tie::RefHash" );
my @keys = keys %$clone;
- is( scalar(@keys), 2, "one key in clone");
+ is( scalar(@keys), 2, "two keys in clone");
my $key = ref($keys[0]) ? shift @keys : pop @keys;
my $reg = $keys[0];
is( $clone->{$reg}, "other", "and is also a valid key" );
}
+tie my %only_refs, "Tie::RefHash";
+$only_refs{$key} = "value";
+
+foreach my $clone ( \%only_refs, dclone(\%only_refs), thaw(nfreeze(\%only_refs)) ){
+
+ ok( tied(%$clone), "copy is tied");
+ isa_ok( tied(%$clone), "Tie::RefHash" );
+
+ my @keys = keys %$clone;
+ is( scalar(@keys), 1, "one key in clone");
+ my $key = $keys[0];
+
+ ok( ref($key), "key is a ref after clone" );
+ is( $key->{foo}, 1, "key serialized ok");
+
+ is( $clone->{$key}, "value", "and is still pointing at the same value" );
+}