github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

schwern / Test-Sims

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 2
    • 2
  • Source
  • Commits
  • Network (2)
  • Issues (0)
  • Downloads (5)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (4)
    • v20090704.203236
    • v20090704
    • v20090630.033501
    • v20090630
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

Perl module to help build up complex, semi-random data for testing. — Read more

  cancel

http://search.cpan.org/dist/Test-Sims

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Version 20090704.203236 
schwern (author)
Sat Jul 04 20:33:33 -0700 2009
commit  52fbc2005f4a06c11bf4fd63386dd949748028af
tree    4efaaf25285f4e3415d0ff67a0afac098008ff09
parent  1928d942abe37c5c7d793505d8e9bff8c9c7db56
Test-Sims /
name age
history
message
file .gitignore Sat Jun 27 18:45:49 -0700 2009 Basic .gitignore [schwern]
file .perlcriticrc Mon Jun 29 19:11:56 -0700 2009 Add a critic action. Run it and fix things dow... [schwern]
file .perltidyrc Mon Jun 29 18:58:39 -0700 2009 Add my usual perlcritic and perltidy configs [schwern]
file Build.PL Mon Jun 29 20:22:43 -0700 2009 Add github as our home page. [schwern]
file Changes Sat Jul 04 20:33:33 -0700 2009 Version 20090704.203236 [schwern]
file MANIFEST Sat Jul 04 13:17:37 -0700 2009 * control_rand.t made the non-portable assu... [schwern]
file MANIFEST.SKIP Sat Jun 27 20:42:50 -0700 2009 Rebuilt the MANIFEST.SKIP with MB r12947 [schwern]
file META.yml Sat Jul 04 20:33:33 -0700 2009 Version 20090704.203236 [schwern]
file README Mon Jun 29 20:25:25 -0700 2009 Add an example to the README [schwern]
directory inc/ Mon Jun 29 19:13:26 -0700 2009 Tidy [schwern]
directory lib/ Sat Jul 04 20:33:33 -0700 2009 Version 20090704.203236 [schwern]
directory t/ Sat Jul 04 20:31:30 -0700 2009 * The date generation example (also a test)... [schwern]
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
    );
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server