2 # This is automatically generated by author/import-moose-test.pl.
3 # DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!!
4 use t::lib::MooseCompat;
10 $TODO = q{Mouse is not yet completed};
14 use_ok("Mouse::Util::TypeConstraints");
15 use_ok('Mouse::Meta::TypeConstraint');
22 bless { items => \@_ }, $class;
27 return @{ $self->{items} };
31 subtype 'MyList' => as 'Object' => where { $_->isa('MyList') };
36 => via { [ $_->items ] }
37 } '... created the coercion okay';
39 my $mylist = Mouse::Util::TypeConstraints::find_or_parse_type_constraint('MyList[Int]');
41 ok($mylist->check(MyList->new(10, 20, 30)), '... validated it correctly (pass)');
42 ok(!$mylist->check(MyList->new(10, "two")), '... validated it correctly (fail)');
43 ok(!$mylist->check([10]), '... validated it correctly (fail)');
45 subtype 'EvenList' => as 'MyList' => where { $_->items % 2 == 0 };
47 # XXX: get this to work *without* the declaration. I suspect it'll be a new
48 # method in Mouse::Meta::TypeCoercion that will look at the parents of the
49 # coerced type as well. but will that be too "action at a distance"-ey?
53 => via { [ $_->items ] }
54 } '... created the coercion okay';
56 my $evenlist = Mouse::Util::TypeConstraints::find_or_parse_type_constraint('EvenList[Int]');
58 ok(!$evenlist->check(MyList->new(10, 20, 30)), '... validated it correctly (fail)');
59 ok($evenlist->check(MyList->new(10, 20, 30, 40)), '... validated it correctly (pass)');
60 ok(!$evenlist->check(MyList->new(10, "two")), '... validated it correctly (fail)');
61 ok(!$evenlist->check([10, 20]), '... validated it correctly (fail)');