5 use Test::More tests => 9;
7 use t::common qw( new_fh );
11 my ($fh2, $filename2) = new_fh();
12 my $db2 = DBM::Deep->new( $filename2 );
15 skip "Apparently, we cannot detect a tied scalar?", 1;
16 tie my $foo, 'Tied::Scalar';
18 $db2->{failure} = $foo;
19 } qr/Cannot store something that is tied\./, "tied scalar storage fails";
23 tie my @foo, 'Tied::Array';
25 $db2->{failure} = \@foo;
26 } qr/Cannot store something that is tied\./, "tied array storage fails";
30 tie my %foo, 'Tied::Hash';
32 $db2->{failure} = \%foo;
33 } qr/Cannot store something that is tied\./, "tied hash storage fails";
37 my ($fh, $filename) = new_fh();
38 my $db = DBM::Deep->new( $filename );
41 # Create structure in $db
45 subkey1 => "subvalue1",
46 subkey2 => "subvalue2",
49 is( $db->{hash1}{subkey1}, 'subvalue1', "Value imported correctly" );
50 is( $db->{hash1}{subkey2}, 'subvalue2', "Value imported correctly" );
52 # Test cross-ref nested hash accross DB objects
54 $db2->{copy} = $db->{hash1};
55 } qr/Cannot store values across DBM::Deep files\. Please use export\(\) instead\./, "cross-ref fails";
57 # This error text is for when internal cross-refs are implemented
58 #} qr/Cannot cross-reference\. Use export\(\) instead\./, "cross-ref fails";
60 $db2->{copy} = $db->{hash1}->export;
64 # Make sure $db2 has copy of $db's hash structure
66 is( $db2->{copy}{subkey1}, 'subvalue1', "Value copied correctly" );
67 is( $db2->{copy}{subkey2}, 'subvalue2', "Value copied correctly" );
70 sub TIESCALAR { bless {}, $_[0]; }
74 sub TIEARRAY { bless {}, $_[0]; }
77 sub TIEHASH { bless {}, $_[0]; }