(OT) Re: S/SA/SAPER/relative-0.02.tar.gz (feature request)

2007-10-09 Thread Ovid
--- Jonathan Rockway [EMAIL PROTECTED] wrote:

 OT, but 'ok.pm' is quite nice:
 
use Test::More tests = 1;
use ok 'My::Module'; # test runs at compile time

Oh, I really like that, but it still causes an issue for me.  You see,
a lot of what I do is stuff like this:

  my $CLASS;
  BEGIN {
  $CLASS = 'Customer';
  use_ok $CLASS or die;
  }

  can_ok $CLASS, 'new';
  ok my $cust = $CLASS-new, '... and we can call it';
  isa_ok $cust, $CLASS, '... and the object it returns';

This means that if I need to refactor classes to better namespaces, I
merely change the $CLASS = line.  With the lovely ok.pm module, I
still have the following clunky construct:

  my $CLASS;
  BEGIN {
  $CLASS = 'Customer';
  }
  use ok $CLASS or die;

  can_ok $CLASS, 'new';
  ok my $cust = $CLASS-new, '... and we can call it';
  isa_ok $cust, $CLASS, '... and the object it returns';

Those BEGIN blocks really annoy the hell out of me at times :(

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/


Re: (OT) Re: S/SA/SAPER/relative-0.02.tar.gz (feature request)

2007-10-09 Thread Smylers
Ovid writes:

 With the lovely ok.pm module, I still have the following clunky
 construct:
 
   my $CLASS;
   BEGIN {
   $CLASS = 'Customer';
   }
   use ok $CLASS or die;
 
   can_ok $CLASS, 'new';
   ok my $cust = $CLASS-new, '... and we can call it';
   isa_ok $cust, $CLASS, '... and the object it returns';
 
 Those BEGIN blocks really annoy the hell out of me at times :(

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';

Smylers


Re: (OT) Re: S/SA/SAPER/relative-0.02.tar.gz (feature request)

2007-10-09 Thread A. Pagaltzis
* Smylers [EMAIL PROTECTED] [2007-10-09 10:25]:
 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';

Sneaky! I like.
-- 
*AUTOLOAD=*_;sub _{s/(.*)::(.*)/print$2,(,$\/, )[defined wantarray]/e;$1}
Just-another-Perl-hack;
#Aristotle