NAME
Test::RandomResults - Test non-deterministic functions
DESCRIPTION
This module aims to provide ways of testing functions that are meant to return results that are random; that is, non-deterministic functions.
Some of the tests provided here might be easily achieved with other testing modules. The reason why they're here is that this way users become aware of how to test their non-deterministic functions.
NOTICE
This is a work in progress. Comments are welcome.
SYNOPSIS
use Test::More plan => $Num_Tests;
use Test::RandomResults;
is_in( my_function, [ $list, $of, $items ], "result is inside list" );
length_lt( my_function, $limit, "length lower than $limit");
length_le( my_function, $limit, "length lower or equal to $limit");
length_eq( my_function, $limit, "length equal to $limit");
length_ge( my_function, $limit, "length greater of equal to $limit");
length_gt( my_function, $limit, "length greater than $limit");
SPECIAL FEATURES
Whenever Test::RandomResults is invoked, a new seed is generated and outputed as diagnostics. This is done so that you can use it to debug your code, if needed.
FUNCTIONS
is_in
Tests if an element belongs to an array.
is_in( my_function, [1, 2, 3], 'either 1, 2 or 3');
in_between
Tests if an element is within two boundaries.
The second parameter to this function is what it uses to do the comparisons.
To compare strings:
in_between( my_function, { $_[0] cmp $_[1] }, "aaa", "zzz",
'result is between "aaa" and "zzz"' );
To compare numbers:
in_between( my_function, { $_[0] <=> $_[1] }, 1, 10, "result is between 1 and 10" );
in_between swaps the lower and upper limits, if need be (this means that checking whether a value is between 1 and 10 is the same as checking between 10 and 1).
length_lt
Tests if length is lower than a limit.
length_lt( my_function, $limit, "length lower than $limit");
length_le
Tests if length is lower or equal to a limit.
length_le( my_function, $limit, "length lower or equal to $limit");
length_eq
Tests if length is equal to a limit.
length_eq( my_function, $limit, "length equal to $limit");
length_ge
Tests if length is greater of equal to a limit.
length_ge( my_function, $limit, "length greater of equal to $limit");
length_gt
Tests if length is greater than a limit.
length_gt( my_function, $limit, "length greater than $limit");
TO DO
* Check if N results of a function are evenly_distributed
AUTHOR
Jose Castro, <cog@cpan.org>
BUGS
Please report any bugs or feature requests to bug-test-randomresults@rt.cpan.org
, or through the web interface at http://rt.cpan.org. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
COPYRIGHT & LICENSE
Copyright 2005 Jose Castro, All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.