Test::Builder tickles Pod::Html parsing stupidity bug
[p5sagit/p5-mst-13.2.git] / lib / Test / Tutorial.pod
index bd5b91d..b730918 100644 (file)
@@ -137,8 +137,8 @@ So now you'd see...
 =head2 Test the manual
 
 Simplest way to build up a decent testing suite is to just test what
-the manual says it does. [3] Let's pull something out of the
-L<Date::ICal/SYNOPSIS> and test that all it's bits work.
+the manual says it does. [3] Let's pull something out of the 
+L<Date::ICal/SYNOPSIS> and test that all its bits work.
 
     #!/usr/bin/perl -w
 
@@ -174,7 +174,7 @@ run that and you get:
     # Looks like you failed 1 tests of 8.
 
 Whoops, a failure! [4] Test::Simple helpfully lets us know on what line
-the failure occured, but not much else.  We were supposed to get 17,
+the failure occurred, but not much else.  We were supposed to get 17,
 but we didn't.  What did we get??  Dunno.  We'll have to re-run the
 test in the debugger or throw in some print statements to find out.
 
@@ -298,8 +298,23 @@ C<%ICal_Dates>.  Now that it's less work to test with more dates, you'll
 be inclined to just throw more in as you think of them.
 Only problem is, every time we add to that we have to keep adjusting
 the C<use Test::More tests =E<gt> ##> line.  That can rapidly get
-annoying.  Instead we use C<no_plan>.  This means we're just running
-some tests, don't know how many. [6]
+annoying.  There's two ways to make this work better.
+
+First, we can calculate the plan dynamically using the C<plan()>
+function.
+
+    use Test::More;
+    use Date::ICal;
+
+    my %ICal_Dates = (
+        ...same as before...
+    );
+
+    # For each key in the hash we're running 8 tests.
+    plan tests => keys %ICal_Dates * 8;
+
+Or to be even more flexible, we use C<no_plan>.  This means we're just
+running some tests, don't know how many. [6]
 
     use Test::More 'no_plan';   # instead of tests => 32
 
@@ -436,6 +451,7 @@ Thumbing through the Date::ICal man page, I came across this:
 the date in the Date::ICal test suite.  So I'll write one.
 
     use Test::More tests => 1;
+    use Date::ICal;
 
     my $ical = Date::ICal->new;
     $ical->ical('20201231Z');
@@ -486,7 +502,7 @@ C<local $TODO> and turn it into a real test.
 =head2 Testing with taint mode.
 
 Taint mode is a funny thing.  It's the globalest of all global
-features.  Once you turn it on it effects I<all> code in your program
+features.  Once you turn it on, it affects I<all> code in your program
 and I<all> modules used (and all the modules they use).  If a single
 piece of code isn't taint clean, the whole thing explodes.  With that
 in mind, it's very important to ensure your module works under taint
@@ -498,8 +514,6 @@ in C<#!> and use them to run your tests.
 
     #!/usr/bin/perl -Tw
 
-    use Test::More 'no_plan';
-
     ...test normally here...
 
 So when you say C<make test> it will be run with taint mode and