Commit | Line | Data |
ac0615b2 |
1 | use strict; |
2 | |
3 | { |
4 | package Foo; |
5 | |
6 | sub export { 'export' }; |
7 | sub foo { 'foo' }; |
8 | } |
9 | |
10 | use Test::More no_plan => 1; |
11 | |
12 | use_ok( 'DBM::Deep' ); |
13 | |
14 | unlink 't/test.db'; |
15 | my $db = DBM::Deep->new( |
16 | file => "t/test.db", |
b8b48a59 |
17 | autobless => 0, |
ac0615b2 |
18 | ); |
19 | if ($db->error()) { |
20 | die "ERROR: " . $db->error(); |
21 | } |
22 | |
ac0615b2 |
23 | $db->{unblessed} = {}; |
24 | $db->{unblessed}{a} = 1; |
25 | $db->{unblessed}{b} = []; |
26 | $db->{unblessed}{b}[0] = 1; |
27 | $db->{unblessed}{b}[1] = 2; |
28 | $db->{unblessed}{b}[2] = 3; |
29 | |
30 | undef $db; |
31 | |
32 | my $db2 = DBM::Deep->new( |
33 | file => 't/test.db', |
ac0615b2 |
34 | autobless => 1, |
35 | ); |
36 | if ($db2->error()) { |
37 | die "ERROR: " . $db2->error(); |
38 | } |
39 | |
ac0615b2 |
40 | is( $db2->{unblessed}{a}, 1 ); |
41 | is( $db2->{unblessed}{b}[0], 1 ); |
42 | is( $db2->{unblessed}{b}[1], 2 ); |
43 | is( $db2->{unblessed}{b}[2], 3 ); |
44 | |
b8b48a59 |
45 | $db2->{unblessed}{a} = 2; |
46 | |
47 | undef $db2; |
48 | |
ac0615b2 |
49 | my $db3 = DBM::Deep->new( |
b8b48a59 |
50 | file => "t/test.db", |
51 | autobless => 0, |
ac0615b2 |
52 | ); |
53 | if ($db3->error()) { |
b8b48a59 |
54 | die "ERROR: " . $db->error(); |
ac0615b2 |
55 | } |
56 | |
b8b48a59 |
57 | is( $db3->{unblessed}{a}, 2 ); |
ac0615b2 |
58 | is( $db3->{unblessed}{b}[0], 1 ); |
59 | is( $db3->{unblessed}{b}[1], 2 ); |
60 | is( $db3->{unblessed}{b}[2], 3 ); |