3 # $Id: blessed.t,v 0.7 2000/08/03 22:04:44 ram Exp $
5 # Copyright (c) 1995-2000, Raphael Manfredi
7 # You may redistribute only under the terms of the Artistic License,
8 # as specified in the README file that comes with the distribution.
11 # Revision 0.7 2000/08/03 22:04:44 ram
12 # Baseline for second beta release.
17 unshift @INC, '../lib';
18 require Config; import Config;
19 if ($Config{'extensions'} !~ /\bStorable\b/) {
20 print "1..0 # Skip: Storable was not built\n";
23 require 'lib/st-dump.pl';
28 use Storable qw(freeze thaw);
34 sub make { bless [], shift }
36 package SHORT_NAME_WITH_HOOK;
38 sub make { bless [], shift }
49 die "STORABLE_thaw" unless $obj eq $self;
54 # Still less than 256 bytes, so long classname logic not fully exercised
55 # Wait until Perl removes the restriction on identifier lengths.
56 my $name = "LONG_NAME_" . 'xxxxxxxxxxxxx::' x 14 . "final";
61 \@ISA = ("SHORT_NAME");
67 package ${name}_WITH_HOOK;
69 \@ISA = ("SHORT_NAME_WITH_HOOK");
73 # Construct a pool of objects
76 for (my $i = 0; $i < 10; $i++) {
77 push(@pool, SHORT_NAME->make);
78 push(@pool, SHORT_NAME_WITH_HOOK->make);
79 push(@pool, $name->make);
80 push(@pool, "${name}_WITH_HOOK"->make);
83 my $x = freeze \@pool;
87 ok 4, ref $y eq 'ARRAY';
90 ok 6, ref $y->[0] eq 'SHORT_NAME';
91 ok 7, ref $y->[1] eq 'SHORT_NAME_WITH_HOOK';
92 ok 8, ref $y->[2] eq $name;
93 ok 9, ref $y->[3] eq "${name}_WITH_HOOK";
96 for (my $i = 0; $i < 10; $i++) {
97 do { $good = 0; last } unless ref $y->[4*$i] eq 'SHORT_NAME';
98 do { $good = 0; last } unless ref $y->[4*$i+1] eq 'SHORT_NAME_WITH_HOOK';
99 do { $good = 0; last } unless ref $y->[4*$i+2] eq $name;
100 do { $good = 0; last } unless ref $y->[4*$i+3] eq "${name}_WITH_HOOK";