From: Christian Walde Date: Wed, 5 Sep 2012 13:22:36 +0000 (+0200) Subject: added tests for no Moo/::Role X-Git-Tag: v1.000008~11 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a6e16bfbdf3d270753d3c37945d22211e70a2abd;p=gitmo%2FMoo.git added tests for no Moo/::Role --- diff --git a/t/no-moo.t b/t/no-moo.t index 58d9297..74ed54e 100644 --- a/t/no-moo.t +++ b/t/no-moo.t @@ -25,10 +25,66 @@ use Test::More; no Moo::Role; } +{ + package NoMooClass; + + no warnings 'redefine'; + + sub has { "has!" } + + my %stash = %{Moo::_Utils::_getstash(__PACKAGE__)}; + Moo->unimport; + my %stash2 = %{Moo::_Utils::_getstash(__PACKAGE__)}; + main::is_deeply(\%stash, \%stash2, "stash of non-Moo class remains untouched"); +} + +{ + package GlobalConflict; + + use Moo; + + no warnings 'redefine'; + + sub has { "has!" } + + no Moo; + + our $around = "has!"; + + no Moo; +} + +{ + package RollerTiny; + + use Role::Tiny; + + no warnings 'redefine'; + + sub with { "with!" } + + my %stash = %{Moo::_Utils::_getstash(__PACKAGE__)}; + Moo::Role->unimport; + my %stash2 = %{Moo::_Utils::_getstash(__PACKAGE__)}; + main::is_deeply(\%stash, \%stash2, "stash of non-Moo role remains untouched"); +} + ok(!Spoon->can('extends'), 'extends cleaned'); is(Spoon->has, "has!", 'has left alone'); ok(!Roller->can('has'), 'has cleaned'); is(Roller->with, "with!", 'with left alone'); +is(NoMooClass->has, "has!", 'has left alone'); + +ok(!GlobalConflict->can('extends'), 'extends cleaned'); +is(GlobalConflict->has, "has!", 'has left alone'); +{ + no warnings 'once'; + is($GlobalConflict::around, "has!", 'package global left alone'); +} + +ok(RollerTiny->can('around'), 'around left alone'); +is(RollerTiny->with, "with!", 'with left alone'); + done_testing;