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';
25 ok(!$@, "repeated object assignment");
26 isa_ok($db->{bar}, 'Foo');
30 # This is bug #29957, reported by HANENKAMP
32 my $dbm_factory = new_dbm();
33 while ( my $dbm_maker = $dbm_factory->() ) {
34 my $db = $dbm_maker->();
38 for my $value ( 1 .. 3 ) {
43 } "Successfully added value $value";
46 cmp_deeply( [1,2,3], noclass($db->{foo}), "Everything looks ok" );
50 # This is bug #33863, reported by PJS
52 my $dbm_factory = new_dbm();
53 while ( my $dbm_maker = $dbm_factory->() ) {
54 my $db = $dbm_maker->();
57 my $foo = shift @{ $db->{foo} };
58 cmp_ok( @{ $db->{foo} }, '==', 0, "Shifting a scalar leaves no values" );
59 cmp_ok( $foo, '==', 42, "... And the value is correct." );
62 my $bar = shift @{ $db->{bar} };
63 cmp_ok( @{ $db->{bar} }, '==', 0, "Shifting an arrayref leaves no values" );
65 $db->{baz} = { foo => [ 1 .. 3 ] };
66 $db->{baz2} = [ $db->{baz} ];
67 my $baz2 = shift @{ $db->{baz2} };
68 cmp_ok( @{ $db->{baz2} }, '==', 0, "Shifting an arrayref leaves no values" );
69 ok( exists $db->{baz}{foo} );
70 ok( exists $baz2->{foo} );