diff options
author | Nicholas Clark <nick@ccl4.org> | 2004-03-17 16:10:57 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2004-03-17 16:10:57 +0000 |
commit | 165cc789d248f15373a01b5b620e86cdc98e3eab (patch) | |
tree | a014a40d706a313c8d3d9d003730e4d12ac48564 /ext/Storable/t | |
parent | 754c00caaffe2ec6497277e111c662069a7bff5c (diff) | |
download | perl-165cc789d248f15373a01b5b620e86cdc98e3eab.tar.gz |
Add auto-require of modules to restore overloading (and tests)
p4raw-id: //depot/perl@22516
Diffstat (limited to 'ext/Storable/t')
-rw-r--r-- | ext/Storable/t/HAS_OVERLOAD.pm | 14 | ||||
-rw-r--r-- | ext/Storable/t/overload.t | 14 |
2 files changed, 26 insertions, 2 deletions
diff --git a/ext/Storable/t/HAS_OVERLOAD.pm b/ext/Storable/t/HAS_OVERLOAD.pm new file mode 100644 index 0000000000..8a622a4bbe --- /dev/null +++ b/ext/Storable/t/HAS_OVERLOAD.pm @@ -0,0 +1,14 @@ +package HAS_OVERLOAD; + +use overload + '""' => sub { ${$_[0]} }, fallback => 1; + +sub make { + my $package = shift; + my $value = shift; + bless \$value, $package; +} + +++$loaded_count; + +1; diff --git a/ext/Storable/t/overload.t b/ext/Storable/t/overload.t index a0b65a2507..31b861d5a2 100644 --- a/ext/Storable/t/overload.t +++ b/ext/Storable/t/overload.t @@ -25,7 +25,7 @@ sub ok; use Storable qw(freeze thaw); -print "1..12\n"; +print "1..16\n"; package OVERLOADED; @@ -87,5 +87,15 @@ ok 10, ref $b->{ref} eq 'REF_TO_OVER'; ok 11, "$b->{ref}->{over}" eq "$b"; ok 12, $b + $b == 314; +# nfreeze data generated by make_overload.pl +my $f = unpack 'u', q{7!084$0Q(05-?3U9%4DQ/040*!'-N;W<`}; + +# see note at the end of do_retrieve in Storable.xs about why this test has to +# use a reference to an overloaded reference, rather than just a reference. +my $t = eval {thaw $f}; +print "# $@" if $@; +ok 13, $@ eq ""; +ok 14, ref ($t) eq 'REF'; +ok 15, ref ($$t) eq 'HAS_OVERLOAD'; +ok 16, $$$t eq 'snow'; 1; - |