Merge commit 'origin/master'
[gitmo/Moose.git] / t / 050_metaclasses / 012_moose_exporter.t
index 612196d..0389fd4 100644 (file)
@@ -7,11 +7,11 @@ use Test::More;
 use Test::Exception;
 
 BEGIN {
-    unless ( eval 'use Test::Warn; 1' )  {
-        plan skip_all => 'These tests require Test::Warn';
+    unless ( eval 'use Test::Warn 0.11; 1' )  {
+        plan skip_all => 'These tests require Test::Warn 0.11';
     }
     else {
-        plan tests => 40;
+        plan tests => 45;
     }
 }
 
@@ -214,7 +214,7 @@ BEGIN {
 
     ::like(
         $@,
-        qr/\QCircular reference in also parameter to MooseX::Exporter between MooseX::CircularAlso and MooseX::CircularAlso/,
+        qr/\QCircular reference in also parameter to Moose::Exporter between MooseX::CircularAlso and MooseX::CircularAlso/,
         'got the expected error from circular reference in also'
     );
 }
@@ -235,7 +235,42 @@ BEGIN {
 
     ::like(
         $@,
-        qr/\QPackage in also (NoSuchThing) does not seem to use MooseX::Exporter/,
+        qr/\QPackage in also (NoSuchThing) does not seem to use Moose::Exporter/,
         'got the expected error from a reference in also to a package which does not use Moose::Exporter'
     );
 }
+
+{
+    package MooseX::OverridingSugar;
+
+    use Moose ();
+
+    sub has {
+        my $caller = shift;
+        return $caller . ' called has';
+    }
+
+    Moose::Exporter->setup_import_methods(
+        with_caller => ['has'],
+        also        => 'Moose',
+    );
+}
+
+{
+    package WantsOverridingSugar;
+
+    MooseX::OverridingSugar->import();
+
+    ::can_ok( 'WantsOverridingSugar', 'has' );
+    ::can_ok( 'WantsOverridingSugar', 'with' );
+    ::is( has('foo'), 'WantsOverridingSugar called has',
+          'has from MooseX::OverridingSugar is called, not has from Moose' );
+
+    MooseX::OverridingSugar->unimport();
+}
+
+{
+    ok( ! WantsSugar->can('has'),  'WantsSugar::has() has been cleaned' );
+    ok( ! WantsSugar->can('with'), 'WantsSugar::with() has been cleaned' );
+}
+