Require Package::DeprecationManager 0.07
[gitmo/Moose.git] / t / 010_basics / 030_deprecations.t
CommitLineData
34d6d196 1use strict;
2use warnings;
3
4use Test::More;
5
6use Test::Requires {
7 'Test::Output' => '0.01',
8};
9
10{
11 package Role;
12
13 use Moose::Role;
14
15 sub thing { }
16}
17
18{
19 package Foo;
20
21 use Moose;
22
23 ::stderr_like{ has foo => (
24 traits => ['String'],
25 is => 'ro',
26 isa => 'Str',
27 );
28 }
29 qr/\QAllowing a native trait to automatically supply a default is deprecated/,
30 'Not providing a default for native String trait warns';
31
32 ::stderr_like{ has bar => (
33 traits => ['String'],
34 isa => 'Str',
35 default => q{},
36 );
37 }
38 qr/\QAllowing a native trait to automatically supply a value for "is" is deprecated/,
39 'Not providing a value for is with native String trait warns';
40
41 ::stderr_like{ with 'Role' =>
42 { excludes => ['thing'], alias => { thing => 'thing2' } };
43 }
44 qr/\QThe alias and excludes options for role application have been renamed -alias and -excludes/,
45 'passing excludes or alias with a leading dash warns';
46 ::ok(
47 !Foo->meta->has_method('thing'),
48 'thing method is excluded from role application'
49 );
50 ::ok(
51 Foo->meta->has_method('thing2'),
52 'thing2 method is created as alias in role application'
53 );
54}
55
3cf2f9ec 56{
57 package Pack1;
58
59 use Moose;
60
61 ::stderr_is{ has foo => (
62 traits => ['String'],
63 reader => '_foo',
64 isa => 'Str',
65 default => q{},
66 );
67 } q{},
68 'Providing a reader for a String trait avoids default is warning';
69
70 ::stderr_is{ has bar => (
71 traits => ['String'],
72 is => 'ro',
73 isa => 'Str',
74 builder => '_build_foo',
75 );
76 } q{},
77 'Providing a builder for a String trait avoids default default warning';
78
79 sub _build_foo { }
80}
81
82{
83 package Pack2;
84
85 use Moose;
86
87 ::stderr_is{ has foo => (
88 traits => ['String'],
89 writer => '_foo',
90 isa => 'Str',
91 default => q{},
92 );
93 } q{},
94 'Providing a writer for a String trait avoids default is warning';
95
96 ::stderr_is{ has bar => (
97 traits => ['String'],
98 is => 'ro',
99 isa => 'Str',
100 required => 1,
101 );
102 } q{},
103 'Making a String trait required avoids default default warning';
104
105 sub _build_foo { }
106}
107
108{
109 package Pack3;
110
111 use Moose;
112
113 ::stderr_is{ has foo => (
114 traits => ['String'],
115 accessor => '_foo',
116 isa => 'Str',
117 default => q{},
118 );
119 } q{},
120 'Providing an accessor for a String trait avoids default is warning';
121}
122
34d6d196 123done_testing;
124