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 | } |
0c384302 |
15 | if ($ENV{PERL_CORE}){ |
16 | chdir('t') if -d 't'; |
7dadce44 |
17 | @INC = ('.', '../lib', '../ext/Storable/t'); |
372cb964 |
18 | } else { |
19 | unshift @INC, 't'; |
0c384302 |
20 | } |
dd19458b |
21 | require Config; import Config; |
0c384302 |
22 | if ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bStorable\b/) { |
dd19458b |
23 | print "1..0 # Skip: Storable was not built\n"; |
24 | exit 0; |
25 | } |
372cb964 |
26 | require 'st-dump.pl'; |
dd19458b |
27 | } |
28 | |
e16e2ff8 |
29 | use strict; |
dd19458b |
30 | sub ok; |
31 | |
32 | use Storable qw(thaw freeze); |
33 | |
fa523c3a |
34 | print "1..6\n"; |
dd19458b |
35 | |
e16e2ff8 |
36 | my $x = chr(1234); |
dd19458b |
37 | ok 1, $x eq ${thaw freeze \$x}; |
38 | |
e16e2ff8 |
39 | # Long scalar |
40 | $x = join '', map {chr $_} (0..1023); |
41 | ok 2, $x eq ${thaw freeze \$x}; |
42 | |
43 | # Char in the range 127-255 (probably) in utf8 |
44 | $x = chr (175) . chr (256); |
45 | chop $x; |
46 | ok 3, $x eq ${thaw freeze \$x}; |
fa523c3a |
47 | |
48 | # Storable needs to cope if a frozen string happens to be internall utf8 |
49 | # encoded |
50 | |
51 | $x = chr 256; |
52 | my $data = freeze \$x; |
53 | ok 4, $x eq ${thaw $data}; |
54 | |
55 | $data .= chr 256; |
56 | chop $data; |
57 | ok 5, $x eq ${thaw $data}; |
58 | |
59 | |
60 | $data .= chr 256; |
61 | # This definately isn't valid |
62 | eval {thaw $data}; |
63 | ok 6, $@ =~ /corrupt.*characters outside/; |