8 'Test::Output' => '0.16',
14 eval 'package Foo; use Package::DeprecationManager;';
17 qr/^\QYou must provide a hash reference -deprecations parameter when importing Package::DeprecationManager/,
18 'must provide a set of deprecations when using Package::DeprecationManager'
25 use Package::DeprecationManager -deprecations => {
29 'not a sub' => '1.23',
33 deprecated('foo is deprecated');
37 deprecated('bar is deprecated');
47 message => 'quux > 5 has been deprecated',
48 feature => 'not a sub',
54 deprecated("The varies sub varies: $_[0]");
64 ::stderr_like{ Foo::foo() }
65 qr/\Qfoo is deprecated/,
66 'deprecation warning for foo';
68 ::stderr_like{ Foo::bar() }
69 qr/\Qbar is deprecated/,
70 'deprecation warning for bar';
72 ::stderr_like{ Foo::baz() }
73 qr/\QFoo::baz has been deprecated since version 1.21/,
74 'deprecation warning for baz, and message is generated by Package::DeprecationManager';
76 ::stderr_is{ Foo::foo() } q{}, 'no warning on second call to foo';
78 ::stderr_is{ Foo::bar() } q{}, 'no warning on second call to bar';
80 ::stderr_is{ Foo::baz() } q{}, 'no warning on second call to baz';
82 ::stderr_like{ Foo::varies(1) }
83 qr/\QThe varies sub varies: 1/,
84 'warning for varies sub';
86 ::stderr_like{ Foo::varies(2) }
87 qr/\QThe varies sub varies: 2/,
88 'warning for varies sub with different error';
90 ::stderr_is{ Foo::varies(1) }
92 'no warning for varies sub with same message as first call';
98 Foo->import( -api_version => '0.01' );
100 ::stderr_is{ Foo::foo() }
102 'no warning for foo with api_version = 0.01';
104 ::stderr_is{ Foo::bar() }
106 'no warning for bar with api_version = 0.01';
108 ::stderr_is{ Foo::baz() }
110 'no warning for baz with api_version = 0.01';
116 Foo->import( -api_version => '1.17' );
118 ::stderr_like{ Foo::foo() }
119 qr/\Qfoo is deprecated/,
120 'deprecation warning for foo with api_version = 1.17';
122 ::stderr_like{ Foo::bar() }
123 qr/\Qbar is deprecated/,
124 'deprecation warning for bar with api_version = 1.17';
126 ::stderr_is{ Foo::baz() }
128 'no warning for baz with api_version = 1.17';
136 ::stderr_is{ Foo::quux(1) }
138 'no warning for quux(1)';
140 ::stderr_like{ Foo::quux(10) }
141 qr/\Qquux > 5 has been deprecated/,
142 'got a warning for quux(10)';
149 use Package::DeprecationManager -deprecations => {
150 'Dep::foo' => '1.00',
152 -ignore => [ 'My::Package1', 'My::Package2' ];
155 deprecated('foo is deprecated');
162 use Package::DeprecationManager -deprecations => {
163 'Dep2::bar' => '1.00',
165 -ignore => [ qr/My::Package[12]/ ];
168 deprecated('bar is deprecated');
173 package My::Package1;
175 sub foo { Dep::foo() }
176 sub bar { Dep2::bar() }
180 package My::Package2;
182 sub foo { My::Package1::foo() }
183 sub bar { My::Package1::bar() }
189 ::stderr_like{ My::Package2::foo() }
190 qr/^foo is deprecated at t.basic\.t line \d+\s+My::Baz/,
191 'deprecation warning for call to My::Package2::foo() and mentions My::Baz but not My::Package[12]';
193 ::stderr_is{ My::Package2::foo() }
195 'no deprecation warning for second call to My::Package2::foo()';
197 ::stderr_is{ My::Package1::foo() }
199 'no deprecation warning for call to My::Package1::foo()';
201 ::stderr_like{ My::Package2::bar() }
202 qr/^bar is deprecated at t.basic\.t line \d+\s+My::Baz/,
203 'deprecation warning for call to My::Package2::foo() and mentions My::Baz but not My::Package[12]';
205 ::stderr_is{ My::Package2::bar() }
207 'no deprecation warning for second call to My::Package2::bar()';
213 ::stderr_like{ My::Package1::foo() }
214 qr/^foo is deprecated at t.basic\.t line \d+\s+My::Quux/,
215 'deprecation warning for call to My::Package1::foo() and mentions My::Quux but not My::Package[12]';
217 ::stderr_is{ My::Package1::foo() }
219 'no deprecation warning for second call to My::Package1::foo()';