MooX-Types-MooseLike

 view release on metacpan or  search on metacpan

t/parameterized_inflate.t  view on Meta::CPAN

use strict;
use warnings;
use Test::More;
use Test::Fatal;

eval q{
	package Local::TestClass;
	use Moo;
	use MooX::Types::MooseLike::Base qw( Enum AnyOf Str ArrayRef ScalarRef HashRef HasMethods );
	has chipmunk => (is => 'ro', isa => Enum[qw(Alvin Simon Theodore)]);
	has songs    => (is => 'ro', isa => AnyOf[ Str, ArrayRef[Str] ]);
	has complex  => (is => 'ro', isa => HashRef[ArrayRef[ScalarRef[HasMethods[qw/foo bar/]]]]);
	1;
} or die $@;

is(
  exception { Local::TestClass->new(chipmunk => 'Simon', songs => []) },
  undef,
  'values which should not violate type constraints',
  );

like(



( run in 2.050 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )