X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fno-moo.t;fp=t%2Fno-moo.t;h=74ed54e6d64889d6eadc39c4114cefd602155096;hb=a6e16bfbdf3d270753d3c37945d22211e70a2abd;hp=58d92978757e80a468a6a4fd8ed55ee3779166f8;hpb=96b09f219131ab88ebcb935e5baef654de7ddb84;p=gitmo%2FMoo.git 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;