my ( $role, $method ) = @_;
local $Test::Builder::Level = $Test::Builder::Level + 1;
if ( $role ) {
- ok( $role->has_method($method) || $role->requires_method($method), $role->name . " has or requires method $method" );
+ ok(
+ $role->has_method($method) || $role->requires_method($method),
+ $role->name . " has or requires method $method"
+ );
} else {
fail("role has or requires method $method");
}
}
-{
- package Bar;
- use Moose::Role;
+{
+ package Bar;
+ use Moose::Role;
# this role eventually adds three methods, qw(foo bar xxy), but only one is
# known when it's still a role
- has foo => ( is => "rw" );
+ has foo => ( is => "rw" );
has gorch => ( reader => "bar" );
has twist => ( is => "rw" );
{
- local our $TODO = "accessors don't satisfy role requires";
::lives_ok { with qw(Dancer) };
}
::lives_ok { with qw(Dancer::Robot) };
}
- package Foo;
- use Moose;
+ package Foo;
+ use Moose;
- with qw(Bar);
+ with qw(Bar);
has oink => (
is => "rw",
default => sub { Dancer::Ballerina->new },
);
- sub foo { 42 }
+ sub foo { 42 }
sub bar { 33 }
sub xxy { 7 }
+
+ package Tree;
+ use Moose::Role;
+
+ has bark => ( is => "rw" );
+
+ package Dog;
+ use Moose::Role;
+
+ sub bark { warn "woof!" };
+
+ package EntPuppy;
+ use Moose;
+
+ {
+ local our $TODO = "attrs and methods from a role should clash";
+ ::dies_ok { with qw(Tree Dog) }
+ }
}
# these fail because of the deferral logic winning over actual methods
req_or_has($gorch, "gorch_method");
ok( $gorch->has_method("gorch_method"), "has_method gorch_method" );
ok( !$gorch->requires_method("gorch_method"), "requires gorch method" );
-
-{
- local $TODO = "role method isn't a meta object yet";
- isa_ok( $gorch->get_method("gorch_method"), "Moose::Meta::Method" );
-}
+isa_ok( $gorch->get_method("gorch_method"), "Moose::Meta::Method" );
{
local $TODO = "method modifier doesn't yet create a method requirement or meta object";
}
{
- local $TODO = "attribute related methods are not yet known by the role";
req_or_has($robot, "twist");
+
+ local $TODO = "attribute related methods are not yet known by the role";
ok( $robot->has_method("twist"), "has twist method" );
isa_ok( $robot->get_method("twist"), "Moose::Meta::Method" );
isa_ok( $robot->get_method("twist"), "Moose::Meta::Method::Accessor" );