4168a1942cea284be12fd4cc9b57044dacf2e2b5
[dbsrgits/DBM-Deep.git] / t / 12_clone.t
1 use strict;
2 use warnings FATAL => 'all';
3
4 use Test::More;
5 use t::common qw( new_dbm );
6
7 use_ok( 'DBM::Deep' );
8
9 my $dbm_factory = new_dbm();
10 while ( my $dbm_maker = $dbm_factory->() ) {
11
12     {
13         my $clone;
14
15         {
16             my $db = $dbm_maker->();
17
18             $db->{key1} = "value1";
19
20             ##
21             # clone db handle, make sure both are usable
22             ##
23             $clone = $db->clone();
24
25             is($clone->{key1}, "value1");
26
27             $clone->{key2} = "value2";
28             $db->{key3} = "value3";
29
30             is($db->{key1}, "value1");
31             is($db->{key2}, "value2");
32             is($db->{key3}, "value3");
33
34             is($clone->{key1}, "value1");
35             is($clone->{key2}, "value2");
36             is($clone->{key3}, "value3");
37         }
38
39         is($clone->{key1}, "value1");
40         is($clone->{key2}, "value2");
41         is($clone->{key3}, "value3");
42     }
43
44     {
45         my $db = $dbm_maker->();
46
47         is($db->{key1}, "value1");
48         is($db->{key2}, "value2");
49         is($db->{key3}, "value3");
50     }
51 }
52 done_testing;