Perl module to help build up complex, semi-random data for testing.
Perl
Latest commit 409264f Apr 12, 2013 @schwern Version 20130412
Failed to load latest commit information.
inc Tidy Jun 29, 2009
lib/Test Version 20130412 Apr 12, 2013
t * The date generation example (also a test) would go out of bounds Jul 4, 2009
.gitignore Ignore MYMETA files and update the MANIFEST.SKIP defaults. Apr 12, 2013
.perlcriticrc
.perltidyrc
Build.PL
Changes Version 20130412 Apr 12, 2013
MANIFEST Version 20130412 Apr 12, 2013
MANIFEST.SKIP Ignore MYMETA files and update the MANIFEST.SKIP defaults. Apr 12, 2013
META.yml Version 20130412 Apr 12, 2013
README Add an example to the README Jun 29, 2009

README

Test::Sims is a Perl module to support the Sims testing technique to generate
large, complex, interesting, semi-random yet valid data for testing purposes.

Here's the slides outlining the technique:
http://schwern.org/talks/Generating%20Test%20Data%20With%20The%20Sims.pdf

Install as any normal Module::Build Perl module.

    perl Build.PL
    ./Build
    ./Build test
    sudo ./Build install

Or for your own personal use:

    perl Build.PL --install_base ~
    ./Build
    ./Build test
    ./Build install

Here's an example of making a simple package to generate random dates.

    package Sim::Date;

    use strict;
    use warnings;

    use DateTime;
    use Test::Sims;

    # Create rand_year(), rand_month(), etc...
    # All exportable on demand or with the :rand tag
    make_rand year  => [1800..2100];
    make_rand month => [1..12];
    make_rand day   => [1..31];
    make_rand hour  => [0..23];
    make_rand minute=> [0..59];
    make_rand second=> [0..59];

    sub sim_datetime {
        my %defaults = (
            year   => rand_year(),
            month  => rand_month(),
            day    => rand_day(),
            hour   => rand_hour(),
            minute => rand_minute(),
            second => rand_second(),
        );

        return DateTime->new(
            %defaults, @_
        );
    }

    # Export sim_datetime()
    export_sims();

And then using it.

    use Sim::Date;

    # Random date.
    my $date = sim_datetime;

    # Random date in the year 2009
    my $date = sim_datetime(
        year => 2009
    );