A few more fixes, bringing stmt to 94.9% and overall to 88.5%
[dbsrgits/DBM-Deep.git] / t / autobless_2.t
CommitLineData
ac0615b2 1use strict;
2
3{
4 package Foo;
5
6 sub export { 'export' };
7 sub foo { 'foo' };
8}
9
10use Test::More no_plan => 1;
11
12use_ok( 'DBM::Deep' );
13
14unlink 't/test.db';
15my $db = DBM::Deep->new(
16 file => "t/test.db",
b8b48a59 17 autobless => 0,
ac0615b2 18);
19if ($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
30undef $db;
31
32my $db2 = DBM::Deep->new(
33 file => 't/test.db',
ac0615b2 34 autobless => 1,
35);
36if ($db2->error()) {
37 die "ERROR: " . $db2->error();
38}
39
ac0615b2 40is( $db2->{unblessed}{a}, 1 );
41is( $db2->{unblessed}{b}[0], 1 );
42is( $db2->{unblessed}{b}[1], 2 );
43is( $db2->{unblessed}{b}[2], 3 );
44
b8b48a59 45$db2->{unblessed}{a} = 2;
46
47undef $db2;
48
ac0615b2 49my $db3 = DBM::Deep->new(
b8b48a59 50 file => "t/test.db",
51 autobless => 0,
ac0615b2 52);
53if ($db3->error()) {
b8b48a59 54 die "ERROR: " . $db->error();
ac0615b2 55}
56
b8b48a59 57is( $db3->{unblessed}{a}, 2 );
ac0615b2 58is( $db3->{unblessed}{b}[0], 1 );
59is( $db3->{unblessed}{b}[1], 2 );
60is( $db3->{unblessed}{b}[2], 3 );