| 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.5 |
BEGIN { $| = 1; print "1..1959\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 (length ($n) >= length ($nc)); |
| 32 |
|
|
ok (length ($n) <= length ($r)); |
| 33 |
|
|
ok (length ($r) >= length ($rr)); |
| 34 |
|
|
ok ($rr eq $rc); |
| 35 |
|
|
ok (length ($r) >= length ($rr)); |
| 36 |
|
|
|
| 37 |
|
|
#print unpack("H*", $s), " => ", unpack("H*", $rc), "\n"; |
| 38 |
|
|
|
| 39 |
|
|
ok ($s eq sthaw $n); |
| 40 |
|
|
ok ($s eq sthaw $nr); |
| 41 |
|
|
ok ($s eq sthaw $nc); |
| 42 |
|
|
ok ($s eq ${sthaw $r}); |
| 43 |
|
|
ok ($s eq ${sthaw $rr}); |
| 44 |
|
|
ok ($s eq ${sthaw $rc}); |
| 45 |
|
|
} |
| 46 |
|
|
|
| 47 |
|
|
for my $pfx (0, 1, 4, 6, 7, 40, ord('x'), 240..255) { |
| 48 |
root |
1.5 |
chk $pfx; |
| 49 |
|
|
$pfx =~ /(.*)/; |
| 50 |
|
|
chk $1; |
| 51 |
root |
1.1 |
chk chr($pfx)."x"; |
| 52 |
|
|
chk chr($pfx)."xxxxxxxxxxxxx"; |
| 53 |
|
|
chk chr($pfx)."abcdefghijklm"; |
| 54 |
|
|
} |
| 55 |
|
|
|
| 56 |
root |
1.4 |
ok (eval {sthaw undef; 1}); |
| 57 |
root |
1.3 |
ok (!eval {sthaw "\x07"; 1}); |
| 58 |
root |
1.2 |
ok (!defined sthaw sfreeze undef); |
| 59 |
root |
1.3 |
|