Blame t/utf8.t

Packit 14c646
#!./perl -w
Packit 14c646
#
Packit 14c646
#  Copyright (c) 1995-2000, Raphael Manfredi
Packit 14c646
#  
Packit 14c646
#  You may redistribute only under the same terms as Perl 5, as specified
Packit 14c646
#  in the README file that comes with the distribution.
Packit 14c646
#
Packit 14c646
Packit 14c646
sub BEGIN {
Packit 14c646
    if ($] < 5.006) {
Packit 14c646
	print "1..0 # Skip: no utf8 support\n";
Packit 14c646
	exit 0;
Packit 14c646
    }
Packit 14c646
    unshift @INC, 't';
Packit 14c646
    unshift @INC, 't/compat' if $] < 5.006002;
Packit 14c646
    require Config; import Config;
Packit 14c646
    if ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bStorable\b/) {
Packit 14c646
        print "1..0 # Skip: Storable was not built\n";
Packit 14c646
        exit 0;
Packit 14c646
    }
Packit 14c646
}
Packit 14c646
Packit 14c646
use strict;
Packit 14c646
Packit 14c646
use Storable qw(thaw freeze);
Packit 14c646
use Test::More tests => 6;
Packit 14c646
Packit 14c646
my $x = chr(1234);
Packit 14c646
is($x, ${thaw freeze \$x});
Packit 14c646
Packit 14c646
# Long scalar
Packit 14c646
$x = join '', map {chr $_} (0..1023);
Packit 14c646
is($x, ${thaw freeze \$x});
Packit 14c646
Packit 14c646
# Char in the range 127-255 (probably) in utf8.  This just won't work for
Packit 14c646
# EBCDIC for early Perls.
Packit 14c646
$x = ($] lt 5.007_003) ? chr(175) : chr(utf8::unicode_to_native(175))
Packit 14c646
   . chr (256);
Packit 14c646
chop $x;
Packit 14c646
is($x, ${thaw freeze \$x});
Packit 14c646
Packit 14c646
# Storable needs to cope if a frozen string happens to be internal utf8
Packit 14c646
# encoded
Packit 14c646
Packit 14c646
$x = chr 256;
Packit 14c646
my $data = freeze \$x;
Packit 14c646
is($x, ${thaw $data});
Packit 14c646
Packit 14c646
$data .= chr 256;
Packit 14c646
chop $data;
Packit 14c646
is($x, ${thaw $data});
Packit 14c646
Packit 14c646
Packit 14c646
$data .= chr 256;
Packit 14c646
# This definitely isn't valid
Packit 14c646
eval {thaw $data};
Packit 14c646
like($@, qr/corrupt.*characters outside/);