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.
12 @INC = ('.', '../lib', '../ext/Storable/t');
16 require Config; import Config;
17 if ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bStorable\b/) {
18 print "1..0 # Skip: Storable was not built\n";
26 use Storable qw(freeze thaw);
32 sub make { bless [], shift }
34 package SHORT_NAME_WITH_HOOK;
36 sub make { bless [], shift }
47 die "STORABLE_thaw" unless $obj eq $self;
52 # Still less than 256 bytes, so long classname logic not fully exercised
53 # Wait until Perl removes the restriction on identifier lengths.
54 my $name = "LONG_NAME_" . 'xxxxxxxxxxxxx::' x 14 . "final";
59 \@ISA = ("SHORT_NAME");
65 package ${name}_WITH_HOOK;
67 \@ISA = ("SHORT_NAME_WITH_HOOK");
71 # Construct a pool of objects
74 for (my $i = 0; $i < 10; $i++) {
75 push(@pool, SHORT_NAME->make);
76 push(@pool, SHORT_NAME_WITH_HOOK->make);
77 push(@pool, $name->make);
78 push(@pool, "${name}_WITH_HOOK"->make);
81 my $x = freeze \@pool;
85 ok 4, ref $y eq 'ARRAY';
88 ok 6, ref $y->[0] eq 'SHORT_NAME';
89 ok 7, ref $y->[1] eq 'SHORT_NAME_WITH_HOOK';
90 ok 8, ref $y->[2] eq $name;
91 ok 9, ref $y->[3] eq "${name}_WITH_HOOK";
94 for (my $i = 0; $i < 10; $i++) {
95 do { $good = 0; last } unless ref $y->[4*$i] eq 'SHORT_NAME';
96 do { $good = 0; last } unless ref $y->[4*$i+1] eq 'SHORT_NAME_WITH_HOOK';
97 do { $good = 0; last } unless ref $y->[4*$i+2] eq $name;
98 do { $good = 0; last } unless ref $y->[4*$i+3] eq "${name}_WITH_HOOK";