--- Smylers <[EMAIL PROTECTED]> wrote:

> Well don't have them then -- put the assignment in the use statement,
> which is run at BEGIN time anyway:
> 
>   use Test::More tests => 1;
>   my $CLASS;
>   use ok $CLASS = 'DateTime';

That gets closer, but how do you then express the 'or die' semantics? 
If 'DateTime' or some other class could not be used, the test program
keeps running.  You can't just:

  use ok $CLASS = 'My::Class' or die;

That's not valid Perl, but I just realized the obvious fix of
'constant' or 'Readonly':

  use Test::More 'no_plan';
  use constant CLASS => 'My::Customer';
  BEGIN { use_ok CLASS or die }

Though smylers just thought of 'or_die' (we work in the same office):

  use Test::More 'no_plan';
  use constant CLASS => 'My::Customer';
  use     or_die CLASS;
  require or_die CLASS;

That would be a strange package name for a testing module, but hey ...

Cheers,
Ovid

--
Buy the book  - http://www.oreilly.com/catalog/perlhks/
Perl and CGI  - http://users.easystreet.com/ovid/cgi_course/
Personal blog - http://publius-ovidius.livejournal.com/
Tech blog     - http://use.perl.org/~Ovid/journal/

Reply via email to