Subject: | DT large-NV rounding fail |
Date: | Mon, 25 Apr 2011 07:22:59 +0100 |
To: | bug-DateTime [...] rt.cpan.org |
From: | Zefram <zefram [...] fysh.org> |
DateTime-0.67 fails its tests on a Perl where NV is the x87 80-bit format:
{{{
t/13strftime.t ................... 1/?
# Failed test 'strftime(%7N) for 1297777805.12 == 1199999'
# at t/13strftime.t line 155.
# got: '1200000'
# expected: '1199999'
# Failed test 'strftime(%8N) for 1297777805.12 == 11999989'
# at t/13strftime.t line 155.
# got: '12000000'
# expected: '11999989'
# Failed test 'strftime(%9N) for 1297777805.12 == 119999885'
# at t/13strftime.t line 155.
# got: '119999999'
# expected: '119999885'
# Failed test 'strftime(%10N) for 1297777805.12 == 1199998850'
# at t/13strftime.t line 155.
# got: '1199999990'
# expected: '1199998850'
# Looks like you failed 4 tests of 148.
t/13strftime.t ................... Dubious, test returned 4 (wstat 1024, 0x400)
Failed 4/148 subtests
}}}
Everything else passes. Looking at the failing test script, it's
obviously been written specifically for 64-bit IEEE double as NV. It's
going to fail with almost any other kind of NV. Possibly you really want
to test whether the fractional part of the seconds is *at least as close*
to the true value as some NV format yields, so maybe you want to change
is(
$dt->strftime($spec), $val,
"strftime($spec) for $epoch == $val"
);
to something like
ok $dt->strftime($spec) >= $val &&
$dt->strftime($spec) <= int(12*10**($x-3)),
"strftime($spec) for $epoch";
-zefram