develooper Front page | perl.qa | Postings from April 2012

Re: Revert use_ok() change to allow lexical effects?

Thread Previous | Thread Next
From:
Andy Lester
Date:
April 11, 2012 09:39
Subject:
Re: Revert use_ok() change to allow lexical effects?
Message ID:
FDED1FFE-D201-464D-A45C-573FEFBB0609@petdance.com

On Apr 11, 2012, at 11:33 AM, Michael G Schwern wrote:

> It's a convenience function so it can be more easily understood what's going
> on and we don't each write it a million different ways.  require_ok() solves a
> big chunk of the problem.
> 
>    if( something something ) {
>        use_ok 'Foo';

So in these cases, we're using it basically as an eval block, because a simple "use Foo" would be bad.

What it sounds to me like is: "If all you're testing is that the module loads, and it must always, then simply do a use and do without the use_ok()".

In this example:

BEGIN {
    use_ok( 'App::Ack' );
    use_ok( 'App::Ack::Repository' );
    use_ok( 'App::Ack::Resource' );
    use_ok( 'File::Next' );
}
diag( "Testing App::Ack $App::Ack::VERSION, File::Next $File::Next::VERSION, Perl $], $^X" );

it sounds like we're saying that the use_ok() doesn't help at all, and I might as well write

use App::Ack;
use App::Ack::Repository;
use App::Ack::Resource;
use File::Next;
diag( "Testing App::Ack $App::Ack::VERSION, File::Next $File::Next::VERSION, Perl $], $^X" );

Agreed?

xoa

--
Andy Lester => andy@petdance.com => www.petdance.com => AIM:petdance


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About