On Thu, Apr 05, 2001 at 10:10:47PM +0100, Michael G Schwern wrote:
> > Then it might be easier to write modules that are testable without a test
> > driver.  If you run the module directly, some distinguished block of code
> > could be executed that wouldn't be if the module were "included" via
> > "require" or "use" (or similar replacement constructs).
> 
> See also SelfTest.pm

I have not looked at SelfTest, but I have always done this with

unless (defined wantarray) {
  # Self Test
}

This works because whenever a file is use'd, require'd etc. it is
evaluated in a scalar context. The main file is in a void context.

Graham.

Reply via email to