Ovid has asked for the wisdom of the Perl Monks concerning the following question:
There's a nasty bug in the latest development version of Test::Differences. By applying a patch which allows this to pass (it currently won't):
eq_or_diff { foo => 1 }, { foo => '1' };It also allows this to pass:
eq_or_diff [ { foo => 1 } ], { foo => '1' };Ow, ow, ow. This is terrible. Fortunately, that's what development versions are for.
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.
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:
eq_or_diff [ { name => 'Bob', id => 1 } ], [ { name => 'Bob', id => 2 } ], 'aoh';
Generates this:
# Failed test 'aoh' # at eq_or_diff.t line 13. # +----+---------+----------+ # | Elt|Got |Expected | # +----+---------+----------+ # | 0|id,name |id,name | # * 1|1,Bob |2,Bob * # +----+---------+----------+
I find this much harder to read, but others may appreciate the hash keys being pulled out as headers.
Does anyone object to me breaking this? Are there any problems that I haven't thought of? (There usually are).
Cheers,
Ovid
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Breaking Test::Differences
by amarquis (Curate) on Aug 04, 2008 at 13:26 UTC | |
by maspalio (Scribe) on Aug 05, 2008 at 09:14 UTC | |
Re: Breaking Test::Differences
by Anonymous Monk on Aug 04, 2008 at 08:49 UTC | |
by Ovid (Cardinal) on Aug 04, 2008 at 09:18 UTC | |
by Anonymous Monk on Aug 04, 2008 at 09:48 UTC | |
by Ovid (Cardinal) on Aug 04, 2008 at 09:59 UTC | |
by Gavin (Archbishop) on Aug 04, 2008 at 10:45 UTC | |
by Anonymous Monk on Aug 04, 2008 at 10:01 UTC | |
by Ovid (Cardinal) on Aug 04, 2008 at 10:08 UTC | |
by Anonymous Monk on Aug 04, 2008 at 14:33 UTC | |
by Anonymous Monk on Mar 23, 2010 at 09:22 UTC |