use
lib
qw( ./lib ./t/lib ../inc ./inc )
;
like(
exception { Type::Tiny::Class->new(
parent
=> Int,
class
=>
'Foo'
) },
qr/^Class type constraints cannot have a parent/
,
);
like(
exception { Type::Tiny::Class->new(
constraint
=>
sub
{ 1 },
class
=>
'Foo'
) },
qr/^Class type constraints cannot have a constraint coderef/
,
);
like(
exception { Type::Tiny::Class->new(
inlined
=>
sub
{ 1 },
class
=>
'Foo'
) },
qr/^Class type constraints cannot have an inlining coderef/
,
);
like(
exception { Type::Tiny::Class->new() },
qr/^Need to supply class name/
,
);
{
our
@ISA
=
qw()
;
sub
new {
bless
[],
shift
}
}
{
our
@ISA
=
qw()
;
}
{
our
@ISA
=
qw(Quuux)
;
}
{
our
@ISA
=
qw(Baz Quux)
;
}
my
$e
= exception {
Type::Tiny::Class
->new(
name
=>
"Elsa"
,
class
=>
"Foo"
)
->assert_valid( Bar->new );
};
is_deeply(
$e
->explain,
[
'"Elsa" requires that the reference isa Foo'
,
'The reference isa Bar, Baz, Quuux, and Quux'
,
],
);
done_testing;