Skip Menu |

This queue is for tickets about the DateTime-LazyInit CPAN distribution.

Report information
The Basics
Id: 122130
Status: new
Priority: 0/
Queue: DateTime-LazyInit

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

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



Subject: Test fails during install
Hi, This won't install at the moment because one of the tests causes a crash. PERL_DL_NONLAZY=1 "/usr/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t t/DateTime-LazyInit.t .. 1/107 Cannot subtract 0008-08-08T08:08:08 from a DateTime object (DateTime=HASH(0x30ee980)). Only a DateTime::Duration or DateTime object can be subtracted from a DateTime object. at t/DateTime-LazyInit.t line 122. # Looks like your test exited with 255 just after 58. t/DateTime-LazyInit.t .. Dubious, test returned 255 (wstat 65280, 0xff00) The problem is here where a DateTime::LazyInit object is being substracted from the DateTime object: diag("Testing subtraction overload") if $verbose; my $dtd = $dtli[0] - $dtli[1]; isa_ok($dtli[0] => 'DateTime'); isa_ok($dtli[1] => 'DateTime::LazyInit'); isa_ok($dtd => 'DateTime::Duration'); It can be worked around by forcing the object to inflate and changing the isa_ok type check: diag("Testing subtraction overload") if $verbose; my $dtd = $dtli[0] - $dtli[1]->inflate; isa_ok($dtli[0] => 'DateTime'); isa_ok($dtli[1] => 'DateTime'); isa_ok($dtd => 'DateTime::Duration'); but then the behaviour isn't the same as for a pure DateTime object.
The problem is more subtle than it looks at first. This line in the test: is ($dtli[0]->time_zone->name => 'UTC'); inflates the DTLI object to a DateTime object so that my $dtd = $dtli[0] - $dtli[1] is subtracting a DTLI object from a DT object which is illegal. Subtracting a DTLI object from another DTLI object inflates both objects before doing the subtraction. It works. Not sure what isa_ok($dtli => 'DateTime::LazyInit'); is supposed to do. isa_ok($dtli[0] => 'DateTime::LazyInit'); would detect the problem.