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

Ovid <[email protected]>
Newsgroups gmane.comp.lang.perl.quality-assurance
Message-ID <[email protected]>
----- 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.