develooper Front page | perl.qa | Postings from January 2009

Re: numeric plans - feature or symptom?

From:
David E. Wheeler
Date:
January 23, 2009 10:39
Subject:
Re: numeric plans - feature or symptom?
Message ID:
6474587D-22FF-4597-BA80-5066C09C3D81@kineticode.com
On Jan 23, 2009, at 10:18 AM, Fergal Daly wrote:

> With nesting, you can move some aspects of the plan closer to the code
> (which is good) but you must always have some part of the plan far
> enough away from the code so that it is not subject to the same bugs.
> Ideally something like this would work
>
> plan(3);
>
> test1();
> test2();
> ok(1)
>
> sub test1 {
>  plan(2);
>  ok(1)
>  ok(2);
> }
>
> sub test1 {
>  plan(5);
>  for $i (1..5) {
>    ok($i)
>  }
> }
>
> But that requires some magic to detect the end of the block so it
> would have to look a little different. It also requires nested TAP. In
> this example plan(x) means that the total number of tests and blocks
> of tests should sum to x.

Hey Fergal, check out Test::Block. It's not far from this and works  
today.

Best,

David



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About