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 -0000 1.2 +++ t/23storable.t 2 Aug 2004 07:46:02 -0000 @@ -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.pm 24 Jul 2003 04:24:16 -0000 1.8 +++ lib/DateTime/Infinite.pm 2 Aug 2004 07:23:17 -0000 @@ -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 =======================*/
