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 unshift @INC, 't/compat' if $] < 5.006002;
12 require Config; import Config;
13 if ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bStorable\b/) {
14 print "1..0 # Skip: Storable was not built\n";
19 use Test::More tests => 8;
21 use Storable qw(freeze nfreeze thaw);
26 my $self = bless {}, shift;
46 my $self = bless [], shift;
55 my $self = bless {}, shift;
56 my $h = tie %hash, TIED_HASH;
58 $self->{ref} = \%hash;
60 for (my $i = 0; $i < 5; $i++) {
61 push(@pool, SIMPLE->make($i));
63 $self->{obj} = \@pool;
64 my @a = ('string', $h, $self);
66 $self->{num} = [1, 0, -3, -3.14159, 456, 4.5];
72 sub num { $_[0]->{num} }
74 sub ref { $_[0]->{ref} }
75 sub obj { $_[0]->{obj} }
79 my $is_EBCDIC = (ord('A') == 193) ? 1 : 0;
84 if (!$is_EBCDIC) { # ASCII machine
87 $data .= unpack("u", $_);
91 next if /^#$/; # skip comments
92 next if /^#\s+/; # skip comments
93 next if /^[^#]/; # skip uuencoding for ASCII machines
94 s/^#//; # prepare uuencoded data for EBCDIC machines
95 $data .= unpack("u", $_);
99 my $expected_length = $is_EBCDIC ? 217 : 278;
100 is(length $data, $expected_length);
106 $Storable::canonical = 1; # Prevent "used once" warning
107 $Storable::canonical = 1;
108 # Allow for long double string conversions.
111 is(nfreeze($y), nfreeze($r));
113 is($y->ref->{key1}, 'val1');
114 is($y->ref->{key2}, 'val2');
119 for (my $i = 0; $i < @$num; $i++) {
120 do { $ok = 0; last } unless $num->[$i] == $y->num->[$i];
126 # using Storable-0.6@11, output of: print pack("u", nfreeze(ROOT->make));
127 # original size: 278 bytes
129 M`P,````%!`(````&"(%8"(!8"'U8"@@M,RXQ-#$U.5@)```!R%@*`S0N-5A8
130 M6`````-N=6T$`P````(*!'9A;#%8````!&ME>3$*!'9A;#)8````!&ME>3)B
131 M"51)141?2$%32%A8`````6@$`@````,*!G-T<FEN9U@$``````I8!```````
132 M6%A8`````6$$`@````4$`@````$(@%AB!E-)35!,15A8!`(````!"(%88@93
133 M24U03$586`0"`````0B"6&(&4TE-4$Q%6%@$`@````$(@UAB!E-)35!,15A8
134 M!`(````!"(188@9324U03$586%A8`````V]B:@0,!``````*6%A8`````W)E
137 # using Storable-0.6@11, output of: print '#' . pack("u", nfreeze(ROOT->make));
138 # on OS/390 (cp 1047) original size: 217 bytes
140 #M!0,1!-G6UN,#````!00,!!$)X\G%Q&W(P>+(`P````(*!*6!D_$````$DH6H
141 #M\0H$I8&3\@````22A:CR`````YF%A@0"````!@B!"(`(?0H(8/-+\?3Q]?D)
142 #M```!R`H#]$OU`````Y6DE`0"````!001!N+)U-?3Q0(````!"(`$$@("````
143 #M`0B!!!("`@````$(@@02`@(````!"(,$$@("`````0B$`````Y:"D00`````
144 #E!`````&(!`(````#"@:BHYF)E8<$``````0$```````````!@0``