Hi,

Yitzchak pointed me to this thread. I thought I'd add that
Data::Dump::Streamer v1.14 has the capability to Dump closures
properly, that is including bound lexical state. (Albeit with a few
minor caveats, its possible to deliberately construct pathological
closures that wont be eval'able, however they will still suffice for
comparison purposes.

If you want to do extremely high detail tests on your data sets I
recommend you use DDS. To the best of my knowledge there is nothing
else that is accurate as it is.

And actually on my first sneaky test of is_deeply it got it wrong.  I
actually raised this exact example about is_deeply some years ago.
sigh. At least the latest version of Test::More doesnt go into
catatonic shock with this test like the one that ships with 5.8.6
does.

cheers,
Yves

use Test::More tests=>2;
use Data::Dump::Streamer;

my ($x,$y);
my $ar=[];
$ar->[0]=\$ar->[1];
$ar->[1]=\$ar->[0];
$x=\$y;
$y=\$x;
my $wrap=[$x,$y];


is_deeply($wrap, $ar, "Scalar Cross");
is(scalar Dump($wrap)->Out,scalar Dump($ar)->Out,'Scalar Cross using DDS');
__END__
1..2
ok 1 - Scalar Cross
not ok 2 - Scalar Cross using DDS
#     Failed test (d:\dev\Stuff\is_deeply.pl at line 14)
#          got: '$ARRAY1 = [
#             \do { my $v = 'V: $ARRAY1->[1]' },
#             \do { my $v = 'V: $ARRAY1->[0]' }
#           ];
# ${$ARRAY1->[0]} = $ARRAY1->[1];
# ${$ARRAY1->[1]} = $ARRAY1->[0];
# '
#     expected: '$ARRAY1 = [
#             'R: $ARRAY1->[1]',
#             'R: $ARRAY1->[0]'
#           ];
# $ARRAY1->[0] = \$ARRAY1->[1];
# $ARRAY1->[1] = \$ARRAY1->[0];
# '
# Looks like you failed 1 test of 2.

-- 
perl -Mre=debug -e "/just|another|perl|hacker/"

Reply via email to