Skip to content

Commit

Permalink
Remove code in Storable's tests that handles perl < v5.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
nwc10 committed Aug 30, 2021
1 parent c4651bb commit a86a81d
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 68 deletions.
56 changes: 8 additions & 48 deletions dist/Storable/t/downgrade.t
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,8 @@ if ($] > 5.007002) {
my $a_circumflex = (ord ('A') == 193 ? "\x47" : "\xe5");
%U_HASH = (map {$_, $_} 'castle', "ch${a_circumflex}teau", $utf8, chr 0x57CE);
plan tests => 169;
} elsif ($] >= 5.006) {
plan tests => 59;
} else {
plan tests => 67;
plan tests => 59;
}

$UTF8_CROAK = "/^Cannot retrieve UTF8 data in non-UTF8 perl/";
Expand Down Expand Up @@ -91,17 +89,7 @@ sub thaw_scalar {
my $scalar = eval {thaw $tests{$name}};
is ($@, '', "Thawed $name without error?");
isa_ok ($scalar, 'SCALAR', "Thawed $name?");
if ($bug and $] == 5.006) {
# Aargh. <expletive> <expletive> 5.6.0's harness doesn't even honour
# TODO tests.
warn "# Test skipped because eq is buggy for certain Unicode cases in 5.6.0";
warn "# Please upgrade to 5.6.1\n";
ok ("I'd really like to fail this test on 5.6.0 but I'm told that CPAN auto-dependencies mess up, and certain vendors only ship 5.6.0. Get your vendor to ugrade. Else upgrade your vendor.");
# One such vendor being the folks who brought you LONG_MIN as a positive
# integer.
} else {
is ($$scalar, $expected, "And it is the data we expected?");
}
is ($$scalar, $expected, "And it is the data we expected?");
$scalar;
}

Expand Down Expand Up @@ -189,26 +177,11 @@ if (eval "use Hash::Util; 1") {
thaw_fail ('Locked keys placeholder', $RESTRICTED_CROAK);
}

if ($] >= 5.006) {
print "# We have utf8 scalars, so test that the utf8 scalars in <DATA> are valid\n";
thaw_scalar ('Short 8 bit utf8 data', "\xDF", 1);
thaw_scalar ('Long 8 bit utf8 data', "\xDF" x 256, 1);
thaw_scalar ('Short 24 bit utf8 data', chr 0xC0FFEE);
thaw_scalar ('Long 24 bit utf8 data', chr (0xC0FFEE) x 256);
} else {
print "# We don't have utf8 scalars, so test that the utf8 scalars downgrade\n";
thaw_fail ('Short 8 bit utf8 data', $UTF8_CROAK);
thaw_fail ('Long 8 bit utf8 data', $UTF8_CROAK);
thaw_fail ('Short 24 bit utf8 data', $UTF8_CROAK);
thaw_fail ('Long 24 bit utf8 data', $UTF8_CROAK);
local $Storable::drop_utf8 = 1;
my $bytes = thaw $tests{'Short 8 bit utf8 data as bytes'};
thaw_scalar ('Short 8 bit utf8 data', $$bytes);
thaw_scalar ('Long 8 bit utf8 data', $$bytes x 256);
$bytes = thaw $tests{'Short 24 bit utf8 data as bytes'};
thaw_scalar ('Short 24 bit utf8 data', $$bytes);
thaw_scalar ('Long 24 bit utf8 data', $$bytes x 256);
}
print "# We have utf8 scalars, so test that the utf8 scalars in <DATA> are valid\n";
thaw_scalar ('Short 8 bit utf8 data', "\xDF", 1);
thaw_scalar ('Long 8 bit utf8 data', "\xDF" x 256, 1);
thaw_scalar ('Short 24 bit utf8 data', chr 0xC0FFEE);
thaw_scalar ('Long 24 bit utf8 data', chr (0xC0FFEE) x 256);

