File: 53_misc_transactions.t

package info (click to toggle)
libdbm-deep-perl 2.0008-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 884 kB
  • sloc: perl: 7,383; sql: 36
file content (37 lines) | stat: -rw-r--r-- 833 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# This was discussed here:
# http://groups.google.com/group/DBM-Deep/browse_thread/thread/a6b8224ffec21bab
# brought up by Alex Gallichotte

use strict;
use warnings FATAL => 'all';

use Test::More;
use t::common qw( new_dbm );

use_ok( 'DBM::Deep' );

my $dbm_factory = new_dbm();
while ( my $dbm_maker = $dbm_factory->() ) {
    my $db = $dbm_maker->();
    eval { $db->{randkey()} = randkey() for 1 .. 10; }; ok(!$@, "No eval failures");

    eval {
        #$db->begin_work;
        $db->{randkey()} = randkey() for 1 .. 10;
        #$db->commit;
    };
    ok(!$@, "No eval failures from the transaction");

    eval { $db->{randkey()} = randkey() for 1 .. 10; };
    ok(!$@, "No eval failures");
}

done_testing;

sub randkey {
    our $i++;
    my @k = map { int rand 100 } 1 .. 10;
    local $" = "-";

    return "$i-@k";
}