1193323Sed#!./perl -w 2193323Sed# 3193323Sed# Copyright (c) 1995-2000, Raphael Manfredi 4193323Sed# 5193323Sed# You may redistribute only under the same terms as Perl 5, as specified 6193323Sed# in the README file that comes with the distribution. 7193323Sed# 8193323Sed 9193323Sedsub BEGIN { 10193323Sed unshift @INC, 't'; 11193323Sed unshift @INC, 't/compat' if $] < 5.006002; 12193323Sed require Config; import Config; 13193323Sed if ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bStorable\b/) { 14193323Sed print "1..0 # Skip: Storable was not built\n"; 15193323Sed exit 0; 16193323Sed } 17193323Sed} 18193323Sed 19193323Seduse strict; 20193323Sed 21193323Seduse Storable qw(thaw freeze); 22221345Sdimuse Test::More tests => 6; 23221345Sdim 24221345Sdimmy $x = chr(1234); 25221345Sdimis($x, ${thaw freeze \$x}); 26221345Sdim 27221345Sdim# Long scalar 28221345Sdim$x = join '', map {chr $_} (0..1023); 29221345Sdimis($x, ${thaw freeze \$x}); 30221345Sdim 31221345Sdim# Char in the range 127-255 (probably) in utf8. This just won't work for 32221345Sdim# EBCDIC for early Perls. 33221345Sdim$x = ($] lt 5.007_003) ? chr(175) : chr(utf8::unicode_to_native(175)) 34221345Sdim . chr (256); 35221345Sdimchop $x; 36221345Sdimis($x, ${thaw freeze \$x}); 37221345Sdim 38221345Sdim# Storable needs to cope if a frozen string happens to be internal utf8 39221345Sdim# encoded 40221345Sdim 41221345Sdim$x = chr 256; 42221345Sdimmy $data = freeze \$x; 43221345Sdimis($x, ${thaw $data}); 44221345Sdim 45221345Sdim$data .= chr 256; 46221345Sdimchop $data; 47221345Sdimis($x, ${thaw $data}); 48221345Sdim 49193323Sed 50193323Sed$data .= chr 256; 51193323Sed# This definitely isn't valid 52193323Sedeval {thaw $data}; 53193323Sedlike($@, qr/corrupt.*characters outside/); 54193323Sed