Well it's about damn time.

  use Test::More;

  pass;
  done_testing;

This now works and effectively replaces no_plan.

This works, too:

  use Test::More;

  pass;
  done_testing(1);

I was expecting it to be hard and require a lot of reworking the tests.  It
turns out it was really easy, so I feel I probably missed some edge cases.
This might also mean the coverage isn't so good.  Here's the patch for review.
http://github.com/schwern/test-more/commit/5cd0ad7c09187fd9244a0153e1fe0545acfe454e

Pay particular attention to the way done_testing() interacts with existing
plans.  For example, this is legal:

  use Test::More tests => 2;

  pass;
  pass;
  done_testing(2);

This is legal, but it's a failure:

  use Test::More tests => 2;

  pass;
  pass;
  done_testing(3);

And it produces this:

1..2
ok 1
ok 2
not ok 3 - planned to run 2 but done_testing() expects 3
#   Failed test 'planned to run 2 but done_testing() expects 3'
#   at lib/Test/More.pm line 221.
# Looks like you planned 2 tests but ran 3.
# Looks like you failed 1 test of 3 run.

An anomaly in done_testing() is expressed as an additional failed test.  For
example.

  use Test::More;

  pass;
  pass;
  done_testing();
  done_testing();

ok 1
ok 2
1..2
not ok 3 - done_testing() was already called at line 221
#   Failed test 'done_testing() was already called at line 221'
#   at lib/Test/More.pm line 221.
# Looks like you planned 2 tests but ran 3.
# Looks like you failed 1 test of 3 run.

Which is a little weird.  I'm not entirely happy with it, but it will
certainly result in a failure and its the most reliable way to produce one.

Finally, this makes it now possible to build up the test plan as you go.  I'd
like to put first order support into Test::Builder and Test::More for it, but
for the moment this will work:

  use Test::More;

  my $tests = 2;
  pass;
  pass;

  $tests += 1;
  pass;

  done_testing($tests);


-- 
40. I do not have super-powers.
    -- The 213 Things Skippy Is No Longer Allowed To Do In The U.S. Army
           http://skippyslist.com/list/

Reply via email to