3 # $Id: blessed.t,v 1.0 2000/09/01 19:40:41 ram Exp $
5 # Copyright (c) 1995-2000, Raphael Manfredi
7 # You may redistribute only under the same terms as Perl 5, as specified
8 # in the README file that comes with the distribution.
11 # Revision 1.0 2000/09/01 19:40:41 ram
12 # Baseline for first official release.
18 @INC = ('.', '../lib', '../ext/Storable/t');
22 require Config; import Config;
23 if ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bStorable\b/) {
24 print "1..0 # Skip: Storable was not built\n";
32 use Storable qw(freeze thaw);
38 sub make { bless [], shift }
40 package SHORT_NAME_WITH_HOOK;
42 sub make { bless [], shift }
53 die "STORABLE_thaw" unless $obj eq $self;
58 # Still less than 256 bytes, so long classname logic not fully exercised
59 # Wait until Perl removes the restriction on identifier lengths.
60 my $name = "LONG_NAME_" . 'xxxxxxxxxxxxx::' x 14 . "final";
65 \@ISA = ("SHORT_NAME");
71 package ${name}_WITH_HOOK;
73 \@ISA = ("SHORT_NAME_WITH_HOOK");
77 # Construct a pool of objects
80 for (my $i = 0; $i < 10; $i++) {
81 push(@pool, SHORT_NAME->make);
82 push(@pool, SHORT_NAME_WITH_HOOK->make);
83 push(@pool, $name->make);
84 push(@pool, "${name}_WITH_HOOK"->make);
87 my $x = freeze \@pool;
91 ok 4, ref $y eq 'ARRAY';
94 ok 6, ref $y->[0] eq 'SHORT_NAME';
95 ok 7, ref $y->[1] eq 'SHORT_NAME_WITH_HOOK';
96 ok 8, ref $y->[2] eq $name;
97 ok 9, ref $y->[3] eq "${name}_WITH_HOOK";
100 for (my $i = 0; $i < 10; $i++) {
101 do { $good = 0; last } unless ref $y->[4*$i] eq 'SHORT_NAME';
102 do { $good = 0; last } unless ref $y->[4*$i+1] eq 'SHORT_NAME_WITH_HOOK';
103 do { $good = 0; last } unless ref $y->[4*$i+2] eq $name;
104 do { $good = 0; last } unless ref $y->[4*$i+3] eq "${name}_WITH_HOOK";