added tests for no Moo/::Role
[gitmo/Moo.git] / t / no-moo.t
CommitLineData
34a69e36 1use strictures 1;
2use Test::More;
3
4{
5 package Spoon;
6
7 use Moo;
8
9 no warnings 'redefine';
10
11 sub has { "has!" }
12
13 no Moo;
14}
15
108f8ddc 16{
17 package Roller;
18
19 use Moo::Role;
20
21 no warnings 'redefine';
22
23 sub with { "with!" }
24
25 no Moo::Role;
26}
27
a6e16bfb 28{
29 package NoMooClass;
30
31 no warnings 'redefine';
32
33 sub has { "has!" }
34
35 my %stash = %{Moo::_Utils::_getstash(__PACKAGE__)};
36 Moo->unimport;
37 my %stash2 = %{Moo::_Utils::_getstash(__PACKAGE__)};
38 main::is_deeply(\%stash, \%stash2, "stash of non-Moo class remains untouched");
39}
40
41{
42 package GlobalConflict;
43
44 use Moo;
45
46 no warnings 'redefine';
47
48 sub has { "has!" }
49
50 no Moo;
51
52 our $around = "has!";
53
54 no Moo;
55}
56
57{
58 package RollerTiny;
59
60 use Role::Tiny;
61
62 no warnings 'redefine';
63
64 sub with { "with!" }
65
66 my %stash = %{Moo::_Utils::_getstash(__PACKAGE__)};
67 Moo::Role->unimport;
68 my %stash2 = %{Moo::_Utils::_getstash(__PACKAGE__)};
69 main::is_deeply(\%stash, \%stash2, "stash of non-Moo role remains untouched");
70}
71
34a69e36 72ok(!Spoon->can('extends'), 'extends cleaned');
73is(Spoon->has, "has!", 'has left alone');
74
108f8ddc 75ok(!Roller->can('has'), 'has cleaned');
76is(Roller->with, "with!", 'with left alone');
77
a6e16bfb 78is(NoMooClass->has, "has!", 'has left alone');
79
80ok(!GlobalConflict->can('extends'), 'extends cleaned');
81is(GlobalConflict->has, "has!", 'has left alone');
82{
83 no warnings 'once';
84 is($GlobalConflict::around, "has!", 'package global left alone');
85}
86
87ok(RollerTiny->can('around'), 'around left alone');
88is(RollerTiny->with, "with!", 'with left alone');
89
34a69e36 90done_testing;