I will never get used to mailing lists that don't default to "reply
all"...
Begin forwarded message:
From: Joe McMahon <[EMAIL PROTECTED]>
Date: July 21, 2006 11:43:31 AM PDT
To: A. Pagaltzis <[EMAIL PROTECTED]>
Subject: Re: Test::More, BEGIN use_ok, plan, what?
On Jul 21, 2006, at 9:50 AM, 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.
That's correct; since the "plan" is invoked separately, the BEGIN
block's already long gone by the time "plan" executes. Putting the
plan on the "use Test::More" would fix this.
Sure looks like a bug.
Dunno whether it's a doc bug or a real one, though. Maybe the
use_ok should barf if no plan's in place yet (whether it's a real
plan or no_plan).
--- Joe M.