----- Original Message ----

> From: Michael G Schwern <schw...@pobox.com>
> 
> Ovid wrote:
> > First feature request:  automatic Moose support to build random data which
> > conforms to Moose constraints :)  (Yes, I know it's much, much harder than
> it sounds).
> 
> Hello, what?

  package Person;
  use Moose;
  has name => (is => 'ro', isa => 'Str');
  has age  => (is => 'ro', isa => 'Int');
  ...

"name" and "age" must be Str and Int respectively.  Each can be easy to break, 
but Test::Sims::Moose would be able to:

    use Test::Sims::Moose 'random';

    Person->new( 
        name => random('Person.name'), 
        age  => random('Person.age') 
    );

And that would potentially have issues when it assigns "\t" to $name and -12 to 
$age, even those are both valid values for the types in question.  It would be 
very difficult to find data which automatically fits any random type, but it 
could be written for core types and extensible for other types.

Cheers,
Ovid
--
Buy the book         - http://www.oreilly.com/catalog/perlhks/
Tech blog            - http://use.perl.org/~Ovid/journal/
Twitter              - http://twitter.com/OvidPerl
Official Perl 6 Wiki - http://www.perlfoundation.org/perl6

Reply via email to