package Foo;
use Package::DeprecationManager -deprecations => {
- 'Foo::foo' => '0.02',
- 'Foo::bar' => '0.03',
- 'Foo::baz' => '1.21',
+ 'Foo::foo' => '0.02',
+ 'Foo::bar' => '0.03',
+ 'Foo::baz' => '1.21',
+ 'not a sub' => '1.23',
};
sub foo {
sub baz {
deprecated();
}
+
+ sub quux {
+ if ( $_[0] > 5 ) {
+ deprecated(
+ message => 'quux > 5 has been deprecated',
+ feature => 'not a sub',
+ );
+ }
+ }
}
{
'no warning for baz with api_version = 0.01';
}
-
{
package Quux;
'no warning for baz with api_version = 1.17';
}
+{
+ package Another;
+
+ Foo->import();
+
+ ::warning_is{ Foo::quux(1) }
+ q{},
+ 'no warning for quux(1)';
+
+ ::warning_is{ Foo::quux(10) }
+ { carped => 'quux > 5 has been deprecated' },
+ 'got a warning for quux(10)';
+}
+
+
+{
+ package Dep;
+
+ use Package::DeprecationManager -deprecations => {
+ 'foo' => '1.00',
+ },
+ -ignore => [ 'My::Foo', 'My::Bar' ];
+
+ sub foo {
+ deprecated('foo is deprecated');
+ }
+}
+
+{
+ package My::Foo;
+
+ sub foo { Dep::foo() }
+}
+
+{
+ package My::Bar;
+
+ sub foo { My::Foo::foo() }
+}
+
+{
+ package My::Baz;
+
+ ::warning_like{ My::Bar::foo() }
+ qr/^foo is deprecated at t.basic\.t line \d+/,
+ 'deprecation warning for call to My::Bar::foo()';
+}
+
+{
+ package My::Baz;
+
+ Dep->import( -api_version => '0.8' );
+
+ ::warning_is{ My::Bar::foo() }
+ q{},
+ 'no wanrning when calling My::Bar::foo()';
+}
+
done_testing();