r11685@rob-kinyons-powerbook58: rob | 2006-04-29 10:50:27 -0400
rkinyon [Mon, 1 May 2006 02:22:53 +0000 (02:22 +0000)]
 Have tests for a couple bugs

MANIFEST
lib/DBM/Deep.pm
t/17_import.t
t/36_transaction_deep.t [new file with mode: 0644]

index 1f879f2..3706a52 100644 (file)
--- 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
index 373fd84..005d06a 100644 (file)
@@ -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);
index 22a2694..6a91e2d 100644 (file)
@@ -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 (file)
index 0000000..eadc6d3
--- /dev/null
@@ -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" );