From: Vincent Pit Date: Tue, 28 Dec 2010 23:49:27 +0000 (+0100) Subject: Test is_deeply against deep datastructures X-Git-Tag: v0.02~5 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=bf415eb37f8b169a2c077a54f089d361787a86dc;p=perl%2Fmodules%2FTest-Leaner.git Test is_deeply against deep datastructures --- diff --git a/MANIFEST b/MANIFEST index 539d7a6..734c6e9 100644 --- a/MANIFEST +++ b/MANIFEST @@ -27,6 +27,7 @@ t/22-is.t t/24-cmp_ok.t t/26-is_deeply.t t/27-is_deeply-failing.t +t/28-is_deeply-deep.t t/91-pod.t t/92-pod-coverage.t t/95-portability-files.t diff --git a/t/28-is_deeply-deep.t b/t/28-is_deeply-deep.t new file mode 100644 index 0000000..2beae50 --- /dev/null +++ b/t/28-is_deeply-deep.t @@ -0,0 +1,46 @@ +#!perl -T + +use strict; +use warnings; + +use Test::Leaner tests => 2; + +sub create_chain { + my ($l, $n) = @_; + + $n = 1 unless defined $n; + $l = 45 unless defined $l; + + return \(\$n) if $l <= 0; + + [ + [ 0, \(\$n) ], + 1, + { a => create_chain($l - 1, $n + 1) }, + ] +} + +my $c1 = create_chain; +my $c2 = create_chain; + +is_deeply $c1, $c2, 'a deep chain structure'; + +sub create_tree { + my ($l, $n) = @_; + + $n = 1 unless defined $n; + $l = 10 unless defined $l; + + return \(\$n) if $l <= 0; + + [ + { a => create_tree($l - 1, 2 * $n) }, + 1, + { b => create_tree($l - 1, 2 * $n + 1) }, + ] +} + +my $t1 = create_tree; +my $t2 = create_tree; + +is_deeply $t1, $t2, 'a deep tree structure';