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 'lib/st-dump.pl';
23 use Storable qw(freeze thaw);
29 sub make { bless [], shift }
31 package SHORT_NAME_WITH_HOOK;
33 sub make { bless [], shift }
44 die "STORABLE_thaw" unless $obj eq $self;
49 # Still less than 256 bytes, so long classname logic not fully exercised
50 # Wait until Perl removes the restriction on identifier lengths.
51 my $name = "LONG_NAME_" . 'xxxxxxxxxxxxx::' x 14 . "final";
56 \@ISA = ("SHORT_NAME");
62 package ${name}_WITH_HOOK;
64 \@ISA = ("SHORT_NAME_WITH_HOOK");
68 # Construct a pool of objects
71 for (my $i = 0; $i < 10; $i++) {
72 push(@pool, SHORT_NAME->make);
73 push(@pool, SHORT_NAME_WITH_HOOK->make);
74 push(@pool, $name->make);
75 push(@pool, "${name}_WITH_HOOK"->make);
78 my $x = freeze \@pool;
82 ok 4, ref $y eq 'ARRAY';
85 ok 6, ref $y->[0] eq 'SHORT_NAME';
86 ok 7, ref $y->[1] eq 'SHORT_NAME_WITH_HOOK';
87 ok 8, ref $y->[2] eq $name;
88 ok 9, ref $y->[3] eq "${name}_WITH_HOOK";
91 for (my $i = 0; $i < 10; $i++) {
92 do { $good = 0; last } unless ref $y->[4*$i] eq 'SHORT_NAME';
93 do { $good = 0; last } unless ref $y->[4*$i+1] eq 'SHORT_NAME_WITH_HOOK';
94 do { $good = 0; last } unless ref $y->[4*$i+2] eq $name;
95 do { $good = 0; last } unless ref $y->[4*$i+3] eq "${name}_WITH_HOOK";