#!./perl -w
#
# Copyright 2002, Larry Wall.
#
# You may redistribute only under the same terms as Perl 5, as specified
# in the README file that comes with the distribution.
#
# I ought to keep this test easily backwards compatible to 5.004, so no
# qr//;
# This test checks downgrade behaviour on pre-5.8 perls when new 5.8 features
# are encountered.
chdir('t') if -d 't';
} else {
}
print "1..0 # Skip: Storable was not built\n";
exit 0;
}
}
use strict;
my $max_uv = ~0;
# Express it in this way so as not to use any addition, as 5.6 maths would
# do this in NVs on 64 bit machines, and we're overflowing IVs so can't use
# use integer.
my $lots_of_9C = do {
local $^W;
eval $temp;
};
);
my @numbers =
(# IV bounds of 8 bits
-1, 0, 1, -127, -128, -129, 42, 126, 127, 128, 129, 254, 255, 256, 257,
# IV bounds of 32 bits
-2147483647, -2147483648, -2147483649, 2147483646, 2147483647, 2147483648,
# IV bounds
# UV bounds at 32 bits
0x7FFFFFFF, 0x80000000, 0x80000001, 0xFFFFFFFF, 0xDEADBEEF,
# UV bounds
# NV-UV conversion
2559831922.0,
);
my $file = "integer.$$";
sub do_clone {
my $data = shift;
return $copy;
}
sub freeze_and_thaw {
my $data = shift;
return $copy;
}
sub nfreeze_and_thaw {
my $data = shift;
return $copy;
}
sub store_and_retrieve {
my $data = shift;
return $copy;
}
sub nstore_and_retrieve {
my $data = shift;
return $copy;
}
# as $number is an alias into @numbers, we don't want any side effects of
# conversion macros affecting later runs, so pass a copy to Storable:
# Test inside use integer to see if the bit pattern is identical
# and outside to see if the sign is right.
# On 5.8 we don't need this trickery anymore.
# We really do need 2 copies here, as conversion may have side effect
# bugs. In particular, I know that this happens:
# perl5.00503 -le '$a = "-2147483649"; $a & 0; print $a; print $a+1'
# -2147483649
# 2147483648
# on 5.6 can't do this with
# my $eq = do {use integer; $copy_s1 == $copy1} && $copy_s1 == $copy1;
# because on builds with IV as long long it tickles bugs.
# (Uncomment it and the Devel::Peek line below to see the messed up
# state of the scalar, with PV showing the correct string for the
# number, and IV holding a bogus value which has been truncated to 32 bits
# So, check the bit patterns are identical, and check that the sign is the
# same. This works on all the versions in all the sizes.
# $eq = && (($copy_s1 <=> 0) == ($copy1 <=> 0));
# Split this into 2 tests, to cater for 5.005_03
# Aargh. Even this doesn't work because 5.6.x sends values with (same
# number of decimal digits as ~0 + 1) via atof. So ^ is getting strings
# cast to doubles cast to integers. And that truncates low order bits.
# my $bit = ok (($copy_s1 ^ $copy1) == 0, "$process $copy1 (bitpattern)");
# Oh well; at least the parser gets it right. :-)
# gets it right, providing you don't have side effects of conversion.
# local $TODO;
# if $[ < 5.005_56 and $copy1 > $max_iv;
# use Devel::Peek; Dump $number; Dump $copy1; Dump $copy_s1;
}
# unless ($bit) { use Devel::Peek; Dump $copy_s1; Dump $$copy_s; }
} else {
}
}
}