perl-docs-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject cvs commit: modperl-docs/src/devel/writing_tests writing_tests.pod
Date Mon, 24 Dec 2001 05:47:46 GMT
stas        01/12/23 21:47:46

  Modified:    src/devel/writing_tests writing_tests.pod
  - update the docs for skip_unless
  Revision  Changes    Path
  1.24      +28 -8     modperl-docs/src/devel/writing_tests/writing_tests.pod
  Index: writing_tests.pod
  RCS file: /home/cvs/modperl-docs/src/devel/writing_tests/writing_tests.pod,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- writing_tests.pod	2001/12/05 08:10:37	1.23
  +++ writing_tests.pod	2001/12/24 05:47:46	1.24
  @@ -973,16 +973,36 @@
   =item * skip_unless()
  -Instead of using a scalar as a last argument to plan() to tell whether
  -to skip the test or not, it's better to use skip_unless() which also
  -prints the reason for skipping the test if the condition is not
  -satisfied. For example:
  +Alternatively to specifying a last argument for plan(), the
  +skip_unless() function can be called before plan(), to decide whether
  +to skip the whole test or not. plan() won't be reached if skip_unless
  +decides to skip the test.
  -  plan tests => 5, skip_unless(sub { $a == $b }, "$a != $b");
  +skip_unless()'s argument is a list of things to test. The list can
  +include scalars, which are passed to have_module(), and hash
  +references. The hash references have a condition code reference as a
  +key and a reason for failure as a value. The condition code is run and
  +if it fails the provided reason is used to tell user why the test was
  -skip_unless() executes the code reference in the first argument and if
  -it returns a false value C<$reason> gets printed as a reason for test
  +For example:
  +  skip_unless({sub {$a==$b} => "$a != $b!"
  +               sub {$a==1}  => "$a != 1!"},
  +              'LWP',
  +              'cgi_d',
  +               {sub {0} => "forced to be skipped"},
  +             );
  +  plan tests => 5;
  +In this example, the first argument is a hash reference which includes
  +two pairs of condition test functions and the corresponding reasons,
  +the second and the third arguments are scalars passed to have_module()
  +and the last argument is another hash reference with a single
  +condition. This is just to demonstrate that you can supply conditions
  +in various syntaxes without particular order. If any of the
  +requirements from this list fail, plan() won't be called since
  +skip_unless() will call exit().
   =item * have_module()

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message