pernod has asked for the wisdom of the Perl Monks concerning the following question:
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.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Can I use Test::Differences with Test::LectroTest?
by fergal (Chaplain) on Feb 01, 2005 at 17:46 UTC | |
by pernod (Chaplain) on Feb 01, 2005 at 18:15 UTC | |
by fergal (Chaplain) on Feb 01, 2005 at 18:44 UTC | |
Try Test::LectroTest::Compat
by tmoertel (Chaplain) on Feb 08, 2005 at 05:22 UTC | |
by pernod (Chaplain) on Feb 17, 2005 at 18:11 UTC | |
Re: Can I use Test::Differences with Test::LectroTest?
by tmoertel (Chaplain) on Feb 02, 2005 at 16:46 UTC |