Commit | Line | Data |
34a69e36 |
1 | use strictures 1; |
2 | use 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 | |
cbbfd457 |
72 | { |
73 | package GlobalConflict2; |
74 | |
75 | use Moo; |
76 | |
77 | no warnings 'redefine'; |
78 | |
79 | our $after = "has!"; |
80 | sub has { $after } |
81 | |
82 | no Moo; |
83 | } |
84 | |
34a69e36 |
85 | ok(!Spoon->can('extends'), 'extends cleaned'); |
86 | is(Spoon->has, "has!", 'has left alone'); |
87 | |
108f8ddc |
88 | ok(!Roller->can('has'), 'has cleaned'); |
89 | is(Roller->with, "with!", 'with left alone'); |
90 | |
a6e16bfb |
91 | is(NoMooClass->has, "has!", 'has left alone'); |
92 | |
93 | ok(!GlobalConflict->can('extends'), 'extends cleaned'); |
94 | is(GlobalConflict->has, "has!", 'has left alone'); |
95 | { |
96 | no warnings 'once'; |
97 | is($GlobalConflict::around, "has!", 'package global left alone'); |
98 | } |
99 | |
100 | ok(RollerTiny->can('around'), 'around left alone'); |
101 | is(RollerTiny->with, "with!", 'with left alone'); |
102 | |
cbbfd457 |
103 | ok(!GlobalConflict2->can('extends'), 'extends cleaned'); |
104 | is(GlobalConflict2->has, "has!", 'has left alone'); |
105 | { |
106 | no warnings 'once'; |
107 | is($GlobalConflict2::after, "has!", 'package global left alone'); |
108 | } |
109 | |
34a69e36 |
110 | done_testing; |