likely/unlikely. Has there been any previous work along these lines?
Should we add something like this to test/spec (Christian are
you listening? :))
likely "that two consecutive calls to rand gives
I think that the example you give is not appropriate for testing rand(),
pretty much any code where the result is expected to conform to a set of
statistical properties. If you take a look at randomness test suites
Diehard there are a battery of different tests that should be applied
data can be called ‘random’ with any confidence.
The tests as you have written them would be satisfied by any number of
broken PRNGs, or even NRAAGs (Not Random At All Generators) (eg
‘1’ and ‘2’ ;). In particular, unlikely events must occur sometimes and
likely events must fail to occur sometimes, so some form of === seems
If you wanted to test RNGs then you need to run a whole series of tests
either like the Diehard tests or just basic stuff like chi square,
monte-carlo calculation of pi etc.
More generally, I think that ‘likely’ and ‘unlikely’ are going to be so
context dependant that the user would be better off writing their own
code, surely? I can see a place for should_be_random, but likely and
unlikely strike me as a bad idea. In any case, when running test code I
expect that it will give me the same result every time, so any tests
at least have that property.
Sorry to sound negative.