bdf827a89f0f9a9d206ad8f4c76c55a0af3d6481
[dbsrgits/DBM-Deep.git] / t / 48_autoexport_after_delete.t
1 use strict;
2 use warnings FATAL => 'all';
3
4 use Test::More;
5 use Test::Deep;
6
7 use t::common qw( new_dbm );
8
9 use_ok( 'DBM::Deep' );
10
11 my $dbm_factory = new_dbm();
12 while ( my $dbm_maker = $dbm_factory->() ) {
13     my $db = $dbm_maker->();
14
15     # Add a self-referencing connection to test export
16     my %struct = (
17         key1 => "value1",
18         key2 => "value2",
19         array1 => [ "elem0", "elem1", "elem2", { foo => 'bar' }, [ 5 ], bless( [], 'Apple' ) ],
20         hash1 => {
21             subkey1 => "subvalue1",
22             subkey2 => "subvalue2",
23             subkey3 => bless( {
24                 sub_obj => bless([
25                     bless([], 'Foo'),
26                 ], 'Foo'),
27                 sub_obj3 => bless([],'Foo'),
28             }, 'Foo' ),
29         },
30     );
31
32     $db->{foo} = \%struct;
33
34     my $x = delete $db->{foo};
35
36     cmp_deeply(
37         $x,
38         {
39             key1 => "value1",
40             key2 => "value2",
41             array1 => [ "elem0", "elem1", "elem2", { foo => 'bar' }, [ 5 ], bless( [], 'Apple' ) ],
42             hash1 => {
43                 subkey1 => "subvalue1",
44                 subkey2 => "subvalue2",
45                 subkey3 => bless( {
46                     sub_obj => bless([
47                         bless([], 'Foo'),
48                     ], 'Foo'),
49                     sub_obj3 => bless([],'Foo'),
50                 }, 'Foo' ),
51             },
52         },
53         "Everything matches",
54     );
55 }
56
57 done_testing;