From: Shawn M Moore Date: Sun, 9 Nov 2008 05:22:44 +0000 (+0000) Subject: Test fixes and improvements X-Git-Tag: 0.05~96 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c389f1dff49901f850358222defd302f52bac9b0;p=gitmo%2FMooseX-Role-Parameterized.git Test fixes and improvements --- diff --git a/t/001-parameters.t b/t/001-parameters.t index 743bc72..838cca0 100644 --- a/t/001-parameters.t +++ b/t/001-parameters.t @@ -1,7 +1,7 @@ #!/usr/bin/env perl use strict; use warnings; -use Test::More tests => 10; +use Test::More tests => 12; use Test::Exception; use MooseX::Role::Parameterized::Parameters; diff --git a/t/002-role-block.t b/t/002-role-block.t index f1d633e..e417880 100644 --- a/t/002-role-block.t +++ b/t/002-role-block.t @@ -1,16 +1,16 @@ #!/usr/bin/env perl use strict; use warnings; -use Test::More tests => 2; +use Test::More tests => 5; use Test::Exception; my ($parameters, %args); do { - package MyRole; + package MyPerson; use MooseX::Role::Parameterized; - parameter length => ( + parameter default_age => ( is => 'rw', isa => 'Int', required => 1, @@ -18,16 +18,25 @@ do { role { ($parameters, %args) = @_; + + has age => ( + is => 'ro', + default => $parameters->default_age, + ); }; }; -ok(MyRole->meta->has_role_generator, "MyRole has a role generator"); +ok(MyPerson->meta->has_role_generator, "MyPerson has a role generator"); -my $role = MyRole->meta->generate_role( - length => 7, +my $role = MyPerson->meta->generate_role( + default_age => 7, ); isa_ok($role, 'Moose::Meta::Role', 'generate_role created a role'); -is($parameters->length, 7); +is($parameters->default_age, 7); +is($args{operating_on}, $role, "we pass in the role metaclass that we're operating on"); + +my $age_attr = $role->get_attribute('age'); +is($age_attr->{default}, 7, "role's age attribute has the right default");