Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

acme (189)

  (email not shown publicly)

Leon Brocard (aka acme) is an orange-loving Perl eurohacker with many varied contributions to the Perl community, including the GraphViz module on the CPAN. YAPC::Europe was all his fault. He is still looking for a Perl Monger group he can start which begins with the letter 'D'.

Journal of acme (189)

Friday June 18, 2004
03:17 AM

Testing and randomness

[ #19342 ]
Tip for the day: if your test suite uses rand(), then please run your test suite a lot of times before releasing to CPAN. I've been guilty of it in the past, and so have others. Another friendly tip from your friendly orange Perl hacker...
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • ... with Net::Random. In this case, I don't use rand(), but I need to test a module whose output is meant to be truly random. Ugh.
    • what do you do? map the distribution? ugh, that's a tricky one ;)
      • I cheat. The current tests SUCK.

        What I really need to test is that I'm not introducing any bias to the data between me getting truly random data from the source and me presenting it to the programmer. My code manipulates the random data to do things like only produce values within a particular range. I have convinced myself that I'm probably OK, but I *need* regression tests for this.

      • Are you testing the functionality of the program or are you testing its randomness?

        If its the latter, say you're developing Crypt::Random or checking that /dev/urandom works, Statistics::ChiSquare sounds like the way to go.

        The former is more common. How do I test non-deterministic behavior?

        Seeing as how Dave Cross bought my testing services for Tie::Hash::Cannabinol at a YAPC auction way back when, let's use that as an example.

                      Tie::Hash::Cannabinol is
    • I need to test a module whose output is meant to be truly random.

      I've used Statistics::ChiSquare [] for this in the past, and it worked quite well. It was originally written by the very-large-brained Jon Orwant, and is currently maintained by David Cantrell.