in reply to Test::LectroTest and Test::MockObject.
in thread RFC: Tutorial on Testing
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:
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.)#!/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";
Thanks again for taking the time to provide feedback!
Cheers,
Tom
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Test::LectroTest and Test::MockObject.
by pernod (Chaplain) on Sep 14, 2004 at 20:37 UTC | |
by spiderman (Monk) on Sep 14, 2004 at 22:16 UTC |