1#!./perl -w 2# 3# Copyright (c) 1995-2000, Raphael Manfredi 4# 5# You may redistribute only under the same terms as Perl 5, as specified 6# in the README file that comes with the distribution. 7# 8 9sub BEGIN { 10 if ($] < 5.006) { 11 print "1..0 # Skip: no utf8 support\n"; 12 exit 0; 13 } 14 unshift @INC, 't'; 15 unshift @INC, 't/compat' if $] < 5.006002; 16 require Config; import Config; 17 if ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bStorable\b/) { 18 print "1..0 # Skip: Storable was not built\n"; 19 exit 0; 20 } 21} 22 23use strict; 24 25use Storable qw(thaw freeze); 26use Test::More tests => 6; 27 28my $x = chr(1234); 29is($x, ${thaw freeze \$x}); 30 31# Long scalar 32$x = join '', map {chr $_} (0..1023); 33is($x, ${thaw freeze \$x}); 34 35# Char in the range 127-255 (probably) in utf8 36$x = chr (175) . chr (256); 37chop $x; 38is($x, ${thaw freeze \$x}); 39 40# Storable needs to cope if a frozen string happens to be internal utf8 41# encoded 42 43$x = chr 256; 44my $data = freeze \$x; 45is($x, ${thaw $data}); 46 47$data .= chr 256; 48chop $data; 49is($x, ${thaw $data}); 50 51 52$data .= chr 256; 53# This definitely isn't valid 54eval {thaw $data}; 55like($@, qr/corrupt.*characters outside/); 56