BEGIN {
declare NonEmptyStr, as Str, where {
length
(
$_
) };
$INC
{
'MyTypes.pm'
} = __FILE__;
};
should_pass(
"foo"
, Str);
should_pass(
""
, Str);
should_pass(
"foo"
, NonEmptyStr);
should_fail(
""
, NonEmptyStr);
should_pass({}, HashLike);
should_fail([], HashLike);
{
$INC
{
'MyDummy.pm'
} = __FILE__;
::like(
::exception { Type::Utils::
extends
'MyDummy'
},
qr/not a type constraint library/
,
'cannot extend non-type-library'
,
);
}
BEGIN {
subtype RoundedInt, as Int;
coerce RoundedInt, from Num, via {
int
(
$_
) };
$INC
{
'MyMooseTypes.pm'
} = __FILE__;
};
{
::is( RoundedInt->coerce(3.1), 3,
'MooseX::Types coercion works as expected'
);
}
BEGIN {
$INC
{
'MyTinyTypes.pm'
} = __FILE__;
};
{
::is( RoundedInt->coerce(3.1), 3,
'Type::Tiny coercion works built from MooseX::Types extension'
);
}
done_testing;