2 use Test::More tests => 51;
4 use t::common qw( new_fh );
8 my ($fh, $filename) = new_fh();
9 my $db1 = DBM::Deep->new(
16 my $db2 = DBM::Deep->new(
23 my $db3 = DBM::Deep->new(
31 is( $db1->{foo}, 'bar', "Before transaction, DB1's foo is bar" );
32 is( $db2->{foo}, 'bar', "Before transaction, DB2's foo is bar" );
33 is( $db3->{foo}, 'bar', "Before transaction, DB3's foo is bar" );
37 is( $db1->{foo}, 'bar', "Before transaction work, DB1's foo is bar" );
38 is( $db2->{foo}, 'bar', "Before transaction work, DB2's foo is bar" );
39 is( $db3->{foo}, 'bar', "Before transaction work, DB3's foo is bar" );
43 is( $db1->{foo}, 'bar2', "After DB1 foo to bar2, DB1's foo is bar2" );
44 is( $db2->{foo}, 'bar', "After DB1 foo to bar2, DB2's foo is bar" );
45 is( $db3->{foo}, 'bar', "After DB1 foo to bar2, DB3's foo is bar" );
49 ok( exists $db1->{bar}, "After DB1 set bar to foo, DB1's bar exists" );
50 ok( !exists $db2->{bar}, "After DB1 set bar to foo, DB2's bar doesn't exist" );
51 ok( !exists $db3->{bar}, "After DB1 set bar to foo, DB3's bar doesn't exist" );
55 is( $db1->{foo}, 'bar2', "After DB2 transaction begin, DB1's foo is still bar2" );
56 is( $db2->{foo}, 'bar', "After DB2 transaction begin, DB2's foo is still bar" );
57 is( $db3->{foo}, 'bar', "After DB2 transaction begin, DB3's foo is still bar" );
59 ok( exists $db1->{bar}, "After DB2 transaction begin, DB1's bar exists" );
60 ok( !exists $db2->{bar}, "After DB2 transaction begin, DB2's bar doesn't exist" );
61 ok( !exists $db3->{bar}, "After DB2 transaction begin, DB3's bar doesn't exist" );
63 $db2->{foo} = 'bar333';
65 is( $db1->{foo}, 'bar2', "After DB2 foo to bar2, DB1's foo is bar2" );
66 is( $db2->{foo}, 'bar333', "After DB2 foo to bar2, DB2's foo is bar333" );
67 is( $db3->{foo}, 'bar', "After DB2 foo to bar2, DB3's foo is bar" );
69 $db2->{bar} = 'mybar';
71 ok( exists $db1->{bar}, "After DB2 set bar to mybar, DB1's bar exists" );
72 ok( exists $db2->{bar}, "After DB2 set bar to mybar, DB2's bar exists" );
73 ok( !exists $db3->{bar}, "After DB2 set bar to mybar, DB3's bar doesn't exist" );
75 is( $db1->{bar}, 'foo', "DB1's bar is still foo" );
76 is( $db2->{bar}, 'mybar', "DB2's bar is now mybar" );
78 $db2->{mykey} = 'myval';
80 ok( !exists $db1->{mykey}, "After DB2 set mykey to myval, DB1's mykey doesn't exist" );
81 ok( exists $db2->{mykey}, "After DB2 set mykey to myval, DB2's mykey exists" );
82 ok( !exists $db3->{mykey}, "After DB2 set mykey to myval, DB3's mykey doesn't exist" );
84 cmp_bag( [ keys %$db1 ], [qw( foo bar )], "DB1 keys correct" );
85 cmp_bag( [ keys %$db2 ], [qw( foo bar mykey )], "DB2 keys correct" );
86 cmp_bag( [ keys %$db3 ], [qw( foo )], "DB3 keys correct" );
90 is( $db1->{foo}, 'bar2', "After DB1 commit, DB1's foo is bar2" );
91 is( $db2->{foo}, 'bar333', "After DB1 commit, DB2's foo is bar333" );
92 is( $db3->{foo}, 'bar2', "After DB1 commit, DB3's foo is bar2" );
94 is( $db1->{bar}, 'foo', "DB1's bar is still foo" );
95 is( $db2->{bar}, 'mybar', "DB2's bar is still mybar" );
96 is( $db3->{bar}, 'foo', "DB3's bar is now foo" );
98 cmp_bag( [ keys %$db1 ], [qw( foo bar )], "DB1 keys correct" );
99 cmp_bag( [ keys %$db2 ], [qw( foo bar mykey )], "DB2 keys correct" );
100 cmp_bag( [ keys %$db3 ], [qw( foo bar )], "DB3 keys correct" );
104 is( $db1->{foo}, 'bar333', "After DB2 commit, DB1's foo is bar333" );
105 is( $db2->{foo}, 'bar333', "After DB2 commit, DB2's foo is bar333" );
106 is( $db3->{foo}, 'bar333', "After DB2 commit, DB3's foo is bar333" );
108 is( $db1->{bar}, 'mybar', "DB1's bar is now mybar" );
109 is( $db2->{bar}, 'mybar', "DB2's bar is still mybar" );
110 is( $db3->{bar}, 'mybar', "DB3's bar is now mybar" );
112 cmp_bag( [ keys %$db1 ], [qw( foo bar mykey )], "DB1 keys correct" );
113 cmp_bag( [ keys %$db2 ], [qw( foo bar mykey )], "DB2 keys correct" );
114 cmp_bag( [ keys %$db3 ], [qw( foo bar mykey )], "DB3 keys correct" );