Commit | Line | Data |
ffed8b01 |
1 | use strict; |
0e3e3555 |
2 | use warnings FATAL => 'all'; |
3 | |
4 | use Test::More; |
2120a181 |
5 | use Test::Exception; |
0e3e3555 |
6 | use t::common qw( new_dbm ); |
ffed8b01 |
7 | |
bd773913 |
8 | use_ok( 'DBM::Deep' ); |
ffed8b01 |
9 | |
0e3e3555 |
10 | my $dbm_factory = new_dbm( locking => 1 ); |
11 | while ( my $dbm_maker = $dbm_factory->() ) { |
12 | my $db = $dbm_maker->(); |
13 | |
14 | lives_ok { |
15 | $db->unlock; |
16 | } "Can call unlock on an unlocked DB."; |
17 | |
18 | ## |
19 | # basic put/get |
20 | ## |
21 | $db->{key1} = "value1"; |
22 | is( $db->{key1}, "value1", "key1 is set" ); |
23 | |
24 | $db->{key2} = [ 1 .. 3 ]; |
25 | is( $db->{key2}[1], 2, "The value is set properly" ); |
26 | |
27 | ## |
28 | # explicit lock |
29 | ## |
30 | $db->lock_exclusive; |
31 | $db->{key1} = "value2"; |
32 | $db->unlock(); |
33 | is( $db->{key1}, "value2", "key1 is overridden" ); |
34 | } |
35 | |
36 | done_testing; |