testing

Dave Cross dave at dave.org.uk
Mon Nov 3 14:36:15 GMT 2008


Dominic Thoreau wrote:
> 2008/11/3 Christopher Jones <c.jones at ucl.ac.uk>:

[ snip ]

>> #!/usr/bin/perl -w
>> use strict;
>>
>> use Test::More tests => 2;
>>
>> BEGIN {
>>        use_ok('My::Module');    # contains a package called 'my_mod'
>> };

[ snip ]

> I think (off the top of my head, and I haven't used any of the Test::*
> modules), but it's at least possible that because you put an enclosure
> around the use_ok call, that the code in that file isn't available to
> anything outside that block.

Hmmm... maybe you should have, at least, skimmed the docs for Test::More
before sending this mail.

>From the Synopsis:

  BEGIN { use_ok( 'Some::Module' ); }

>From the discussion of use_ok:

  It's recommended that you run use_ok() inside a BEGIN block so its
  functions are exported at compile-time and prototypes are properly
  honored.

> Scope is always useful once you understand it - but can be nasty when you don't.

No comment :)

> 'Course I could be wrong.....

You could...

Cheers,

Dave...


More information about the london.pm mailing list