Re: Bug: Storable on Infinite Dates Broken
Assuming the tests pass, please feel free to check it in. all tests passed. checked in. --d
Re: Bug: Storable on Infinite Dates Broken
On Mon, 2 Aug 2004, Daisuke Maki wrote: > From the Storable docs: > >The first time the hook is hit in a serialization flow, you may >have it return an empty list. That will signal the Storable engine >to further discard that hook for this class and to therefore revert >to the default serialization of the underlying Perl data. The hook >will again be normally processed in the next serialization. > > I think this is the behavior that we'd want I think (the wording is > a bit ambiguous to me, but it sounds like it) Ah, I didn't remember that. > And here's the test to go with it. > Your wish is my command ;) Assuming the tests pass, please feel free to check it in. -dave
Re: Bug: Storable on Infinite Dates Broken
From the Storable docs: The first time the hook is hit in a serialization flow, you may have it return an empty list. That will signal the Storable engine to further discard that hook for this class and to therefore revert to the default serialization of the underlying Perl data. The hook will again be normally processed in the next serialization. I think this is the behavior that we'd want I think (the wording is a bit ambiguous to me, but it sounds like it) And here's the test to go with it. Your wish is my command ;) Index: t/23storable.t === RCS file: /cvsroot/perl-date-time/modules/DateTime.pm/t/23storable.t,v retrieving revision 1.2 diff -d -u -r1.2 23storable.t --- t/23storable.t 6 Jul 2003 16:48:37 - 1.2 +++ t/23storable.t 2 Aug 2004 07:46:02 - @@ -8,7 +8,7 @@ if ( eval { require Storable; 1 } ) { -plan tests => 5; +plan tests => 15; } else { @@ -16,29 +16,34 @@ } { -my $dt = +my @dt = ( DateTime->new( year => 1950, hour => 1, nanosecond => 1, time_zone => 'America/Chicago', language => 'German' - ); - -my $copy = Storable::thaw( Storable::nfreeze($dt) ); - -is( $copy->time_zone->name, 'America/Chicago', -'Storable freeze/thaw preserves tz' ); - -is( ref $copy->locale, 'DateTime::Locale::de', -'Storable freeze/thaw preserves locale' ); - -is( $copy->year, 1950, -'Storable freeze/thaw preserves rd values' ); - -is( $copy->hour, 1, -'Storable freeze/thaw preserves rd values' ); + ), +DateTime::Infinite::Past->new, +DateTime::Infinite::Future->new, +); -is( $copy->nanosecond, 1, -'Storable freeze/thaw preserves rd values' ); +foreach my $dt (@dt) { +my $copy = Storable::thaw( Storable::nfreeze($dt) ); + +is( $copy->time_zone->name, $dt->time_zone->name, +'Storable freeze/thaw preserves tz' ); + +is( ref $copy->locale, ref $dt->locale, +'Storable freeze/thaw preserves locale' ); + +is( $copy->year, $dt->year, +'Storable freeze/thaw preserves rd values' ); + +is( $copy->hour, $dt->hour, +'Storable freeze/thaw preserves rd values' ); + +is( $copy->nanosecond, $dt->nanosecond, +'Storable freeze/thaw preserves rd values' ); +} } Dave Rolsky wrote: On Mon, 2 Aug 2004, Daisuke Maki wrote: I supppose something like this would fix the problem? Index: lib/DateTime/Infinite.pm === RCS file: /cvsroot/perl-date-time/modules/DateTime.pm/lib/DateTime/Infinite.pm,v retrieving revision 1.8 diff -d -u -r1.8 Infinite.pm --- lib/DateTime/Infinite.pm24 Jul 2003 04:24:16 - 1.8 +++ lib/DateTime/Infinite.pm2 Aug 2004 07:23:17 - @@ -27,6 +27,9 @@ return ($_[1]) x 3; } +sub STORABLE_freeze { return } +sub STORABLE_thaw { return } It does? Won't this just freeze nothing? I think we need some tests ;) -dave /*=== House Absolute Consulting www.houseabsolute.com ===*/
Re: Bug: Storable on Infinite Dates Broken
On Mon, 2 Aug 2004, Daisuke Maki wrote: > I supppose something like this would fix the problem? > > Index: lib/DateTime/Infinite.pm > === > RCS file: > /cvsroot/perl-date-time/modules/DateTime.pm/lib/DateTime/Infinite.pm,v > retrieving revision 1.8 > diff -d -u -r1.8 Infinite.pm > --- lib/DateTime/Infinite.pm24 Jul 2003 04:24:16 - 1.8 > +++ lib/DateTime/Infinite.pm2 Aug 2004 07:23:17 - > @@ -27,6 +27,9 @@ > return ($_[1]) x 3; > } > > +sub STORABLE_freeze { return } > +sub STORABLE_thaw { return } It does? Won't this just freeze nothing? I think we need some tests ;) -dave /*=== House Absolute Consulting www.houseabsolute.com ===*/
Re: Bug: Storable on Infinite Dates Broken
I supppose something like this would fix the problem? Index: lib/DateTime/Infinite.pm === RCS file: /cvsroot/perl-date-time/modules/DateTime.pm/lib/DateTime/Infinite.pm,v retrieving revision 1.8 diff -d -u -r1.8 Infinite.pm --- lib/DateTime/Infinite.pm24 Jul 2003 04:24:16 - 1.8 +++ lib/DateTime/Infinite.pm2 Aug 2004 07:23:17 - @@ -27,6 +27,9 @@ return ($_[1]) x 3; } +sub STORABLE_freeze { return } +sub STORABLE_thaw { return } + package DateTime::Infinite::Future; use base qw(DateTime::Infinite); Max Campos wrote: Just FYI - Storable freeze seems to fail when running against a DateTime::Infinite::Future/Past object. I believe it's because $self->{locale} is not being defined. I don't have a patch, but I thought you may want to at least scribble this one down in the bug tracker. === use DateTime::Infinite; use Storable; my $future = DateTime::Infinite::Future->new; Storable::freeze($future); === Item #1 returned by STORABLE_freeze for DateTime::Infinite::Future is not a reference at ../../lib/Storable.pm (autosplit into ../../lib/auto/Storable/_freeze.al) line 282, at foo line 5
Bug: Storable on Infinite Dates Broken
Just FYI - Storable freeze seems to fail when running against a DateTime::Infinite::Future/Past object. I believe it's because $self->{locale} is not being defined. I don't have a patch, but I thought you may want to at least scribble this one down in the bug tracker. === use DateTime::Infinite; use Storable; my $future = DateTime::Infinite::Future->new; Storable::freeze($future); === Item #1 returned by STORABLE_freeze for DateTime::Infinite::Future is not a reference at ../../lib/Storable.pm (autosplit into ../../lib/auto/Storable/_freeze.al) line 282, at foo line 5