{
{
}
my
$exception
= exception {
Foo->new(
"hello"
)
};
like(
$exception
,
qr/^\QSingle parameters to new() must be a HASH ref/
,
"A single non-hashref arg to a constructor throws an error"
);
isa_ok(
$exception
,
"Moose::Exception::SingleParamsToNewMustBeHashRef"
,
"A single non-hashref arg to a constructor throws an error"
);
}
{
{
}
my
$foo
= Foo->new;
my
$exception
= exception {
$foo
->does;
};
like(
$exception
,
qr/^\QYou must supply a role name to does()/
,
"Cannot call does() without a role name"
);
isa_ok(
$exception
,
"Moose::Exception::DoesRequiresRoleName"
,
"Cannot call does() without a role name"
);
is(
$exception
->class_name,
"Foo"
,
"Cannot call does() without a role name"
);
$exception
= exception {
Foo->does;
};
like(
$exception
,
qr/^\QYou must supply a role name to does()/
,
"Cannot call does() without a role name"
);
isa_ok(
$exception
,
"Moose::Exception::DoesRequiresRoleName"
,
"Cannot call does() without a role name"
);
is(
$exception
->class_name,
"Foo"
,
"Cannot call does() without a role name"
);
}
done_testing;