diff options
author | Michael G. Schwern <schwern@pobox.com> | 2001-08-30 13:02:08 -0400 |
---|---|---|
committer | Abhijit Menon-Sen <ams@wiw.org> | 2001-08-30 23:53:23 +0000 |
commit | 812f512702be7ee71d2a1fb4afd0eb7fe7545d6c (patch) | |
tree | b62db5f7e6dc2de28414809011dadecac55ce328 /pod/perlhack.pod | |
parent | e2c88acc9eb721d9206fdbfa8f5977ae2ccaa3c1 (diff) | |
download | perl-812f512702be7ee71d2a1fb4afd0eb7fe7545d6c.tar.gz |
Yet another improvement to the
patching example
Message-Id: <20010830170208.M2318@blackrider>
p4raw-id: //depot/perl@11795
Diffstat (limited to 'pod/perlhack.pod')
-rw-r--r-- | pod/perlhack.pod | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/pod/perlhack.pod b/pod/perlhack.pod index 5aff68e492..b83fbd0be5 100644 --- a/pod/perlhack.pod +++ b/pod/perlhack.pod @@ -1481,13 +1481,10 @@ write one easily. my $test = 1; sub ok { - my($ok) = @_; + my($ok, $name) = @_; # You have to do it this way or VMS will get confused. - my $out = ''; - $out = "not " unless $ok; - $out .= "ok $test\n"; - print $out; + print $ok ? "ok $test - $name\n" : "not ok $test - $name\n"; printf "# Failed test at line %d\n", (caller)[2] unless $ok; @@ -1502,16 +1499,19 @@ so instead of this: we can write the (somewhat) more sensible: - ok( "1.20.300.4000" eq sprintf "%vd", pack("U*",1,20,300,4000) ); + 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: - ok( "1.20.300.4000" eq sprintf "%vd", pack(" U*",1,20,300,4000) ); + 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: - ok( v1.20.300.4000 ne sprintf "%vd", pack("C0U*",1,20,300,4000) ); + 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: |