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

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Thanks for your feedback on LectroTest, and your example with Test::MockObject is a cool use. (BTW, I don't think that calculating the expected score in the Property is an abuse at all.)

If you don't mind a suggestion, you could simplify the data-building portion of your code by letting LectroTest build the more-complicated data structure for you:

#!/usr/bin/perl use strict; use Data::Dumper; use Test::LectroTest trials => 10; use List::Util qw( reduce ); $Data::Dumper::Terse = 1; Property { ##[ data <- List( Hash( Unit(1) , Int( range=>[50,100], sized=>0 ) , length=>1 ) , length=>5 ) ]## my @input = map { values %$_ } @$data; my $questions = reduce { $a + $b } @input; print STDERR Dumper( { data => $data , input => \@input , questions => $questions } ), "\n"; 1; # always passes trials }, name => "shell property that holds a generator example";
Also, for the Int generator, you shouldn't specify a range that does not contain zero if the generator is sized. The reason for this rule is that at run time, the intersection of the sizing-guidance range and your given range can be empty, thus making it impossible to generate a valid value. (I have updated the LectroTest::Generator docs to reflect this, and LectroTest will now complain if you try to combine these settings.)

Thanks again for taking the time to provide feedback!

Cheers,
Tom


In reply to Re: Test::LectroTest and Test::MockObject. by tmoertel
in thread RFC: Tutorial on Testing by tmoertel

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 chanting in the Monastery: (5)
As of 2024-04-19 11:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found