home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3 / perl5 / Test.z / Test
Encoding:
Text File  |  2002-10-03  |  4.3 KB  |  133 lines

  1.  
  2.  
  3.  
  4. TTTTeeeesssstttt((((3333))))                                                                TTTTeeeesssstttt((((3333))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.        Test - provides a simple framework for writing test scripts
  10.  
  11.  
  12. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  13.        use strict;
  14.        use Test;
  15.        BEGIN { plan tests => 13, todo => [3,4] }
  16.  
  17.        ok(0); # failure
  18.        ok(1); # success
  19.  
  20.        ok(0); # ok, expected failure (see todo list, above)
  21.        ok(1); # surprise success!
  22.  
  23.        ok(0,1);             # failure: '0' ne '1'
  24.        ok('broke','fixed'); # failure: 'broke' ne 'fixed'
  25.        ok('fixed','fixed'); # success: 'fixed' eq 'fixed'
  26.  
  27.        ok(sub { 1+1 }, 2);  # success: '2' eq '2'
  28.        ok(sub { 1+1 }, 3);  # failure: '2' ne '3'
  29.        ok(0, int(rand(2));  # (just kidding! :-)
  30.  
  31.        my @list = (0,0);
  32.        ok @list, 3, "\@list=".join(',',@list);      #extra diagnostics
  33.        ok 'segmentation fault', '/(?i)success/';    #regex match
  34.  
  35.        skip($feature_is_missing, ...);    #do platform specific test
  36.  
  37.  
  38. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  39.      Test::Harness expects to see particular output when it executes tests.
  40.      This module aims to make writing proper test scripts just a little bit
  41.      easier (and less error prone :-).
  42.  
  43. TTTTEEEESSSSTTTT TTTTYYYYPPPPEEEESSSS
  44.      +o NORMAL TESTS
  45.          These tests are expected to succeed.  If they don't, something's
  46.          screwed up!
  47.  
  48.      +o SKIPPED TESTS
  49.          Skip tests need a platform specific feature that might or might not
  50.          be available.  The first argument should evaluate to true if the
  51.          required feature is NOT available.  After the first argument, skip
  52.          tests work exactly the same way as do normal tests.
  53.  
  54.      +o TODO TESTS
  55.          TODO tests are designed for maintaining an executable TODO list.
  56.          These tests are expected NOT to succeed (otherwise the feature they
  57.          test would be on the new feature list, not the TODO list).
  58.  
  59.          Packages should NOT be released with successful TODO tests.  As soon
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. TTTTeeeesssstttt((((3333))))                                                                TTTTeeeesssstttt((((3333))))
  71.  
  72.  
  73.  
  74.          as a TODO test starts working, it should be promoted to a normal test
  75.          and the newly minted feature should be documented in the release
  76.          notes.
  77.  
  78. OOOONNNNFFFFAAAAIIIILLLL
  79.        BEGIN { plan test => 4, onfail => sub { warn "CALL 911!" } }
  80.  
  81.      The test failures can trigger extra diagnostics at the end of the test
  82.      run.  onfail is passed an array ref of hash refs that describe each test
  83.      failure.  Each hash will contain at least the following fields:  package,
  84.      repetition, and result.  (The file, line, and test number are not
  85.      included because their correspondance to a particular test is fairly
  86.      weak.)  If the test had an expected value or a diagnostic string, these
  87.      will also be included.
  88.  
  89.      This optional feature might be used simply to print out the version of
  90.      your package and/or how to report problems.  It might also be used to
  91.      generate extremely sophisticated diagnostics for a particular test
  92.      failure.  It's not a panacea, however.  Core dumps or other unrecoverable
  93.      errors will prevent the onfail hook from running.  (It is run inside an
  94.      END block.)  Besides, onfail is probably over-kill in the majority of
  95.      cases.  (Your test code should be simpler than the code it is testing,
  96.      yes?)
  97.  
  98. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  99.      the _T_e_s_t::_H_a_r_n_e_s_s manpage and various test coverage analysis tools.
  100.  
  101. AAAAUUUUTTTTHHHHOOOORRRR
  102.      Copyright (C) 1998 Joshua Nathaniel Pritikin.  All rights reserved.
  103.  
  104.      This package is free software and is provided "as is" without express or
  105.      implied warranty.  It may be used, redistributed and/or modified under
  106.      the terms of the Perl Artistic License (see
  107.      http://www.perl.com/perl/misc/Artistic.html)
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.