]> git.vpit.fr Git - perl/modules/Test-Leaner.git/blob - README
Another POD typo
[perl/modules/Test-Leaner.git] / README
1 NAME
2     Test::Leaner - A slimmer Test::More for when you favor performance over
3     completeness.
4
5 VERSION
6     Version 0.02
7
8 SYNOPSIS
9         use Test::Leaner tests => 10_000;
10         for (1 .. 10_000) {
11          ...
12          is $one, 1, "checking situation $_";
13         }
14
15 DESCRIPTION
16     When profiling some Test::More-based test script that contained about 10
17     000 unit tests, I realized that 60% of the time was spent in
18     Test::Builder itself, even though every single test actually involved a
19     costly "eval STRING".
20
21     This module aims to be a partial replacement to Test::More in those
22     situations where you want to run a large number of simple tests. Its
23     functions behave the same as their Test::More counterparts, except for
24     the following differences :
25
26     *   Stringification isn't forced on the test operands. However, "ok"
27         honors 'bool' overloading, "is" and "is_deeply" honor 'eq'
28         overloading (and just that one) and "cmp_ok" honors whichever
29         overloading category corresponds to the specified operator.
30
31     *   "pass", "fail", "ok", "is", "isnt", "like", "unlike" and "cmp_ok"
32         are all guaranteed to return the truth value of the test.
33
34     *   "like" and "unlike" don't special case regular expressions that are
35         passed as '/.../' strings. A string regexp argument is always
36         treated as a the source of the regexp, making "like $text, $rx" and
37         "like $text, qr[$rx]" equivalent to each other and to "cmp_ok $text,
38         '=~', $rx" (and likewise for "unlike").
39
40     *   "cmp_ok" throws an exception if the given operator isn't a valid
41         Perl binary operator (except '=' and variants). It also tests in
42         scalar context, so '..' will be treated as the flip-flop operator
43         and not the range operator.
44
45     *   "is_deeply" doesn't guard for memory cycles. If the two first
46         arguments present parallel memory cycles, the test may result in an
47         infinite loop.
48
49     *   The tests don't output any kind of default diagnostic in case of
50         failure ; the rationale being that if you have a large number of
51         tests and a lot of them are failing, then you don't want to be
52         flooded by diagnostics.
53
54     *   "use_ok", "require_ok", "can_ok", "isa_ok", "new_ok", "subtest",
55         "explain", "TODO" blocks and "todo_skip" are not implemented.
56
57 ENVIRONMENT
58   "PERL_TEST_LEANER_USES_TEST_MORE"
59     If this environment variable is set, Test::Leaner will replace its
60     functions by those from Test::More. Moreover, the symbols that are
61     imported you "use Test::Leaner" will be those from Test::More, but you
62     can still only import the symbols originally defined in Test::Leaner
63     (hence the functions from Test::More that are not implemented in
64     Test::Leaner will not be imported). If your version of Test::More is too
65     old and doesn't have some symbols (like "note" or "done_testing"), they
66     will be replaced in Test::Leaner by croaking stubs.
67
68     This may be useful if your Test::Leaner-based test script fails and you
69     want extra diagnostics.
70
71 FUNCTIONS
72     The following functions from Test::More are implemented and exported by
73     default.
74
75   "plan [ tests => $count | 'no_plan' | skip_all => $reason ]"
76     See "plan" in Test::More.
77
78   "skip $reason => $count"
79     See "skip" in Test::More.
80
81   "done_testing [ $count ]"
82     See "done_testing" in Test::More.
83
84   "ok $ok [, $desc ]"
85     See "ok" in Test::More.
86
87   "pass [ $desc ]"
88     See "pass" in Test::More.
89
90   "fail [ $desc ]"
91     See "fail" in Test::More.
92
93   "is $got, $expected [, $desc ]"
94     See "is" in Test::More.
95
96   "isnt $got, $expected [, $desc ]"
97     See "isnt" in Test::More.
98
99   "like $got, $regexp_expected [, $desc ]"
100     See "like" in Test::More.
101
102   "unlike $got, $regexp_expected, [, $desc ]"
103     See "unlike" in Test::More.
104
105   "cmp_ok $got, $op, $expected [, $desc ]"
106     See "cmp_ok" in Test::More.
107
108   "is_deeply $got, $expected [, $desc ]"
109     See "is_deeply" in Test::More.
110
111   "diag @text"
112     See "diag" in Test::More.
113
114   "note @text"
115     See "note" in Test::More.
116
117   "BAIL_OUT [ $desc ]"
118     See "BAIL_OUT" in Test::More.
119
120     Test::Leaner also provides some functions of its own, which are never
121     exported.
122
123   "tap_stream [ $fh ]"
124     Read/write accessor for the filehandle to which the tests are outputted.
125     On write, it also turns autoflush on onto $fh.
126
127     Note that it can only be used as a write accessor before you start any
128     thread, as threads::shared cannot reliably share filehandles.
129
130     Defaults to "STDOUT".
131
132   "diag_stream [ $fh ]"
133     Read/write accessor for the filehandle to which the diagnostics are
134     printed. On write, it also turns autoflush on onto $fh.
135
136     Just like "tap_stream", it can only be used as a write accessor before
137     you start any thread, as threads::shared cannot reliably share
138     filehandles.
139
140     Defaults to "STDERR".
141
142   "THREADSAFE"
143     This constant evaluates to true if and only if Test::Leaner is
144     thread-safe, i.e. when this version of "perl" is at least 5.8, has been
145     compiled with "useithreads" defined, and threads has been loaded before
146     Test::Leaner. In that case, it also needs a working threads::shared.
147
148 DEPENDENCIES
149     perl 5.6.
150
151     Exporter, Test::More.
152
153 AUTHOR
154     Vincent Pit, "<perl at profvince.com>", <http://www.profvince.com>.
155
156     You can contact me by mail or on "irc.perl.org" (vincent).
157
158 BUGS
159     Please report any bugs or feature requests to "bug-test-leaner at
160     rt.cpan.org", or through the web interface at
161     <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Leaner>. I will be
162     notified, and then you'll automatically be notified of progress on your
163     bug as I make changes.
164
165 SUPPORT
166     You can find documentation for this module with the perldoc command.
167
168         perldoc Test::Leaner
169
170 COPYRIGHT & LICENSE
171     Copyright 2010 Vincent Pit, all rights reserved.
172
173     This program is free software; you can redistribute it and/or modify it
174     under the same terms as Perl itself.
175