Document the changes with regards to running of END blocks.
[p5sagit/p5-mst-13.2.git] / pod / perlhack.pod
index 629f4d5..b83fbd0 100644 (file)
@@ -1471,26 +1471,47 @@ we must document that change. We must also provide some more regression
 tests to make sure our patch works and doesn't create a bug somewhere
 else along the line.
 
-The regression tests for each operator live in F<t/op/>, and so we make
-a copy of F<t/op/pack.t> to F<t/op/pack.t~>. Now we can add our tests
-to the end. First, we'll test that the C<U> does indeed create Unicode
-strings:
+The regression tests for each operator live in F<t/op/>, and so we
+make a copy of F<t/op/pack.t> to F<t/op/pack.t~>. Now we can add our
+tests to the end. First, we'll test that the C<U> does indeed create
+Unicode strings.  
+
+t/op/pack.t has a sensible ok() function, but if it didn't we could
+write one easily.
+
+    my $test = 1;
+    sub ok {
+        my($ok, $name) = @_;
+
+        # You have to do it this way or VMS will get confused.
+        print $ok ? "ok $test - $name\n" : "not ok $test - $name\n";
+
+        printf "# Failed test at line %d\n", (caller)[2] unless $ok;
+
+        $test++;
+        return $ok;
+    }
+
+so instead of this:
 
  print 'not ' unless "1.20.300.4000" eq sprintf "%vd", pack("U*",1,20,300,4000);
  print "ok $test\n"; $test++;
 
+we can write the (somewhat) more sensible:
+
+ ok( "1.20.300.4000" eq sprintf "%vd", pack("U*",1,20,300,4000), 
+                                       "U* produces unicode" );
+
 Now we'll test that we got that space-at-the-beginning business right:
 
- print 'not ' unless "1.20.300.4000" eq
-                     sprintf "%vd", pack("  U*",1,20,300,4000);
- print "ok $test\n"; $test++;
+ ok( "1.20.300.4000" eq sprintf "%vd", pack("  U*",1,20,300,4000),
+                                       "  with spaces at the beginning" );
 
 And finally we'll test that we don't make Unicode strings if C<U> is B<not>
 the first active format:
 
- print 'not ' unless v1.20.300.4000 ne
-                     sprintf "%vd", pack("C0U*",1,20,300,4000);
- print "ok $test\n"; $test++;
+ ok( v1.20.300.4000 ne  sprintf "%vd", pack("C0U*",1,20,300,4000),
+                                       "U* not first isn't unicode" );
 
 Mustn't forget to change the number of tests which appears at the top, or
 else the automated tester will get confused: