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',
49 deprecated("The varies sub varies: $_[0]");
59 ::warning_is{ Foo::foo() }
60 { carped => 'foo is deprecated' },
61 'deprecation warning for foo';
63 ::warning_is{ Foo::bar() }
64 { carped => 'bar is deprecated' },
65 'deprecation warning for bar';
67 ::warning_is{ Foo::baz() }
68 { carped => 'Foo::baz has been deprecated since version 1.21' },
69 'deprecation warning for baz, and message is generated by Package::DeprecationManager';
71 ::warning_is{ Foo::foo() } q{}, 'no warning on second call to foo';
73 ::warning_is{ Foo::bar() } q{}, 'no warning on second call to bar';
75 ::warning_is{ Foo::baz() } q{}, 'no warning on second call to baz';
77 ::warning_is{ Foo::varies(1) }
78 { carped => "The varies sub varies: 1" },
79 'warning for varies sub';
81 ::warning_is{ Foo::varies(2) }
82 { carped => "The varies sub varies: 2" },
83 'warning for varies sub with different error';
85 ::warning_is{ Foo::varies(1) }
87 'no warning for varies sub with same message as first call';
93 Foo->import( -api_version => '0.01' );
95 ::warning_is{ Foo::foo() }
97 'no warning for foo with api_version = 0.01';
99 ::warning_is{ Foo::bar() }
101 'no warning for bar with api_version = 0.01';
103 ::warning_is{ Foo::baz() }
105 'no warning for baz with api_version = 0.01';
111 Foo->import( -api_version => '1.17' );
113 ::warning_is{ Foo::foo() }
114 { carped => 'foo is deprecated' },
115 'deprecation warning for foo with api_version = 1.17';
117 ::warning_is{ Foo::bar() }
118 { carped => 'bar is deprecated' },
119 'deprecation warning for bar with api_version = 1.17';
121 ::warning_is{ Foo::baz() }
123 'no warning for baz with api_version = 1.17';
131 ::warning_is{ Foo::quux(1) }
133 'no warning for quux(1)';
135 ::warning_is{ Foo::quux(10) }
136 { carped => 'quux > 5 has been deprecated' },
137 'got a warning for quux(10)';
144 use Package::DeprecationManager -deprecations => {
147 -ignore => [ 'My::Foo', 'My::Bar' ];
150 deprecated('foo is deprecated');
157 sub foo { Dep::foo() }
163 sub foo { My::Foo::foo() }
169 ::warning_like{ My::Bar::foo() }
170 qr/^foo is deprecated at t.basic\.t line \d+/,
171 'deprecation warning for call to My::Bar::foo()';
177 Dep->import( -api_version => '0.8' );
179 ::warning_is{ My::Bar::foo() }
181 'no wanrning when calling My::Bar::foo()';