Reverse the output from _follow_also
[gitmo/Moose.git] / t / 050_metaclasses / 012_moose_exporter.t
index 98bde56..3635a8b 100644 (file)
@@ -267,11 +267,56 @@ use Test::Requires {
 }
 
 {
-    ok( ! WantsSugar->can('has'),  'WantsSugar::has() has been cleaned' );
-    ok( ! WantsSugar->can('with'), 'WantsSugar::with() has been cleaned' );
+    ok( ! WantsOverridingSugar->can('has'),  'WantsSugar::has() has been cleaned' );
+    ok( ! WantsOverridingSugar->can('with'), 'WantsSugar::with() has been cleaned' );
+}
+
+{
+    package MooseX::OverridingSugar::PassThru;
+    
+    sub with {
+        my $caller = shift->name;
+        return $caller . ' called with';
+    }
+    
+    Moose::Exporter->setup_import_methods(
+        with_meta => ['with'],
+        also      => 'MooseX::OverridingSugar',
+    );
+    
+}
+
+{
+
+    package WantsOverridingSugar::PassThru;
+
+    MooseX::OverridingSugar::PassThru->import();
+
+    ::can_ok( 'WantsOverridingSugar::PassThru', 'has' );
+    ::can_ok( 'WantsOverridingSugar::PassThru', 'with' );
+    ::is(
+        has('foo'),
+        'WantsOverridingSugar::PassThru called has',
+        'has from MooseX::OverridingSugar is called, not has from Moose'
+    );
+
+    ::is(
+        with('foo'),
+        'WantsOverridingSugar::PassThru called with',
+        'with from MooseX::OverridingSugar::PassThru is called, not has from Moose'
+    );
+
+
+    MooseX::OverridingSugar::PassThru->unimport();
+}
+
+{
+    ok( ! WantsOverridingSugar::PassThru->can('has'),  'WantsOverridingSugar::PassThru::has() has been cleaned' );
+    ok( ! WantsOverridingSugar::PassThru->can('with'), 'WantsOverridingSugar::PassThru::with() has been cleaned' );
 }
 
 {
+
     package NonExistentExport;
 
     use Moose ();