use strict;
use warnings;
-use Test::More tests => 9;
-use Test::Exception;
-
+use Test::More;
+use Test::Fatal;
{
has 'bar' => (is => 'rw', does => 'Bar::Role');
has 'baz' => (
is => 'rw',
- does => subtype('Role', where { $_->does('Bar::Role') })
+ does => role_type('Bar::Role')
);
+ package Foo::Class;
+ use Moose;
+
+ with 'Foo::Role';
+
package Bar::Role;
use Moose::Role;
# since the isa() check will imply the does() check
has 'foo' => (is => 'rw', isa => 'Foo::Class', does => 'Foo::Role');
- package Foo::Class;
- use Moose;
-
- with 'Foo::Role';
-
package Bar::Class;
use Moose;
with 'Bar::Role';
-
}
my $foo = Foo::Class->new;
my $bar = Bar::Class->new;
isa_ok($bar, 'Bar::Class');
-lives_ok {
+is( exception {
$foo->bar($bar);
-} '... bar passed the type constraint okay';
+}, undef, '... bar passed the type constraint okay' );
-dies_ok {
+isnt( exception {
$foo->bar($foo);
-} '... foo did not pass the type constraint okay';
+}, undef, '... foo did not pass the type constraint okay' );
-lives_ok {
+is( exception {
$foo->baz($bar);
-} '... baz passed the type constraint okay';
+}, undef, '... baz passed the type constraint okay' );
-dies_ok {
+isnt( exception {
$foo->baz($foo);
-} '... foo did not pass the type constraint okay';
+}, undef, '... foo did not pass the type constraint okay' );
-lives_ok {
+is( exception {
$bar->foo($foo);
-} '... foo passed the type constraint okay';
+}, undef, '... foo passed the type constraint okay' );
# if isa and does appear together, then see if Class->does(Role)
# if it does not,.. we have a conflict... so we die loudly
- ::dies_ok {
+ ::isnt( ::exception {
has 'foo' => (isa => 'Foo::Class', does => 'Bar::Class');
- } '... cannot have a does() which is not done by the isa()';
+ }, undef, '... cannot have a does() which is not done by the isa()' );
}
{
# if isa and does appear together, then see if Class->does(Role)
# if it does not,.. we have a conflict... so we die loudly
- ::dies_ok {
+ ::isnt( ::exception {
has 'foo' => (isa => 'Bling', does => 'Bar::Class');
- } '... cannot have a isa() which is cannot does()';
+ }, undef, '... cannot have a isa() which is cannot does()' );
}
-
-
+done_testing;