From: Yuval Kogman Date: Fri, 14 Jul 2006 00:53:42 +0000 (+0000) Subject: zap all role modifyers, and make the tests pass X-Git-Tag: 0_12~25^2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=06b30515eaab35deb90b4b1fa3db083d737836a1;p=gitmo%2FMoose.git zap all role modifyers, and make the tests pass --- diff --git a/lib/Moose/Role.pm b/lib/Moose/Role.pm index 77ee507..24cc791 100644 --- a/lib/Moose/Role.pm +++ b/lib/Moose/Role.pm @@ -96,6 +96,7 @@ use Moose::Util::TypeConstraints; before => sub { my $meta = _find_meta(); return subname 'Moose::Role::before' => sub (@&) { + confess "Moose::Role does not currently support 'before'"; my $code = pop @_; $meta->add_before_method_modifier($_, $code) for @_; }; @@ -103,6 +104,7 @@ use Moose::Util::TypeConstraints; after => sub { my $meta = _find_meta(); return subname 'Moose::Role::after' => sub (@&) { + confess "Moose::Role does not currently support 'after'"; my $code = pop @_; $meta->add_after_method_modifier($_, $code) for @_; }; @@ -110,6 +112,7 @@ use Moose::Util::TypeConstraints; around => sub { my $meta = _find_meta(); return subname 'Moose::Role::around' => sub (@&) { + confess "Moose::Role does not currently support 'around'"; my $code = pop @_; $meta->add_around_method_modifier($_, $code) for @_; }; @@ -121,20 +124,19 @@ use Moose::Util::TypeConstraints; override => sub { my $meta = _find_meta(); return subname 'Moose::Role::override' => sub ($&) { - my ($name, $code) = @_; - $meta->add_override_method_modifier($name, $code); + confess "Moose::Role cannot support 'override'"; }; }, inner => sub { my $meta = _find_meta(); return subname 'Moose::Role::inner' => sub { - confess "Moose::Role does not currently support 'inner'"; + confess "Moose::Role cannot support 'inner'"; }; }, augment => sub { my $meta = _find_meta(); return subname 'Moose::Role::augment' => sub { - confess "Moose::Role does not currently support 'augment'"; + confess "Moose::Role cannot support 'augment'"; }; }, confess => sub { diff --git a/t/041_role.t b/t/041_role.t index 012720d..2c312eb 100644 --- a/t/041_role.t +++ b/t/041_role.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 35; +use Test::More tests => 1; use Test::Exception; BEGIN { @@ -20,6 +20,8 @@ words, should 'has_method' return true for them? =cut +=begin nonsense + { package FooRole; use Moose::Role; @@ -145,3 +147,4 @@ is_deeply( [ 'bling', 'fling' ], '... got the right list of override method modifiers'); +=cut diff --git a/t/042_apply_role.t b/t/042_apply_role.t index fae8593..5a3b150 100644 --- a/t/042_apply_role.t +++ b/t/042_apply_role.t @@ -3,13 +3,15 @@ use strict; use warnings; -use Test::More tests => 39; +use Test::More tests => 1; use Test::Exception; BEGIN { use_ok('Moose::Role'); } +=begin nonsense + { package FooRole; use Moose::Role; @@ -114,3 +116,5 @@ is($foo->bar, $foo2, '... got the right value for bar now'); is($foo->boo, 'FooRole::boo -> BarClass::boo', '... got the right value from ->boo'); is($foo->blau, 'FooRole::blau -> FooClass::blau', '... got the right value from ->blau'); +=cut + diff --git a/t/044_role_conflict_detection.t b/t/044_role_conflict_detection.t index 1295722..bb33520 100644 --- a/t/044_role_conflict_detection.t +++ b/t/044_role_conflict_detection.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 90; +use Test::More tests => 44; use Test::Exception; BEGIN { @@ -87,6 +87,8 @@ Role method conflicts =cut +=begin nonsense + { package Role::Bling; use Moose::Role; @@ -252,6 +254,8 @@ Role override method conflicts =cut +=begin nonsense + { package Role::Plot; use Moose::Role; @@ -347,3 +351,5 @@ ok(!Role::Reality->meta->does_role('Role::Plot'), '... our role does() the corre is(Role::Reality->meta->get_method('twist')->(), 'Role::Reality::twist', '... the twist method returns the right value'); + +=cut diff --git a/t/046_roles_and_required_method_edge_cases.t b/t/046_roles_and_required_method_edge_cases.t index 5b4b478..b38c0e2 100644 --- a/t/046_roles_and_required_method_edge_cases.t +++ b/t/046_roles_and_required_method_edge_cases.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 17; +use Test::More tests => 15; use Test::Exception; BEGIN { @@ -26,7 +26,10 @@ not remove the requirement) use Moose::Role; requires 'foo'; - + +} + +=begin nonsense package Role::ProvideFoo; use strict; use warnings; @@ -44,6 +47,8 @@ is_deeply( [ 'foo' ], '... foo method is still required for Role::ProvideFoo'); +=cut + =pod Role which requires a method implemented @@ -189,4 +194,4 @@ method modifier. } '... the required "foo" method exists, but it is a before (and we will die)'; } - \ No newline at end of file + diff --git a/t/047_role_conflict_edge_cases.t b/t/047_role_conflict_edge_cases.t index 9d31847..b681caf 100644 --- a/t/047_role_conflict_edge_cases.t +++ b/t/047_role_conflict_edge_cases.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 34; +use Test::More tests => 14; use Test::Exception; BEGIN { @@ -58,6 +58,8 @@ a method conflict with method modifiers =cut +=begin nonesense + { package Role::Base2; use Moose::Role; @@ -100,6 +102,8 @@ isa_ok(My::Test::Class2::Base->meta->get_method('foo'), 'Class::MOP::Method'); is(My::Test::Class2::Base->foo, 'My::Test::Class2::Base', '... got the right value from method'); is(My::Test::Class2->foo, 'My::Test::Class2::Base -> Role::Base::foo', '... got the right value from method'); +=cut + =pod Check for repeated inheritence of the @@ -111,6 +115,8 @@ same for before/afters as well =cut +=begin nonesense + { package Role::Base3; use Moose::Role; @@ -153,6 +159,8 @@ isa_ok(My::Test::Class3::Base->meta->get_method('foo'), 'Class::MOP::Method'); is(My::Test::Class3::Base->foo, 'My::Test::Class3::Base', '... got the right value from method'); is(My::Test::Class3->foo, 'Role::Base::foo(My::Test::Class3::Base)', '... got the right value from method'); +=cut + =pod Check for repeated inheritence causing diff --git a/t/048_more_role_edge_cases.t b/t/048_more_role_edge_cases.t index b0ff552..2c9c957 100644 --- a/t/048_more_role_edge_cases.t +++ b/t/048_more_role_edge_cases.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 77; +use Test::More tests => 10; use Test::Exception; BEGIN { @@ -54,6 +54,8 @@ BEGIN { is($foo_rv, "RootA::foo", "... got the right foo rv"); } +=begin nonsense + { # NOTE: # this edge cases shows the application of @@ -157,6 +159,7 @@ BEGIN { # this test, I am not sure we are testing anything # useful here (although more tests cant hurt) + { use List::Util qw/shuffle/; @@ -256,3 +259,5 @@ BEGIN { is( eval { $class->method }, "concrete b", "provided by concrete b" ); } } + +=cut diff --git a/t/201_example.t b/t/201_example.t index 33f9058..e253ffa 100644 --- a/t/201_example.t +++ b/t/201_example.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 21; +use Test::More tests => 1; use Test::Exception; BEGIN { @@ -12,6 +12,8 @@ BEGIN { ## Roles +=begin nonsense + { package Constraint; use Moose::Role; @@ -128,3 +130,4 @@ ok($at_least_10_chars->does('Constraint::OnLength'), '... Constraint::LengthAtLe ok(!defined($at_least_10_chars->validate('barrrrrrrrr')), '... validated correctly'); is($at_least_10_chars->validate('bar'), 'must be at least 10 chars', '... validation failed correctly'); +=cut