Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

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).


In reply to Breaking Test::Differences by Ovid

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2022-12-04 11:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?