diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2000-10-03 11:20:37 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2000-10-03 11:20:37 +0000 |
commit | dd19458bcc107ff5b00bdc811d918a2e32b367ed (patch) | |
tree | 9e175c61a2e7d01cf1083531ac2735178ae59c02 /t/lib | |
parent | 9e1f4cb514bd574e44a4fee14f93bc860a4baa5b (diff) | |
download | perl-dd19458bcc107ff5b00bdc811d918a2e32b367ed.tar.gz |
Upgrade to Storable 1.0.3, from Raphael Manfredi.
p4raw-id: //depot/perl@7132
Diffstat (limited to 't/lib')
-rw-r--r-- | t/lib/st-lock.t | 46 | ||||
-rw-r--r-- | t/lib/st-recurse.t | 56 | ||||
-rw-r--r-- | t/lib/st-utf8.t | 40 |
3 files changed, 140 insertions, 2 deletions
diff --git a/t/lib/st-lock.t b/t/lib/st-lock.t new file mode 100644 index 0000000000..0bb4a33af5 --- /dev/null +++ b/t/lib/st-lock.t @@ -0,0 +1,46 @@ +#!./perl + +# $Id: lock.t,v 1.0.1.1 2000/09/28 21:44:06 ram Exp $ +# +# @COPYRIGHT@ +# +# $Log: lock.t,v $ +# Revision 1.0.1.1 2000/09/28 21:44:06 ram +# patch2: created. +# +# + +sub BEGIN { + chdir('t') if -d 't'; + @INC = '.'; + push @INC, '../lib'; + require Config; import Config; + if ($Config{'extensions'} !~ /\bStorable\b/) { + print "1..0 # Skip: Storable was not built\n"; + exit 0; + } + require 'lib/st-dump.pl'; +} + +sub ok; + +use Storable qw(lock_store lock_retrieve); + +print "1..5\n"; + +@a = ('first', undef, 3, -4, -3.14159, 456, 4.5); + +# +# We're just ensuring things work, we're not validating locking. +# + +ok 1, defined lock_store(\@a, 'store'); +ok 2, $dumped = &dump(\@a); + +$root = lock_retrieve('store'); +ok 3, ref $root eq 'ARRAY'; +ok 4, @a == @$root; +ok 5, &dump($root) eq $dumped; + +unlink 't/store'; + diff --git a/t/lib/st-recurse.t b/t/lib/st-recurse.t index 5bd8e24244..dcf6d1a029 100644 --- a/t/lib/st-recurse.t +++ b/t/lib/st-recurse.t @@ -1,6 +1,6 @@ #!./perl -# $Id: recurse.t,v 1.0 2000/09/01 19:40:42 ram Exp $ +# $Id: recurse.t,v 1.0.1.1 2000/09/17 16:48:05 ram Exp $ # # Copyright (c) 1995-2000, Raphael Manfredi # @@ -8,6 +8,10 @@ # in the README file that comes with the distribution. # # $Log: recurse.t,v $ +# Revision 1.0.1.1 2000/09/17 16:48:05 ram +# patch1: added test case for store hook bug +# +# $Log: recurse.t,v $ # Revision 1.0 2000/09/01 19:40:42 ram # Baseline for first official release. # @@ -28,7 +32,7 @@ sub ok; use Storable qw(freeze thaw dclone); -print "1..23\n"; +print "1..28\n"; package OBJ_REAL; @@ -181,3 +185,51 @@ ok 21, $OBJ_REAL2::hook_called == 2 * $OBJ_REAL2::MAX; ok 22, !Storable::is_storing; ok 23, !Storable::is_retrieving; + +# +# The following was a test-case that Salvador Ortiz Garcia <sog@msg.com.mx> +# sent me, along with a proposed fix. +# + +package Foo; + +sub new { + my $class = shift; + my $dat = shift; + return bless {dat => $dat}, $class; +} + +package Bar; +sub new { + my $class = shift; + return bless { + a => 'dummy', + b => [ + Foo->new(1), + Foo->new(2), # Second instance of a Foo + ] + }, $class; +} + +sub STORABLE_freeze { + my($self,$clonning) = @_; + return "$self->{a}", $self->{b}; +} + +sub STORABLE_thaw { + my($self,$clonning,$dummy,$o) = @_; + $self->{a} = $dummy; + $self->{b} = $o; +} + +package main; + +my $bar = new Bar; +my $bar2 = thaw freeze $bar; + +ok 24, ref($bar2) eq 'Bar'; +ok 25, ref($bar->{b}[0]) eq 'Foo'; +ok 26, ref($bar->{b}[1]) eq 'Foo'; +ok 27, ref($bar2->{b}[0]) eq 'Foo'; +ok 28, ref($bar2->{b}[1]) eq 'Foo'; + diff --git a/t/lib/st-utf8.t b/t/lib/st-utf8.t new file mode 100644 index 0000000000..2160308a28 --- /dev/null +++ b/t/lib/st-utf8.t @@ -0,0 +1,40 @@ +#!./perl + +# $Id: utf8.t,v 1.0.1.2 2000/09/28 21:44:17 ram Exp $ +# +# @COPYRIGHT@ +# +# $Log: utf8.t,v $ +# Revision 1.0.1.2 2000/09/28 21:44:17 ram +# patch2: fixed stupid typo +# +# Revision 1.0.1.1 2000/09/17 16:48:12 ram +# patch1: created. +# +# + +sub BEGIN { + if ($] < 5.006) { + print "1..0 # Skip: no utf8 support\n"; + exit 0; + } + chdir('t') if -d 't'; + @INC = '.'; + push @INC, '../lib'; + require Config; import Config; + if ($Config{'extensions'} !~ /\bStorable\b/) { + print "1..0 # Skip: Storable was not built\n"; + exit 0; + } + require 'lib/st-dump.pl'; +} + +sub ok; + +use Storable qw(thaw freeze); + +print "1..1\n"; + +$x = chr(1234); +ok 1, $x eq ${thaw freeze \$x}; + |