diff options
author | Florian Ragwitz <rafl@debian.org> | 2011-02-25 18:30:18 +0100 |
---|---|---|
committer | Florian Ragwitz <rafl@debian.org> | 2011-02-25 18:30:18 +0100 |
commit | c34a735eb8190cd7cf9d4956d849b2f0d91d397d (patch) | |
tree | c3a0d80a9ceb611dd2e16da95197f8eb08470dba /cpan | |
parent | ee999586fe75fe0bba44247626493f792df9697a (diff) | |
download | perl-c34a735eb8190cd7cf9d4956d849b2f0d91d397d.tar.gz |
Upgrade Tie::RefHash from version 1.38 to 1.39
Diffstat (limited to 'cpan')
-rw-r--r-- | cpan/Tie-RefHash/lib/Tie/RefHash.pm | 9 | ||||
-rw-r--r-- | cpan/Tie-RefHash/t/storable.t | 21 | ||||
-rw-r--r-- | cpan/Tie-RefHash/t/threaded.t | 2 |
3 files changed, 27 insertions, 5 deletions
diff --git a/cpan/Tie-RefHash/lib/Tie/RefHash.pm b/cpan/Tie-RefHash/lib/Tie/RefHash.pm index f95bf41efd..ed72abc90e 100644 --- a/cpan/Tie-RefHash/lib/Tie/RefHash.pm +++ b/cpan/Tie-RefHash/lib/Tie/RefHash.pm @@ -2,7 +2,7 @@ package Tie::RefHash; use vars qw/$VERSION/; -$VERSION = "1.38"; +$VERSION = "1.39"; use 5.005; @@ -71,6 +71,11 @@ cloning of tied refhashes. 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> @@ -159,7 +164,7 @@ my $storable_format_version = join("/", __PACKAGE__, "0.01"); 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 { diff --git a/cpan/Tie-RefHash/t/storable.t b/cpan/Tie-RefHash/t/storable.t index 6c28b77a54..260622bd6f 100644 --- a/cpan/Tie-RefHash/t/storable.t +++ b/cpan/Tie-RefHash/t/storable.t @@ -21,7 +21,7 @@ use Tie::RefHash; use Storable qw/dclone nfreeze thaw/; $\ = "\n"; -print "1..24"; +print "1..42"; sub ok ($$) { print ( ( $_[0] ? "" : "not " ), "ok - $_[1]" ); @@ -47,7 +47,7 @@ foreach my $clone ( \%hash, dclone(\%hash), thaw(nfreeze(\%hash)) ){ 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]; @@ -60,4 +60,21 @@ foreach my $clone ( \%hash, dclone(\%hash), thaw(nfreeze(\%hash)) ){ 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" ); +} diff --git a/cpan/Tie-RefHash/t/threaded.t b/cpan/Tie-RefHash/t/threaded.t index 7e4fa1a7f0..8767f97980 100644 --- a/cpan/Tie-RefHash/t/threaded.t +++ b/cpan/Tie-RefHash/t/threaded.t @@ -21,7 +21,7 @@ BEGIN { } if ( $Config{usethreads} and !$Config{use5005threads} and defined(&Scalar::Util::weaken) - and eval { require threads; "threads"->import } + and eval { require threads; threads->import; 1 } ) { print "1..14\n"; } else { |