2 use warnings FATAL => 'all';
8 use t::common qw( new_dbm );
10 use_ok( 'DBM::Deep' );
12 # This is bug #34819, reported by EJS
14 my $dbm_factory = new_dbm();
15 while ( my $dbm_maker = $dbm_factory->() ) {
16 my $db = $dbm_maker->();
18 my $bar = bless { foo => 'ope' }, 'Foo';
23 }; if ( $@ ) { warn $@ }
25 ok(!$@, "repeated object assignment");
26 isa_ok($db->{bar}, 'Foo');
31 # This is bug #29957, reported by HANENKAMP
33 my $dbm_factory = new_dbm();
34 while ( my $dbm_maker = $dbm_factory->() ) {
35 my $db = $dbm_maker->();
39 for my $value ( 1 .. 3 ) {
44 } "Successfully added value $value";
47 cmp_deeply( [1,2,3], noclass($db->{foo}), "Everything looks ok" );
51 # This is bug #33863, reported by PJS
53 my $dbm_factory = new_dbm();
54 while ( my $dbm_maker = $dbm_factory->() ) {
55 my $db = $dbm_maker->();
58 my $foo = shift @{ $db->{foo} };
59 cmp_ok( @{ $db->{foo} }, '==', 0, "Shifting a scalar leaves no values" );
60 cmp_ok( $foo, '==', 42, "... And the value is correct." );
63 my $bar = shift @{ $db->{bar} };
64 cmp_ok( @{ $db->{bar} }, '==', 0, "Shifting an arrayref leaves no values" );
66 $db->{baz} = { foo => [ 1 .. 3 ] };
67 $db->{baz2} = [ $db->{baz} ];
68 my $baz2 = shift @{ $db->{baz2} };
69 cmp_ok( @{ $db->{baz2} }, '==', 0, "Shifting an arrayref leaves no values" );
70 ok( exists $db->{baz}{foo} );
71 ok( exists $baz2->{foo} );