X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fno-moo.t;h=0388a2badb5d845b1c5b7a9ce8d17a363e064c73;hb=350f2de6ebd85fd6fc5699c0773e6737756bac36;hp=58d92978757e80a468a6a4fd8ed55ee3779166f8;hpb=108f8ddcc8c9c70cdc1eb4b60210e47a1dfe1d06;p=gitmo%2FMoo.git diff --git a/t/no-moo.t b/t/no-moo.t index 58d9297..0388a2b 100644 --- a/t/no-moo.t +++ b/t/no-moo.t @@ -25,10 +25,86 @@ 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"); +} + +{ + package GlobalConflict2; + + use Moo; + + no warnings 'redefine'; + + our $after = "has!"; + sub has { $after } + + no Moo; +} + 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'); + +ok(!GlobalConflict2->can('extends'), 'extends cleaned'); +is(GlobalConflict2->has, "has!", 'has left alone'); +{ + no warnings 'once'; + is($GlobalConflict2::after, "has!", 'package global left alone'); +} + done_testing;