Commit | Line | Data |
2120a181 |
1 | use strict; |
0e3e3555 |
2 | use warnings FATAL => 'all'; |
3 | |
4 | use Test::More; |
2120a181 |
5 | use Test::Deep; |
0e3e3555 |
6 | use t::common qw( new_dbm ); |
2120a181 |
7 | |
8 | use_ok( 'DBM::Deep' ); |
9 | |
0e3e3555 |
10 | my $dbm_factory = new_dbm( |
11 | locking => 1, |
2120a181 |
12 | autoflush => 1, |
13 | ); |
0e3e3555 |
14 | while ( my $dbm_maker = $dbm_factory->() ) { |
15 | my $db = $dbm_maker->(); |
2120a181 |
16 | |
0e3e3555 |
17 | for ( 1 .. 17 ) { |
18 | $db->{ $_ } = $_; |
19 | is( $db->{$_}, $_, "Addition of $_ is still $_" ); |
20 | } |
2120a181 |
21 | |
0e3e3555 |
22 | for ( 1 .. 17 ) { |
23 | is( $db->{$_}, $_, "Verification of $_ is still $_" ); |
24 | } |
2120a181 |
25 | |
0e3e3555 |
26 | my @keys = keys %$db; |
27 | cmp_ok( scalar(@keys), '==', 17, "Right number of keys returned" ); |
2120a181 |
28 | |
0e3e3555 |
29 | ok( !exists $db->{does_not_exist}, "EXISTS works on large hashes for non-existent keys" ); |
30 | is( $db->{does_not_exist}, undef, "autovivification works on large hashes" ); |
31 | ok( exists $db->{does_not_exist}, "EXISTS works on large hashes for newly-existent keys" ); |
32 | cmp_ok( scalar(keys %$db), '==', 18, "Number of keys after autovivify is correct" ); |
33 | } |
2120a181 |
34 | |
0e3e3555 |
35 | done_testing; |