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

Ovid <[email protected]>
Newsgroups gmane.comp.lang.perl.quality-assurance
Message-ID <[email protected]>
Or more simply:

    use Test::More tests => 1;

    my $ok;
    END { BAIL_OUT "Could not load all modules" unless $ok }
    use Test::Trap::Builder::TempFile;                                                                                                            
    use Test::Trap::Builder::SystemSafe;
    use Test::Trap::Builder;
    use Test::Trap;
    use if eval "use PerlIO; 1", 'Test::Trap::Builder::PerlIO';
    ok 1, 'All modules loaded successfully';
    $ok = 1;

Cheers,
Ovid
--
Live and work overseas - http://www.overseas-exile.com/
Buy the book           - http://www.oreilly.com/catalog/perlhks/
Tech blog              - http://blogs.perl.org/users/ovid/
Twitter                - http://twitter.com/OvidPerl/


----- Original Message -----
> From: Ovid <[email protected]>
> To: "[email protected]" <[email protected]>; "[email protected]" <[email protected]>
> Cc: 
> Sent: Wednesday, 11 April 2012, 16:22
> Subject: Re: Revert use_ok() change to allow lexical effects?
> 
> ----- Original Message -----
> 
>>  From: The Sidhekin <[email protected]>
> 
> 
>>  * How would you rewrite a test script such as my own
>>  http://cpansearch.perl.org/src/EBHANSSEN/Test-Trap-v0.2.2/t/00-load.t so
>>  that it does not use use_ok()?
>>  * Why would you? :-\
> 
> 
> Just a quick hack:
> 
>     use Test::More;                                                             
>                                                                   
> 
>     BEGIN {
>         my @modules = qw(
>           Test::Trap::Builder::TempFile
>           Test::Trap::Builder::SystemSafe
>           Test::Trap::Builder
>           Test::Trap
>         );
>         push @modules => 'Test::Trap::Builder::PerlIO' if eval 
> "use PerlIO; 1";
>         plan tests => scalar @modules;
> 
>         for my $module (@modules) {
>             eval "use $module";
>             BAIL_OUT $@ if $@;
>         }
>     }
> 
> 
> With that, you're using the actual use builtin and not worrying about extra 
> code that might or might not be obscuring problems.
> 
> Cheers,
> Ovid 
> --
> Live and work overseas - http://www.overseas-exile.com/
> Buy the book - http://www.oreilly.com/catalog/perlhks/
> Tech blog - http://blogs.perl.org/users/ovid/
> Twitter - http://twitter.com/OvidPerl/
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.