Added recursion test, hoisted staleness() to Sector.pm, and refactored to write_bucke...
[dbsrgits/DBM-Deep.git] / t / 55_recursion.t
diff --git a/t/55_recursion.t b/t/55_recursion.t
new file mode 100644 (file)
index 0000000..edec0d9
--- /dev/null
@@ -0,0 +1,25 @@
+use strict;
+use warnings FATAL => 'all';
+
+use Test::More;
+use Test::Exception;
+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->();
+
+    my $h = {};
+    my $tmp = $h;
+    for (1..4) { # 98 is ok, 99 is bad.
+        %$tmp = ("" => {});
+        $tmp = $tmp->{""};
+    }
+    lives_ok {
+        $db->{""} = $h;
+    } 'deep recursion causes no errors';
+}
+
+done_testing;