1 |
root |
1.1 |
BEGIN { |
2 |
|
|
eval "use Storable; 1" or do { |
3 |
|
|
print "1..0 # skip Storable module unavailable\n"; |
4 |
|
|
exit; |
5 |
|
|
}; |
6 |
|
|
} |
7 |
|
|
|
8 |
root |
1.2 |
BEGIN { $| = 1; print "1..1244\n"; } |
9 |
root |
1.1 |
|
10 |
|
|
END {print "not ok 1\n" unless $loaded;} |
11 |
|
|
use Compress::LZF ':freeze'; |
12 |
|
|
use Storable; |
13 |
|
|
$loaded = 1; |
14 |
|
|
print "ok 1\n"; |
15 |
|
|
|
16 |
|
|
$tst = 0; |
17 |
|
|
|
18 |
|
|
sub ok { |
19 |
|
|
print (($_[0] ? "ok " : "not ok "), 1+ ++$tst, "\n"); |
20 |
|
|
} |
21 |
|
|
|
22 |
|
|
sub chk { |
23 |
|
|
my $s = shift; |
24 |
|
|
my $n = sfreeze $s; ok(1); |
25 |
|
|
my $nr = sfreeze_cr $s; ok(1); |
26 |
|
|
my $nc = sfreeze_c $s; ok(1); |
27 |
|
|
my $r = sfreeze \$s; ok(1); |
28 |
|
|
my $rr = sfreeze_cr\$s; ok(1); |
29 |
|
|
my $rc = sfreeze_c \$s; ok(1); |
30 |
|
|
|
31 |
|
|
ok ($n eq $nr); |
32 |
|
|
ok (length ($n) >= length ($nc)); |
33 |
|
|
ok (length ($n) <= length ($r)); |
34 |
|
|
ok (length ($r) >= length ($rr)); |
35 |
|
|
ok ($rr eq $rc); |
36 |
|
|
ok (length ($r) >= length ($rr)); |
37 |
|
|
|
38 |
|
|
#print unpack("H*", $s), " => ", unpack("H*", $rc), "\n"; |
39 |
|
|
|
40 |
|
|
ok ($s eq sthaw $n); |
41 |
|
|
ok ($s eq sthaw $nr); |
42 |
|
|
ok ($s eq sthaw $nc); |
43 |
|
|
ok ($s eq ${sthaw $r}); |
44 |
|
|
ok ($s eq ${sthaw $rr}); |
45 |
|
|
ok ($s eq ${sthaw $rc}); |
46 |
|
|
} |
47 |
|
|
|
48 |
|
|
for my $pfx (0, 1, 4, 6, 7, 40, ord('x'), 240..255) { |
49 |
|
|
chk chr($pfx)."x"; |
50 |
|
|
chk chr($pfx)."xxxxxxxxxxxxx"; |
51 |
|
|
chk chr($pfx)."abcdefghijklm"; |
52 |
|
|
} |
53 |
|
|
|
54 |
root |
1.2 |
ok (!defined sthaw sfreeze undef); |