if ($] > 5.007002) {
print "# We have utf8 hashes, so test that the utf8 hashes in <DATA> are valid\n";
Expand Down Expand Up @@ -240,8 +213,7 @@ if ($] > 5.007002) {
thaw_fail ('Hash with utf8 keys', $UTF8_CROAK);
thaw_fail ('Locked hash with utf8 keys', $UTF8_CROAK);
local $Storable::drop_utf8 = 1;
my $what = $] < 5.006 ? 'pre 5.6' : '5.6';
my $expect = thaw $tests{"Hash with utf8 keys for $what"};
my $expect = thaw $tests{"Hash with utf8 keys for 5.6"};
thaw_hash ('Hash with utf8 keys', $expect);
#foreach (keys %$expect) { print "'$_':\t'$expect->{$_}'\n"; }
#foreach (keys %$got) { print "'$_':\t'$got->{$_}'\n"; }
Expand Down Expand Up @@ -370,12 +342,6 @@ D96%U%P/EGXX%`````^6?CA<'4V-H;&_#GP8````&4V-H;&_?
end
begin 101 Hash with utf8 keys for pre 5.6
M!049``````0*!F-A<W1L90`````&8V%S=&QE"@=C:.5T96%U``````=C:.5T
D96%U"@/EGXX``````^6?C@H'4V-H;&_#GP(````&4V-H;&_?
end
begin 101 Hash with utf8 keys for 5.6
M!049``````0*!F-A<W1L90`````&8V%S=&QE"@=C:.5T96%U``````=C:.5T
D96%U%P/EGXX``````^6?CA<'4V-H;&_#GP(````&4V-H;&_?
Expand Down Expand Up @@ -494,12 +460,6 @@ FHY.%%P3<9')5!0````3<9')5%P?B@XB3EHMS!@````;B@XB3EM\`
end
begin 301 Hash with utf8 keys for pre 5.6
M!049``````0*!H.!HJ.3A0`````&@X&BHY.%"@B#B(M&HX6!I``````'@XA'
GHX6!I`H'XH.(DY:+<P(````&XH.(DY;?"@3<9')5``````3<9')5
end
begin 301 Hash with utf8 keys for 5.6
M!049``````0*!H.!HJ.3A0`````&@X&BHY.%"@>#B$>CA8&D``````>#B$>C
FA8&D%P?B@XB3EHMS`@````;B@XB3EM\7!-QD<E4`````!-QD<E4`
Expand Down
1 change: 0 additions & 1 deletion dist/Storable/t/freeze.t
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ thaw $frozen; # used to segfault here
pass("Didn't segfault");

SKIP: {
skip 'no av_exists', 2 unless $] >= 5.006;
my (@a, @b);
eval '
$a = []; $#$a = 2; $a->[1] = undef;
Expand Down
5 changes: 0 additions & 5 deletions dist/Storable/t/integer.t
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,6 @@ foreach (@processes) {
die "Was supposed to have number $copy_s3, got error $@"
unless defined $copy_s3;
my $bit = ok (($copy_s3 ^ $copy1) == 0, "$process $copy1 (bitpattern)");
# This is sick. 5.005_03 survives without the IV/UV flag, and somehow
# gets it right, providing you don't have side effects of conversion.
# local $TODO;
# $TODO = "pre 5.6 doesn't have flag to distinguish IV/UV"
# if $] < 5.005_56 and $copy1 > $max_iv;
my $sign = ok (($copy_s2 <=> 0) == ($copy2 <=> 0),
"$process $copy1 (sign)");

Expand Down
5 changes: 1 addition & 4 deletions dist/Storable/t/make_downgrade.pl
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,14 @@ sub uuencode_it {

uuencode_it (\%uhash, "Locked hash with utf8 keys");

my (%pre56, %pre58);
my %pre58;

while (my ($key, $val) = each %uhash) {
# hash keys are always stored downgraded to bytes if possible, with a flag
# to say "promote back to utf8"
# Whereas scalars are stored as is.
utf8::encode ($key) if ord $key > 256;
$pre58{$key} = $val;
utf8::encode ($val) unless $val eq "ch\xe5teau";
$pre56{$key} = $val;

}
uuencode_it (\%pre56, "Hash with utf8 keys for pre 5.6");
uuencode_it (\%pre58, "Hash with utf8 keys for 5.6");
7 changes: 1 addition & 6 deletions dist/Storable/t/restrict.t
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,7 @@ sub BEGIN {
exit 0;
}
} else {
if ($] < 5.005) {
print "1..0 # Skip: No Hash::Util pre 5.005\n";
exit 0;
# And doing this seems on 5.004 seems to create bogus warnings about
# uninitialized variables, or coredumps in Perl_pp_padsv
} elsif (!eval "require Hash::Util") {
if (!eval "require Hash::Util") {
if ($@ =~ /Can\'t locate Hash\/Util\.pm in \@INC/s) {
print "1..0 # Skip: No Hash::Util:\n";
exit 0;
Expand Down
4 changes: 0 additions & 4 deletions dist/Storable/t/utf8.t
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
#

sub BEGIN {
if ($] < 5.006) {
print "1..0 # Skip: no utf8 support\n";
exit 0;
}
unshift @INC, 't';
unshift @INC, 't/compat' if $] < 5.006002;
require Config; import Config;
Expand Down

0 comments on commit a86a81d

Please sign in to comment.