From: rkinyon Date: Mon, 1 May 2006 02:22:53 +0000 (+0000) Subject: r11685@rob-kinyons-powerbook58: rob | 2006-04-29 10:50:27 -0400 X-Git-Tag: 0-99_03~53 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=415dcbb7932c4fe7593a86516a6f84ce42d20baa;p=dbsrgits%2FDBM-Deep.git r11685@rob-kinyons-powerbook58: rob | 2006-04-29 10:50:27 -0400 Have tests for a couple bugs --- diff --git a/MANIFEST b/MANIFEST index 1f879f2..3706a52 100644 --- a/MANIFEST +++ b/MANIFEST @@ -47,3 +47,4 @@ t/32_dash_ell.t t/33_transactions.t t/34_transaction_arrays.t t/35_transaction_multiple.t +t/36_transaction_deep.t diff --git a/lib/DBM/Deep.pm b/lib/DBM/Deep.pm index 373fd84..005d06a 100644 --- a/lib/DBM/Deep.pm +++ b/lib/DBM/Deep.pm @@ -405,7 +405,7 @@ sub _find_parent { while ( $parent->{parent} ) { $base = ( $parent->_type eq TYPE_HASH - ? "\{$child->{parent_key}\}" + ? "\{q{$child->{parent_key}}\}" : "\[$child->{parent_key}\]" ) . $base; @@ -413,10 +413,10 @@ sub _find_parent { $parent = $parent->{parent}; } if ( $base ) { - $base = "\$db->get( '$child->{parent_key}' )->" . $base; + $base = "\$db->get( q{$child->{parent_key}} )->" . $base; } else { - $base = "\$db->get( '$child->{parent_key}' )"; + $base = "\$db->get( q{$child->{parent_key}} )"; } } return $base; @@ -459,7 +459,7 @@ sub STORE { my $lhs = $self->_find_parent; if ( $lhs ) { if ( $self->_type eq TYPE_HASH ) { - $lhs .= "->\{$orig_key\}"; + $lhs .= "->\{q{$orig_key}\}"; } else { $lhs .= "->\[$orig_key\]"; @@ -468,7 +468,7 @@ sub STORE { $lhs .= "=$rhs;"; } else { - $lhs = "\$db->put('$orig_key',$rhs);"; + $lhs = "\$db->put(q{$orig_key},$rhs);"; } $self->_fileobj->audit($lhs); diff --git a/t/17_import.t b/t/17_import.t index 22a2694..6a91e2d 100644 --- a/t/17_import.t +++ b/t/17_import.t @@ -35,7 +35,7 @@ $db->import( $struct ); cmp_deeply( $db, - noclass({ + { key1 => 'value1', key2 => 'value2', array1 => [ 'elem0', 'elem1', 'elem2', ], @@ -44,6 +44,6 @@ cmp_deeply( subkey2 => "subvalue2", subkey3 => useclass( bless {}, 'Foo' ), }, - }), + }, "Everything matches", ); diff --git a/t/36_transaction_deep.t b/t/36_transaction_deep.t new file mode 100644 index 0000000..eadc6d3 --- /dev/null +++ b/t/36_transaction_deep.t @@ -0,0 +1,23 @@ +use strict; +use Test::More tests => 3; +use Test::Deep; +use t::common qw( new_fh ); + +use_ok( 'DBM::Deep' ); + +my ($fh, $filename) = new_fh(); +my $db1 = DBM::Deep->new( + file => $filename, + locking => 1, + autoflush => 1, +); + +$db1->begin_work; + + my $x = { a => 'b' };; + $db1->{x} = $x; + +$db1->commit; + +is( $db1->{x}{a}, 'b', "DB1 X-A is good" ); +is( $x->{a}, 'b', "X's A is good" );