The patch I accepted for Test::Differences which allows one to compare string/numeric values in hashrefs has a very, very nasty bug. This now passes:
use Test::More 'no_plan'; use Test::Differences; diag $Test::Differences::VERSION; eq_or_diff { foo => 1 }, { foo => 1 }, 'oops!'; eq_or_diff [ { foo => 1 } ], { foo => 1 }, 'oops!';
Sigh. Good thing this is a development version.
If anyone cares to take a gander at it, I'd be grateful. I'm back to work and may not get to this right away. I'm thinking about forcing it to use &Test::More::is_deeply for the actual test and only do the diff if that fails. That might change how some things look in test results, but should tremendously simplify the internals.
Sorry about the flawed patch.
When I saw it the other day, it didn't look familiar, and then I noticed that I submitted it about 4 years ago.
Re:sorry
Ovid on 2008-08-04T13:33:04
Heh. No worries. It's not obvious that it's flawed and frankly, if it weren't for a typo in my test suite, I never would have noticed. I'd be astonished if you recalled code from four years ago
:) Besides, I'm just damned grateful that there's a patch in the first place. And I don't see what's wrong, either (but IIRC, _flatten() is returning an aref without an embedded hashref for the AoH, but I'm not sure and don't have time to fix this today. As a result, we've downgraded.)
perl -MTest::More=tests,1 -MTest::Differences
-e'eq_or_diff [a => 1], [{a => 1}], "oops"'
1..1
ok 1 - oops
which is just as wrong. It happens because _flatten treats hashes as equivalent to arrays, and an array of one element as equivalent to a scalar.
Re:I don't think this is a new bug...
Ovid on 2008-08-04T15:50:47
Hmm, I'll try to look into this later, then. I must have screwed up somewhere and Mark Stosberg is off the hook
:)