Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests failure with Math::BigInt >= 1.999840 #96

Closed
xavierba opened this issue Oct 2, 2023 · 2 comments
Closed

Tests failure with Math::BigInt >= 1.999840 #96

xavierba opened this issue Oct 2, 2023 · 2 comments

Comments

@xavierba
Copy link

xavierba commented Oct 2, 2023

Hi,

CryptX fails at some test when built against Math::BigInt >= 1.999840

# Math::BigInt VERSION=1.999841
t/mbi_ltm_01load.t .................. ok
#   Failed test '$x = Math::BigFloat->new("1"); $y = Math::BigFloat->new("1"); $x >> $y;'
#   at ./t/mbi_ltm/bigfltpm.inc line 168.
#          got: '0'
#     expected: '0.5'
#   Failed test '$x = Math::BigFloat->new("123"); $y = Math::BigFloat->new("1"); $x >> $y;'
#   at ./t/mbi_ltm/bigfltpm.inc line 168.
#          got: '61'
#     expected: '61.5'
#   Failed test '$x = Math::BigFloat->new("2"); $y = Math::BigFloat->new("18.2"); $x <<= $y; $x->copy()->bfround(-9);'
#   at ./t/mbi_ltm/bigfltpm.inc line 502.
#          got: '524288.000000000'
#     expected: '602248.763144685'
# Looks like you failed 3 tests of 2396.
t/mbi_ltm_bigfltpm.t ................ 
Dubious, test returned 3 (wstat 768, 0x300)
Failed 3/2396 subtests 
        (less 1 skipped subtest: 2392 okay)
t/mbi_ltm_bigintg.t ................. ok
#   Failed test '$x = Math::BigInt->new("+8"); $y = Math::BigInt->new("-2"); $x << $y;'
#   at ./t/mbi_ltm/bigintpm.inc line 202.
#          got: '2'
#     expected: 'NaN'
#   Failed test '$x = Math::BigInt->new("+1234"); $y = Math::BigInt->new("-3"); $x->blsft($y, 10);'
#   at ./t/mbi_ltm/bigintpm.inc line 202.
#          got: '1'
#     expected: 'NaN'
#   Failed test '$x = Math::BigInt->new("+2"); $y = Math::BigInt->new("-2"); $x >> $y;'
#   at ./t/mbi_ltm/bigintpm.inc line 202.
#          got: '8'
#     expected: 'NaN'
#   Failed test '$x = Math::BigInt->new("+1234"); $y = Math::BigInt->new("-3"); $x->brsft($y, 10);'
#   at ./t/mbi_ltm/bigintpm.inc line 202.
#          got: '1234000'
#     expected: 'NaN'
# Looks like you failed 4 tests of 3718.
t/mbi_ltm_bigintpm.t ................ 
Dubious, test returned 4 (wstat 1024, 0x400)
Failed 4/3718 subtests 
        (less 50 skipped subtests: 3664 okay)

From Math::BigInt 1.999840 changelog:

  • Add methods bblsft() and bbrsft(), which do bitwise left and right shift,
    respectively. The binary operators for bitwise left and right shift, "<<"
    and ">>", now call the methods bblsft() and bbrsft(), respectively.

    While this behaviour is consistent with how "<<" and ">>" work on floating
    point numbers in core Perl, it changes how "<<" and ">>" worked on
    Math::BigFloat objects. This is a corner case, but any code currently using
    "<<" and ">>" on Math::BigFloat objects might need to be modified as follows

    $x >>= $y    should be changed to    $x -> brsft($y)
    $x <<= $y    should be changed to    $x -> blsft($y)
    $x >>  $y    should be changed to    $x -> copy() -> brsft($y)
    $x <<  $y    should be changed to    $x -> copy() -> blsft($y)
    

This was initially reported by Petr Pisar at: https://bugzilla.redhat.com/show_bug.cgi?id=2240587

@karel-m
Copy link
Contributor

karel-m commented Oct 2, 2023

Already fixed in the latest devel version CryptX-0.079_004

@karel-m karel-m closed this as completed Oct 2, 2023
@xavierba
Copy link
Author

xavierba commented Oct 2, 2023

Thanks for the quick answer. I confirm that 62fde62 fixes the issue.
However, I believe t/mbi_ltm_since_1.999842.t should be run for Math::BigInt 1.999840 and later, and thus be renamed and tweaked accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants