http://qs1969.pair.com?node_id=426952

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.