Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Greetings

From time to time I use Test::LectroTest for specifications based testing, which allows me to do neat things like:

Property { ##[ x <- Int #]## square( $x ) == $x * $x; }, name => "Finding \$x's square";

This will generate a thousand tests and rapidly uncovers tricky edge cases. Take a look at the author's tutorial for a more detailed presentation of this technique.

Lately I have been thinking about comparing more complex data structures than what is shown in the basic documentation. As many of my functions return data structures, being able to compare these results with Test::Differences' eq_or_diff, or something from Test::Deep would have been nice. Something like:

use Test::Differences; Property { ##[ x <- Int, y <- Int #]## my @expected = map { $x * $_ } 0 .. $y; # Or something ... my @result = getDataAsArray( $x, $y ); eq_or_diff( \@result, \@expected ); }, name => "Transmogrifer parameters ok";

I only fiddled a little bit around with this (without success), and some googling didn't find much. I wonder if anyone knows if this is possible, or even useful?

Have a nice day :)

Edit: Changed title, the old one sounded like a howto.

pernod
--
Mischief. Mayhem. Soap.


In reply to Can I use Test::Differences with Test::LectroTest? by pernod

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?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-25 13:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found