Subject: | Test::Deep and array comparisons |
Date: | Mon, 04 Jul 2011 21:08:27 +0200 |
To: | rjbs [...] cpan.org |
From: | Heiko <heiko [...] hexco.de> |
Hello Ricardo,
I like your CPAN-Module Test::Deep and use it in my test scripts
effectively.
Thanks for your work!
I had the idea that cmp_deeply could be improved when comparing arrays.
After the length check of both arrays, a check for assigned slots could
be added
before the values finally are compared.
A demo to illustrate my point:
use Test::Deep;
my @a = (undef, 1);
my @b;
$b[1] = 1;
# @a has two assigned values
# @b has one assigned value
if (exists $a[0] != exists $b[0]) {
print "different assignment status for index 0\n";
}
cmp_deeply(\@a, \@b, "cmp_deeply sees them as equal");
What do you think about that?
best regards, Heiko (aka hexcoder)