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