Hi Michael, * Michael G Schwern <[EMAIL PROTECTED]> [2007-12-04 03:35]: > 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.
Yes, so this should be allowed: pass(); plan 'no_plan'; pass(); Whereas this should not: pass(); plan tests => 2; pass(); So the error would be deferred from the first assertion run to the `plan` invocation. Consider also: pass(); plan skip_all => 'Surprise!'; pass(); > It also makes it technically possible to allow the test to > change it's plan mid-stream Without some hypothetical future version of TAP this is only possible if you have run tests before declaring a plan at all, because otherwise the plan will already have been output as the first line of the TAP stream. > 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. Because declaring a plan after running tests is effectively a no_plan and the programmer should be aware that that’s what they did. It’s fine if that’s their conscious choice; just make sure it was. Regards, -- Aristotle Pagaltzis // <http://plasmasturm.org/>