use Test::More;
        pass();
        plan tests => 2;
        pass();

Why shouldn't this work?  Currently you get a "You tried to run a test without
a plan" error, but what is it really protecting the test author from?

Historically, there was a clear technical reason.  It used to be that the plan
had to come first in the TAP output, so a plan had to come before any tests
were run.  Simple.

But that technical restriction no longer holds true.  The plan can come at the
end, primarily used for "no_plan".  If a test is run before the plan is
declared, simply delay the plan output until the end.

Removing this restriction eliminates some unnecessarily difficult planing
problems, especially of the annoying "the plan is calculated but I have to run
some tests at BEGIN time".  Like this common mistake:

        use Test::More;

        if( $something ) {
                plan tests => 1;
        }
        else {
                plan skip_all => "Because";
        }

        BEGIN { use_ok "Some::Module" }

It also allows you to run some tests before you determine the plan, though I
can't think of a particular use for this.

It also makes it technically possible to allow the test to change it's plan
mid-stream, though the consequences and interface for that do require some
thought.

Since the technical restriction is gone, and I see no particular benefit to it
being there, and it eliminates some tricky plan counting situations, I don't
see why it shouldn't be removed.


PS  To be clear, a plan is still eventually needed before the test exits.


-- 
The interface should be as clean as newly fallen snow and its behavior
as explicit as Japanese eel porn.

Reply via email to