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