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 <publiustemp-perl...@yahoo.com> > To: "sidhe...@allverden.no" <sidhe...@allverden.no>; "perl-qa@perl.org" > <perl-qa@perl.org> > Cc: > Sent: Wednesday, 11 April 2012, 16:22 > Subject: Re: Revert use_ok() change to allow lexical effects? > > ----- Original Message ----- > >> From: The Sidhekin <sidhe...@allverden.no> > > >> * 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/ >