Refactored to _descend to fix the recursion bug
[dbsrgits/DBM-Deep.git] / t / 53_misc_transactions.t
1 # This was discussed here:
2 # http://groups.google.com/group/DBM-Deep/browse_thread/thread/a6b8224ffec21bab
3 # brought up by Alex Gallichotte
4
5 use strict;
6 use warnings FATAL => 'all';
7
8 use Test::More;
9 use t::common qw( new_dbm );
10
11 use_ok( 'DBM::Deep' );
12
13 my $dbm_factory = new_dbm();
14 while ( my $dbm_maker = $dbm_factory->() ) {
15     my $db = $dbm_maker->();
16     eval { $db->{randkey()} = randkey() for 1 .. 10; }; ok(!$@, "No eval failures");
17
18     eval {
19         #$db->begin_work;
20         $db->{randkey()} = randkey() for 1 .. 10;
21         #$db->commit;
22     };
23     ok(!$@, "No eval failures from the transaction");
24
25     eval { $db->{randkey()} = randkey() for 1 .. 10; };
26     ok(!$@, "No eval failures");
27 }
28
29 done_testing;
30
31 sub randkey {
32     our $i++;
33     my @k = map { int rand 100 } 1 .. 10;
34     local $" = "-";
35
36     return "$i-@k";
37 }