-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
t/31.schema.t fails tests 238 and 3838 when nvtype is IBM DoubleDouble #33
Comments
Thanks! I actually want to compare via I fixed the test simply by avoiding rounding errors with Could you test it? |
It seems that the first change where cmp_ok() is changed from performing an 'eq' test to an '==' might be the wrong thing. That's not causing any tests to fail, but for me the second change, where $data is replaced by sprintf("%0.2f",$data), is alone sufficient to allow all tests to pass. However, I don't think I'm using the exact same version of 31.schema.t as is presented at 9e907d1 . The interesting thing about that second change is that it fixes the failures by coercing the LHS of the '==' comparison to the same incorrect representation of 685230.15 as held by the RHS ($def{data}). Cheers, |
See #33 Also use `header` option for dumper
Huh, weird. Thanks! |
Yep - https://github.com/perlpunk/YAML-PP-p5/blob/testfloat/t/31.schema.t is fine. Cheers, |
Hi,
This is a -Duselongdouble build of perl-5.32.0 (and 5.31.0 suffers the same problem) on Debian wheezy:
$ perl -V:longdblkind
longdblkind='6';
The errors are reported in the test suite as follows:
t/31.schema.t .............. 20/?
# Failed test '(yaml11) type float: load(!!float 190:20:30.15) eq '685230.15''
# at t/31.schema.t line 138.
# got: 685230.15
# expected: 685230.15
t/31.schema.t .............. 3615/?
# Failed test '(yaml11) type float: load(190:20:30.15) eq '685230.15''
# at t/31.schema.t line 138.
# got: 685230.15
# expected: 685230.15
t/31.schema.t .............. 4123/? # Looks like you failed 2 tests of 4394.
t/31.schema.t .............. Dubious, test returned 2 (wstat 512, 0x200)
Failed 2/4394 subtests
and, at the end of the test suite:
t/31.schema.t (Wstat: 512 Tests: 4394 Failed: 2)
Failed tests: 238, 3838
Non-zero exit status: 2
The problem is that $data != $def{data} in this particular case, though they are both (obviously) stringifying to the same string of "685230.15".
For this particular case
scalar(reverse(unpack "h*", pack("D<", $data))) is 4124e95c4ccccccdbdb999999999999a
scalar(reverse(unpack "h*", pack("D<", $def{data}))) is 4124e95c4ccccccdbdb9999999999998
which is a very minor discrepancy (of 2 units in the last place).
The former value (ie $data) is the correct representation of 685230.15 for this architecture, though both perl and C will inaccurately assign the latter value (which translates to 685230.150000000000000000000000005.
(The least significant double is a negative value, so $def{data} is in fact greater than $data, despite the appearance to the contrary.)
Could the test be changed from "==" to "eq" ? (The diagnostic message suggests that the intention was to test "eq", not "==".)
Cheers,
Rob
The text was updated successfully, but these errors were encountered: