3 # $Id: dclone.t,v 0.7 2000/08/03 22:04:44 ram Exp $
5 # Copyright (c) 1995-2000, Raphael Manfredi
7 # You may redistribute only under the terms of the Artistic License,
8 # as specified in the README file that comes with the distribution.
11 # Revision 0.7 2000/08/03 22:04:44 ram
12 # Baseline for second beta release.
17 require Config; import Config;
18 if ($Config{'extensions'} !~ /\bStorable\b/) {
19 print "1..0 # Skip: Storable was not built\n";
22 unshift @INC, '../lib';
23 require 'lib/st-dump.pl';
27 use Storable qw(dclone);
34 $c->{attribute} = 'attrval';
35 %a = ('key', 'value', 1, 0, $a, $b, 'cvar', \$c);
36 @a = ('first', undef, 3, -4, -3.14159, 456, 4.5,
37 $b, \$a, $a, $c, \$c, \%a);
39 print "not " unless defined ($aref = dclone(\@a));
48 print "not " unless $got eq $dumped;
51 package FOO; @ISA = qw(Storable);
55 $self->{key} = \%main::a;
62 print "not " unless defined($r = $foo->dclone);
65 print "not " unless &dump($foo) eq &dump($r);
68 # Ensure refs to "undef" values are properly shared during cloning
70 push @{$$hash{''}}, \$$hash{a};
71 print "not " unless $$hash{''}[0] == \$$hash{a};
74 my $cloned = dclone(dclone($hash));
75 print "not " unless $$cloned{''}[0] == \$$cloned{a};
79 print "not " unless $$cloned{''}[0] == \$$cloned{a};