----- Original Message ----
From: Geoffrey Young <[EMAIL PROTECTED]>

> so, the compile test failed, but bar() could still be called and, in
> fact, even executed successfully.


Hi Geoff,

You've run into a problem which surprises a few folks but definitely causes 
problems.  In a nutshell, use_ok internally traps the "use" call with an eval.  
However, even if it fails (as in your case), the bytecode might still be 
compiled and in memory and, as a result, some tests might pass and others fail. 
 As a result, *all* of my tests generally start with something similar to the 
following (season to test):

  my $CLASS;
  BEGIN {
      $CLASS = 'Some::Module';
      use_ok $CLASS or die; # "or die" saves the day
  }
  can_ok $CLASS, 'new';

This prevents the error you received.  Part of the reason I started doing that 
is I once had a use_ok test fail but I had so many intervening tests pass that 
this scrolled off the screen by the time I got down to my failing tests.  It 
took me a long time of debugging and calling over other coworkers before 
someone spotted that the use_ok was failing.

Cheers,
Ovid
 
-- If this message is a response to a question on a mailing list, please send 
follow up questions to the list.
 
Web Programming with Perl -- http://users.easystreet.com/ovid/cgi_course/

Reply via email to