8 'Test::Output' => '0.16',
13 eval 'package Foo; use Package::DeprecationManager;';
16 qr/^\QYou must provide a hash reference -deprecations parameter when importing Package::DeprecationManager/,
17 'must provide a set of deprecations when using Package::DeprecationManager';
23 use Package::DeprecationManager -deprecations => {
27 'not a sub' => '1.23',
31 deprecated('foo is deprecated');
35 deprecated('bar is deprecated');
45 message => 'quux > 5 has been deprecated',
46 feature => 'not a sub',
52 deprecated("The varies sub varies: $_[0]");
62 ::stderr_like{ Foo::foo() }
63 qr/\Qfoo is deprecated/,
64 'deprecation warning for foo';
66 ::stderr_like{ Foo::bar() }
67 qr/\Qbar is deprecated/,
68 'deprecation warning for bar';
70 ::stderr_like{ Foo::baz() }
71 qr/\QFoo::baz has been deprecated since version 1.21/,
72 'deprecation warning for baz, and message is generated by Package::DeprecationManager';
74 ::stderr_is{ Foo::foo() } q{}, 'no warning on second call to foo';
76 ::stderr_is{ Foo::bar() } q{}, 'no warning on second call to bar';
78 ::stderr_is{ Foo::baz() } q{}, 'no warning on second call to baz';
80 ::stderr_like{ Foo::varies(1) }
81 qr/\QThe varies sub varies: 1/,
82 'warning for varies sub';
84 ::stderr_like{ Foo::varies(2) }
85 qr/\QThe varies sub varies: 2/,
86 'warning for varies sub with different error';
88 ::stderr_is{ Foo::varies(1) }
90 'no warning for varies sub with same message as first call';
96 Foo->import( -api_version => '0.01' );
98 ::stderr_is{ Foo::foo() }
100 'no warning for foo with api_version = 0.01';
102 ::stderr_is{ Foo::bar() }
104 'no warning for bar with api_version = 0.01';
106 ::stderr_is{ Foo::baz() }
108 'no warning for baz with api_version = 0.01';
114 Foo->import( -api_version => '1.17' );
116 ::stderr_like{ Foo::foo() }
117 qr/\Qfoo is deprecated/,
118 'deprecation warning for foo with api_version = 1.17';
120 ::stderr_like{ Foo::bar() }
121 qr/\Qbar is deprecated/,
122 'deprecation warning for bar with api_version = 1.17';
124 ::stderr_is{ Foo::baz() }
126 'no warning for baz with api_version = 1.17';
134 ::stderr_is{ Foo::quux(1) }
136 'no warning for quux(1)';
138 ::stderr_like{ Foo::quux(10) }
139 qr/\Qquux > 5 has been deprecated/,
140 'got a warning for quux(10)';
147 use Package::DeprecationManager -deprecations => {
148 'Dep::foo' => '1.00',
150 -ignore => [ 'My::Package1', 'My::Package2' ];
153 deprecated('foo is deprecated');
160 use Package::DeprecationManager -deprecations => {
161 'Dep2::bar' => '1.00',
163 -ignore => [ qr/My::Package[12]/ ];
166 deprecated('bar is deprecated');
171 package My::Package1;
173 sub foo { Dep::foo() }
174 sub bar { Dep2::bar() }
178 package My::Package2;
180 sub foo { My::Package1::foo() }
181 sub bar { My::Package1::bar() }
187 ::stderr_like{ My::Package2::foo() }
188 qr/^foo is deprecated at t.basic\.t line \d+\s+My::Baz/,
189 'deprecation warning for call to My::Package2::foo() and mentions My::Baz but not My::Package[12]';
191 ::stderr_is{ My::Package2::foo() }
193 'no deprecation warning for second call to My::Package2::foo()';
195 ::stderr_is{ My::Package1::foo() }
197 'no deprecation warning for call to My::Package1::foo()';
199 ::stderr_like{ My::Package2::bar() }
200 qr/^bar is deprecated at t.basic\.t line \d+\s+My::Baz/,
201 'deprecation warning for call to My::Package2::foo() and mentions My::Baz but not My::Package[12]';
203 ::stderr_is{ My::Package2::bar() }
205 'no deprecation warning for second call to My::Package2::bar()';
211 ::stderr_like{ My::Package1::foo() }
212 qr/^foo is deprecated at t.basic\.t line \d+\s+My::Quux/,
213 'deprecation warning for call to My::Package1::foo() and mentions My::Quux but not My::Package[12]';
215 ::stderr_is{ My::Package1::foo() }
217 'no deprecation warning for second call to My::Package1::foo()';