Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the DateTime CPAN distribution.

Report information
The Basics
Id: 53942
Status: resolved
Priority: 0/
Queue: DateTime

People
Owner: Nobody in particular
Requestors: MAROS [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Unimportant
Broken in: (no value)
Fixed in: (no value)



Subject: Comparison of two DT objects with nanoseconds sometimes fails
Hi, for quite a while I have been observing some weird behavior in the DateTime::Format::CLDR test suite which most likely originates from DateTime. I have written a test case (http://cpansearch.perl.org/src/MAROS/DateTime-Format-CLDR-1.10/t/011_nanosecond.t and http://cpansearch.perl.org/src/MAROS/DateTime-Format-CLDR-1.10/t/lib/testlib.pm) which generates a DateTime object with nanoseconds, prints it out, parses the output, returns a new DateTime object and then finally compares the two objects (via DateTime->compare_ignore_floating). However this test *sometimes* fails (according to cpan testers - however I have never experienced such a test failure myself). The stringified DT objects look exactly the same, but nonetheless compare_ignore_floating returns false. Here are some reported test failures: http://www.cpantesters.org/cpan/report/6711070 http://www.cpantesters.org/cpan/report/5583764 http://www.cpantesters.org/cpan/report/5373996 http://www.cpantesters.org/cpan/report/5374015 So far I was not able to narrow the problem down to a certain OS/Perl version/32-64bit/DateTime version/DT::Format::CLDR version ... For now I'd suggest adding the following test to DateTime' 07compare test: # sub-second equals { my $date1 = DateTime->new( year => 2000, month => 10, day => 24, hour => 12, minute => 0, second => 0, nanosecond => 10000, ); my $date2 = DateTime->new( year => 2000, month => 10, day => 24, hour => 12, minute => 0, second => 0, nanosecond => 10000, ); is( DateTime->compare( $date1, $date2 ), 0, 'Comparison with floating time (cmp)' ); is( ($date1 <=> $date2), 0, 'Comparison with floating time (<=>)' ); is( ($date1 cmp $date2), 0, 'Comparison with floating time (cmp)' ); is( DateTime->compare_ignore_floating($date1, $date2), 0, 'Comparison with compare_ignore_floating (cmp)' ); } Cheers Maros
Show quoted text
> The stringified DT > objects look exactly the same, but nonetheless compare_ignore_floating > returns false.
This should of course be "The stringified DT objects look exactly the same, but nonetheless compare_ignore_floating returns 1 or -1, indicating that the two objects differ" Cheers Maros
If the nvsize of the perl compiler is 16 this test is failing. Show quoted text
> # sub-second equals > { > my $date1 = DateTime->new( year => 2000, month => 10, day => 24, > hour => 12, minute => 0, second => 0, > nanosecond => 10000, > ); > > my $date2 = DateTime->new( year => 2000, month => 10, day => 24, > hour => 12, minute => 0, second => 0, > nanosecond => 10000, > ); > > is( DateTime->compare( $date1, $date2 ), 0, 'Comparison with > floating time (cmp)' ); > is( ($date1 <=> $date2), 0, 'Comparison with floating time (<=>)' > ); > is( ($date1 cmp $date2), 0, 'Comparison with floating time (cmp)' > ); > is( DateTime->compare_ignore_floating($date1, $date2), 0, > 'Comparison with compare_ignore_floating (cmp)' ); > }
On Fri Nov 05 03:58:44 2010, MAROS wrote: Show quoted text
> If the nvsize of the perl compiler is 16 this test is failing.
On what platforms is it 16? My system is 64-bit but my nvsize is still 8.
Am Fr 05. Nov 2010, 22:40:51, DROLSKY schrieb: Show quoted text
> On Fri Nov 05 03:58:44 2010, MAROS wrote:
> > If the nvsize of the perl compiler is 16 this test is failing.
> > On what platforms is it 16? My system is 64-bit but my nvsize is still 8.
See http://analysis.cpantesters.org/reports_by_field?SUBMIT_xxx=Submit&distv=DateTime-Format-CLDR-1.12&field=conf%3Aarchname for more details: Looks like x86_64-linux-thread-multi-ld with uselongdouble mostly on amd64 are affected.