1#!perl -w 2 3BEGIN { 4 unshift @INC, 't'; 5 unshift @INC, 't/compat' if $] < 5.006002; 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); 21use Test::More; 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 30plan(tests => 3 * @dumps); 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 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"); 45 46 unlink($file); 47} 48