Skip to content

Commit

Permalink
t/op/pack.t: Get it to pass under 'make minitest'
Browse files Browse the repository at this point in the history
During preparations for release of perl-5.35.6 we noticed that
t/op/pack.t was failing during 'make minitest', though passing under
'make test'.  Certain tests require Math::BigInt, which in turn now
requires Scalar::Util.  The latter is not available under miniperl.  So
we skip certain tests.

Also, Math::BigInt is now under cpan/, not dist/.

Insert one 'note' so that we can see where we are in the file.  Minor
whitespace improvements.
  • Loading branch information
jkeenan committed Nov 20, 2021
1 parent b80b9f7 commit 7007433
Showing 1 changed file with 41 additions and 37 deletions.
78 changes: 41 additions & 37 deletions t/op/pack.t
Expand Up @@ -3,7 +3,7 @@
BEGIN {
chdir 't' if -d 't';
require './test.pl'; require './charset_tools.pl';
set_up_inc(qw '../lib ../dist/Math-BigInt/lib');
set_up_inc(qw '../lib ../cpan/Math-BigInt/lib');
}

plan tests => 14720;
Expand Down Expand Up @@ -131,7 +131,7 @@ sub list_eq ($$) {
}

{
# check 'w'
note("check 'w'");
my @x = (5,130,256,560,32000,3097152,268435455,1073741844, 2**33,
'4503599627365785','23728385234614992549757750638446');
my $x = pack('w*', @x);
Expand All @@ -151,46 +151,50 @@ sub list_eq ($$) {

is(scalar(@y), 2);
is($y[1], 130);
$x = pack('w*', 5000000000); $y = '';
eval {
use Math::BigInt;
$y = pack('w*', Math::BigInt::->new(5000000000));
};
is($x, $y);

$x = pack 'w', ~0;
$y = pack 'w', (~0).'';
is($x, $y);
is(unpack ('w',$x), ~0);
is(unpack ('w',$y), ~0);

$x = pack 'w', ~0 - 1;
$y = pack 'w', (~0) - 2;

if (~0 - 1 == (~0) - 2) {
is($x, $y, "NV arithmetic");
} else {
isnt($x, $y, "IV/NV arithmetic");
}
cmp_ok(unpack ('w',$x), '==', ~0 - 1);
cmp_ok(unpack ('w',$y), '==', ~0 - 2);
SKIP: {
skip "no Scalar::Util (Math::BigInt prerequisite) on miniperl", 10, if is_miniperl();
$x = pack('w*', 5000000000); $y = '';
eval q{
use Math::BigInt;
$y = pack('w*', Math::BigInt::->new(5000000000));
};
is($x, $y, 'pack');

$x = pack 'w', ~0;
$y = pack 'w', (~0).'';
is($x, $y);
is(unpack ('w',$x), ~0);
is(unpack ('w',$y), ~0);

$x = pack 'w', ~0 - 1;
$y = pack 'w', (~0) - 2;

if (~0 - 1 == (~0) - 2) {
is($x, $y, "NV arithmetic");
} else {
isnt($x, $y, "IV/NV arithmetic");
}
cmp_ok(unpack ('w',$x), '==', ~0 - 1);
cmp_ok(unpack ('w',$y), '==', ~0 - 2);

# These should spot that pack 'w' is using NV, not double, on platforms
# where IVs are smaller than doubles, and harmlessly pass elsewhere.
# (tests for change 16861)
my $x0 = 2**54+3;
my $y0 = 2**54-2;
# These should spot that pack 'w' is using NV, not double, on platforms
# where IVs are smaller than doubles, and harmlessly pass elsewhere.
# (tests for change 16861)
my $x0 = 2**54+3;
my $y0 = 2**54-2;

$x = pack 'w', $x0;
$y = pack 'w', $y0;
$x = pack 'w', $x0;
$y = pack 'w', $y0;

if ($x0 == $y0) {
is($x, $y, "NV arithmetic");
} else {
isnt($x, $y, "IV/NV arithmetic");
if ($x0 == $y0) {
is($x, $y, "NV arithmetic");
} else {
isnt($x, $y, "IV/NV arithmetic");
}
cmp_ok(unpack ('w',$x), '==', $x0);
cmp_ok(unpack ('w',$y), '==', $y0);
}
cmp_ok(unpack ('w',$x), '==', $x0);
cmp_ok(unpack ('w',$y), '==', $y0);
}


Expand Down

0 comments on commit 7007433

Please sign in to comment.