perlquestion
Ovid
<p>There's a nasty bug in the latest development version of [dist://Test::Differences]. By applying a patch which allows this to pass (it currently won't):</p>
<code> eq_or_diff { foo => 1 }, { foo => '1' };</code>
<p>It also allows this to pass:</p>
<code> eq_or_diff [ { foo => 1 } ], { foo => '1' };</code>
<p>Ow, ow, ow. This is terrible. Fortunately, that's what development versions are for.</p>
<p>I'm thinking about rewriting Test::Differences to use &Test::More::is_deeply for the test and only diff if there are differences. Currently it uses Data::Dumper or its own internal flattening and and compares the string outputs.</p>
<p>There are two side-effects I can think of. First, the string/numeric value comparison will work correctly. Second, the 'Array of HashRef' diff output will change dramatically. There's an internal hack which assumes an AoH is a table (likely pulled from DBI, I assume), and this:</p>
<code> eq_or_diff [ { name => 'Bob', id => 1 } ],
[ { name => 'Bob', id => 2 } ], 'aoh';</code>
<p>Generates this:</p>
<code> # Failed test 'aoh'
# at eq_or_diff.t line 13.
# +----+---------+----------+
# | Elt|Got |Expected |
# +----+---------+----------+
# | 0|id,name |id,name |
# * 1|1,Bob |2,Bob *
# +----+---------+----------+</code>
<p>I find this much harder to read, but others may appreciate the hash keys being pulled out as headers.</p>
<p>Does anyone object to me breaking this? Are there any problems that I haven't thought of? (There usually are).</p>
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-17000">
<p>Cheers,<br />
<a href="/index.pl?node=Ovid&lastnode_id=1072">Ovid</a></p>
<p><small><a href="http://www.perlfoundation.org/perl6">The official Perl 6 wiki</a>.</small></p>
</div></div>