3 # $Id: dclone.t,v 1.0 2000/09/01 19:40:41 ram Exp $
5 # Copyright (c) 1995-2000, Raphael Manfredi
7 # You may redistribute only under the same terms as Perl 5, as specified
8 # in the README file that comes with the distribution.
11 # Revision 1.0 2000/09/01 19:40:41 ram
12 # Baseline for first official release.
19 require Config; import Config;
20 if ($Config{'extensions'} !~ /\bStorable\b/) {
21 print "1..0 # Skip: Storable was not built\n";
24 require 'lib/st-dump.pl';
28 use Storable qw(dclone);
35 $c->{attribute} = 'attrval';
36 %a = ('key', 'value', 1, 0, $a, $b, 'cvar', \$c);
37 @a = ('first', undef, 3, -4, -3.14159, 456, 4.5,
38 $b, \$a, $a, $c, \$c, \%a);
40 print "not " unless defined ($aref = dclone(\@a));
49 print "not " unless $got eq $dumped;
52 package FOO; @ISA = qw(Storable);
56 $self->{key} = \%main::a;
63 print "not " unless defined($r = $foo->dclone);
66 print "not " unless &dump($foo) eq &dump($r);
69 # Ensure refs to "undef" values are properly shared during cloning
71 push @{$$hash{''}}, \$$hash{a};
72 print "not " unless $$hash{''}[0] == \$$hash{a};
75 my $cloned = dclone(dclone($hash));
76 print "not " unless $$cloned{''}[0] == \$$cloned{a};
80 print "not " unless $$cloned{''}[0] == \$$cloned{a};