FreeBSD.software
Home/devel/p5-Test-MockRandom

p5-Test-MockRandom

1.01_1

Replaces random number generation with non-random number generation

This perhaps ridiculous-seeming module was created to test routines that manipulate random numbers by providing a known output from rand. Given a list of seeds with srand, it will return each in turn. After seeded random numbers are exhausted, it will always return 0. Seed numbers must be of a form that meets the expected output from rand as called with no arguments -- i.e. they must be between 0 (inclusive) and 1 (exclusive). In order to facilitate generating and testing a nearly-one number, this module exports the function oneish, which returns a number just fractionally less than one. Depending on how this module is called with use, it will export rand to a specified package (e.g. a class being tested) effectively overriding and intercepting calls in that package to the built-in rand. It can also override rand in the current package or even globally. In all of these cases, it also exports srand and oneish to the current package in order to control the output of rand. Alternatively, this module can be used to generate objects, with each object maintaining its own distinct seed array.

Origin: devel/p5-Test-MockRandom
Category: devel
Size: 34.6KiB
License: APACHE20
Maintainer: perl@FreeBSD.org
Dependencies: 1 packages
Required by: 0 packages
$pkg install p5-Test-MockRandom

Dependencies (1)

More in devel