This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Document string- and number-specific bitops in perlop
[perl5.git] / dist / Storable / t / compat01.t
CommitLineData
2fc01f5f
GA
1#!perl -w
2
3BEGIN {
48c887dd 4 unshift @INC, 't';
1afdebce 5 unshift @INC, 't/compat' if $] < 5.006002;
2fc01f5f
GA
6 require Config; import Config;
7 if ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bStorable\b/) {
8 print "1..0 # Skip: Storable was not built\n";
9 exit 0;
10 }
11
12 use Config;
13 if ($Config{byteorder} ne "1234") {
14 print "1..0 # Skip: Test only works for 32 bit little-ending machines\n";
15 exit 0;
16 }
17}
18
19use strict;
20use Storable qw(retrieve);
dddb60fc 21use Test::More;
2fc01f5f
GA
22
23my $file = "xx-$$.pst";
24my @dumps = (
25 # some sample dumps of the hash { one => 1 }
26 "perl-store\x041234\4\4\4\x94y\22\b\3\1\0\0\0vxz\22\b\1\1\0\0\x001Xk\3\0\0\0oneX", # 0.1
27 "perl-store\0\x041234\4\4\4\x94y\22\b\3\1\0\0\0vxz\22\b\b\x81Xk\3\0\0\0oneX", # 0.4@7
28);
29
dddb60fc 30plan(tests => 3 * @dumps);
2fc01f5f
GA
31
32my $testno;
33for my $dump (@dumps) {
34 $testno++;
35
36 open(FH, ">$file") || die "Can't create $file: $!";
37 binmode(FH);
38 print FH $dump;
39 close(FH) || die "Can't write $file: $!";
40
dddb60fc
NC
41 my $data = eval { retrieve($file) };
42 is($@, '', "No errors for $file");
43 is(ref $data, 'HASH', "Got HASH for $file");
44 is($data->{one}, 1, "Got data for $file");
2fc01f5f
GA
45
46 unlink($file);
47}