10 eval 'package Foo; use Package::DeprecationManager;';
13 qr/^\QYou must provide a hash reference -deprecations parameter when importing Package::DeprecationManager/,
14 'must provide a set of deprecations when using Package::DeprecationManager';
20 use Package::DeprecationManager -deprecations => {
24 'not a sub' => '1.23',
28 deprecated('foo is deprecated');
32 deprecated('bar is deprecated');
42 message => 'quux > 5 has been deprecated',
43 feature => 'not a sub',
54 ::warning_is{ Foo::foo() }
55 { carped => 'foo is deprecated' },
56 'deprecation warning for foo';
58 ::warning_is{ Foo::bar() }
59 { carped => 'bar is deprecated' },
60 'deprecation warning for bar';
62 ::warning_is{ Foo::baz() }
63 { carped => 'Foo::baz has been deprecated since version 1.21' },
64 'deprecation warning for baz, and message is generated by Package::DeprecationManager';
66 ::warning_is{ Foo::foo() } q{}, 'no warning on second call to foo';
68 ::warning_is{ Foo::bar() } q{}, 'no warning on second call to bar';
70 ::warning_is{ Foo::baz() } q{}, 'no warning on second call to baz';
76 Foo->import( -api_version => '0.01' );
78 ::warning_is{ Foo::foo() }
80 'no warning for foo with api_version = 0.01';
82 ::warning_is{ Foo::bar() }
84 'no warning for bar with api_version = 0.01';
86 ::warning_is{ Foo::baz() }
88 'no warning for baz with api_version = 0.01';
94 Foo->import( -api_version => '1.17' );
96 ::warning_is{ Foo::foo() }
97 { carped => 'foo is deprecated' },
98 'deprecation warning for foo with api_version = 1.17';
100 ::warning_is{ Foo::bar() }
101 { carped => 'bar is deprecated' },
102 'deprecation warning for bar with api_version = 1.17';
104 ::warning_is{ Foo::baz() }
106 'no warning for baz with api_version = 1.17';
114 ::warning_is{ Foo::quux(1) }
116 'no warning for quux(1)';
118 ::warning_is{ Foo::quux(10) }
119 { carped => 'quux > 5 has been deprecated' },
120 'got a warning for quux(10)';