Changes for 0.04
[gitmo/Package-DeprecationManager.git] / t / basic.t
index 9fadb79..5c48e63 100644 (file)
--- a/t/basic.t
+++ b/t/basic.t
@@ -18,9 +18,10 @@ use Test::Warn;
     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 {
@@ -34,6 +35,15 @@ use Test::Warn;
     sub baz {
         deprecated();
     }
+
+    sub quux {
+        if ( $_[0] > 5 ) {
+            deprecated(
+                message => 'quux > 5 has been deprecated',
+                feature => 'not a sub',
+            );
+        }
+    }
 }
 
 {
@@ -78,7 +88,6 @@ use Test::Warn;
         'no warning for baz with api_version = 0.01';
 }
 
-
 {
     package Quux;
 
@@ -97,4 +106,62 @@ use Test::Warn;
         '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();