3 # Copyright (c) 1995-2000, Raphael Manfredi
5 # You may redistribute only under the same terms as Perl 5, as specified
6 # in the README file that comes with the distribution.
11 require Config; import Config;
12 if ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bStorable\b/) {
13 print "1..0 # Skip: Storable was not built\n";
21 use Storable qw(freeze thaw);
28 '""' => sub { $_[0][0] };
32 $a = bless [77], OVERLOADED;
35 ok 1, ref $b eq 'OVERLOADED';
39 ok 3, ref $c eq 'REF';
40 ok 4, ref $$c eq 'OVERLOADED';
43 $d = thaw freeze [$a, $a];
44 ok 6, "$d->[0]" eq "77";
46 ok 7, "$d->[1]" eq "78";
51 my $self = bless {}, shift;
53 $self->{over} = $over;
61 '""' => sub { ref $_[0] };
68 my $self = bless {}, shift;
69 my $ref = REF_TO_OVER->make($self);
79 ok 8, ref $b eq 'OVER';
81 ok 10, ref $b->{ref} eq 'REF_TO_OVER';
82 ok 11, "$b->{ref}->{over}" eq "$b";
83 ok 12, $b + $b == 314;
85 # nfreeze data generated by make_overload.pl
87 if (ord ('A') == 193) { # EBCDIC.
88 $f = unpack 'u', q{7!084$0S(P>)MUN7%V=/6P<0*!**5EJ8`};
90 $f = unpack 'u', q{7!084$0Q(05-?3U9%4DQ/040*!'-N;W<`};
93 # see note at the end of do_retrieve in Storable.xs about why this test has to
94 # use a reference to an overloaded reference, rather than just a reference.
95 my $t = eval {thaw $f};
98 ok 14, ref ($t) eq 'REF';
99 ok 15, ref ($$t) eq 'HAS_OVERLOAD';
100 ok 16, $$$t eq 'snow';
104 # blessed reference to overloded object.
106 my $a = bless [88], 'OVERLOADED';
107 my $c = thaw freeze bless \$a, 'main';
108 ok 17, ref $c eq 'main';
109 ok 18, ref $$c eq 'OVERLOADED';
110 ok 19, "$$c" eq "88";