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

optionally support bigints and bignums #10

Closed
karenetheridge opened this issue May 3, 2020 · 5 comments
Closed

optionally support bigints and bignums #10

karenetheridge opened this issue May 3, 2020 · 5 comments

Comments

@karenetheridge
Copy link
Owner

Cpanel::JSON::XS has a 'get_allow_bignum' option which inflates very large numbers into Math::BigInt or Math::BigFloat objects. If desired, we should support validating integers and numbers using this.

@karenetheridge karenetheridge changed the title optionally support bigints optionally support bigints and bignums May 3, 2020
@karenetheridge
Copy link
Owner Author

any interesting tests I come up with should be added to the test suite - see json-schema-org/JSON-Schema-Test-Suite#378

@karenetheridge
Copy link
Owner Author

karenetheridge commented May 31, 2020

This should fix the issues I'm seeing on this smoker here -- http://www.cpantesters.org/cpan/report/c65fadbe-a2d4-11ea-9066-e374b0ba08e8

on my box:

perl -MCpanel::JSON::XS=decode_json -MDevel::Peek -wle'my $data = decode_json(q{[ 9007199254740992, 9007199254740992.0 ]}); Dump($_) foreach @$data; print $_ foreach @$data'
SV = IV(0x7fd6180025e8) at 0x7fd6180025f8
  REFCNT = 2
  FLAGS = (IOK,pIOK)
  IV = 9007199254740992
SV = NV(0x7fd618002760) at 0x7fd618002778
  REFCNT = 2
  FLAGS = (NOK,pNOK)
  NV = 9.00719925474099e+15
9007199254740992
9.00719925474099e+15

let's see what it looks like on BinGOs's machine..

@bingos
Copy link

bingos commented May 31, 2020

Different VM from the one that generated that report, but another 32bit Debian. Got a similar fail, so here is the output:

$ /opt/perl-5.22.4/bin/perl -MCpanel::JSON::XS=decode_json -MDevel::Peek -wle'my $data = decode_json(q{[ 9007199254740992, 9007199254740992.0 ]}); Dump($_) foreach @$data; print $_ foreach @$data'
SV = PV(0x1fb70e0) at 0x1fb6500
  REFCNT = 2
  FLAGS = (POK,pPOK)
  PV = 0x1fcbaf0 "9007199254740992"\0
  CUR = 16
  LEN = 18
SV = NV(0x1fd51fc) at 0x1fb6f90
  REFCNT = 2
  FLAGS = (NOK,pNOK)
  NV = 9.00719925474099e+15
9007199254740992
9.00719925474099e+15

@karenetheridge
Copy link
Owner Author

until I add bigint/bignum handling, I should just mark this specific test TODO if $Config{something}.

karenetheridge added a commit that referenced this issue May 31, 2020
where ivsize < 8, the integer is being represented as a PV rather than an IV;
where nvsize < 8, the float is being represented as a PV rather than an NV;
if one of these comes through as a string, comparison with the other will
fail on the types being different; if both come through as a string, the
string comparison will fail.

e.g. see GHI #10 and
http://www.cpantesters.org/cpan/report/d9ff55c4-a13d-11ea-9066-e374b0ba08e8
http://www.cpantesters.org/cpan/report/a1898f1c-a097-11ea-b276-2fafcccccfd6
http://www.cpantesters.org/cpan/report/f6457db7-6bf7-1014-9edb-f53f8c633b70
karenetheridge added a commit that referenced this issue May 31, 2020
          - add infinite recursion detection
          - process properties in sorted order, for consistent ordering of
            results
          - mark a numeric comparison test as TODO on 32-bit machines (see
            GHI #10)
@karenetheridge
Copy link
Owner Author

This is now complete, and with version 0.537, hopefully bug free.

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

No branches or pull requests

2 participants