diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2014-12-10 13:34:52 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2014-12-10 13:34:52 +0000 |
commit | 8fddd4400d09891094843fe9e77fec74e4510c67 (patch) | |
tree | 23dbb27d11e56cf6586d93b091c708fa111a7a2d /t/deep-recursion.t | |
download | Data-Compare-tarball-master.tar.gz |
Data-Compare-1.25HEADData-Compare-1.25master
Diffstat (limited to 't/deep-recursion.t')
-rw-r--r-- | t/deep-recursion.t | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/t/deep-recursion.t b/t/deep-recursion.t new file mode 100644 index 0000000..9861c0a --- /dev/null +++ b/t/deep-recursion.t @@ -0,0 +1,34 @@ +#!/usr/bin/perl -w + +use strict; +use warnings; +# use diagnostics; + +use Data::Compare; +use Test::More tests => 3; + +my $warning= ''; +$SIG{__WARN__} = sub { $warning= shift; }; + +my($data1, $data2) = ({}, {}); +foreach my $i (qw(a b c d e f g h i j)) { + foreach my $j (qw(k l m n o p q r s t)) { + $data1->{$i}->{$j} = 'i like pie'; + $data2->{$i}->{$j} = 'i like pie'; + } +} + +# check that we DTRT on very deep recursion +$a = [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[0]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]; +$b = [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[0]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]; +Compare($a, $b); +ok($warning, "warn on deep recursion"); +$warning = ''; + +Compare([5], [5]) foreach(1..1000); +ok(!$warning, "recursion counter correctly reset"); + + +Compare($data1, $data2); + +ok(!$warning, "no warnings emitted on large flat structures"); |