inlining for overloaded object isa/coerce
[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
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 85ok(!Spoon->can('extends'), 'extends cleaned');
86is(Spoon->has, "has!", 'has left alone');
87
108f8ddc 88ok(!Roller->can('has'), 'has cleaned');
89is(Roller->with, "with!", 'with left alone');
90
a6e16bfb 91is(NoMooClass->has, "has!", 'has left alone');
92
93ok(!GlobalConflict->can('extends'), 'extends cleaned');
94is(GlobalConflict->has, "has!", 'has left alone');
95{
96 no warnings 'once';
97 is($GlobalConflict::around, "has!", 'package global left alone');
98}
99
100ok(RollerTiny->can('around'), 'around left alone');
101is(RollerTiny->with, "with!", 'with left alone');
102
cbbfd457 103ok(!GlobalConflict2->can('extends'), 'extends cleaned');
104is(GlobalConflict2->has, "has!", 'has left alone');
105{
106 no warnings 'once';
107 is($GlobalConflict2::after, "has!", 'package global left alone');
108}
109
34a69e36 110done_testing;