On Friday 21 July 2006 19:50, A. Pagaltzis wrote: > Hi Adriano, > > * Adriano Ferreira <[EMAIL PROTECTED]> [2006-07-21 15:20]: > > If I run this script > > > > use Test::More; > > > > plan tests => 2; > > > > BEGIN { use_ok( 'My', 'foo' ); } > > > > ok(1); > > is(foo, 1); > > > > I got the output, which says nothing about the use_ok. It is > > not counted as a test, it does not ruin the plan, it does its > > job (requiring and importing a &foo subroutine). > > I assume it’s because, despite the order in the file, the BEGIN > block runs before the `plan tests => 2` line. > > Sure looks like a bug. >
I don't think that it is. Perl preprocesses the files and at compile time executes any BEGIN { ... } blocks it encounters and execute them before the rest of the program. If you want to execute the plan at the beginning either also put it in a BEGIN { ... } block, or use the "use Test::More tests => $num_tests" directive. It's not a bug - it's a feature. BTW, the "use" Perl keyword is also executed in compile time. There's some equivalent code to it in "perldoc -f use": http://perldoc.perl.org/functions/use.html Regards, Shlomi Fish --------------------------------------------------------------------- Shlomi Fish [EMAIL PROTECTED] Homepage: http://www.shlomifish.org/ Chuck Norris wrote a complete Perl 6 implementation in a day but then destroyed all evidence with his bare hands, so no one will know his secrets.