title: How can I mock -f on an object in Perl?
body: <p>I have a Perl object that has defined <code>use overload '""' =&gt; \&amp;name;</code>
  and a <code>name</code> method.</p>
  
  <p>In my unit tests I have mocked this object, including the <code>name</code> method, but code like</p>
  
  <pre><code>if (-d $object)
  </code></pre>
  
  <p>still gives me <code>Use of uninitialized value in -d ...</code>. The mocked method is not being executed. </p>
  
  <p>My mock code:</p>
  
  <pre><code>my $CMmock = Test::MockObject::Extends-&gt;new('MyClass');
  $CMmock-&gt;mock('name', sub { print "TEST!\n";});      
  $CMmock-&gt;mock('""', sub {print "TEST!\n";});
  </code></pre>
  
  <p>Other methods that I have mocked are working.</p>