1Test2::V0(3)          User Contributed Perl Documentation         Test2::V0(3)
2
3
4

NAME

6       Test2::V0 - 0Th edition of the Test2 recommended bundle.
7

DESCRIPTION

9       This is the big-daddy bundle. This bundle includes nearly every tool,
10       and several plugins, that the Test2 author uses. This bundle is used
11       extensively to test Test2::Suite itself.
12

NAMING, USING, DEPENDING

14       This bundle should not change in a severely incompatible way. Some
15       minor breaking changes, specially bugfixes, may be allowed. If breaking
16       changes are needed then a new "Test2::V#" module should be released
17       instead.
18
19       As new "V#" modules are released old ones may be moved to different
20       cpan distributions. You should always use a specific bundle version and
21       list that version in your distributions testing requirements. You
22       should never simply list Test2::Suite as your modules dep, instead list
23       the specific bundle, or tools and plugins you use directly in your
24       metadata.
25

SYNOPSIS

27           use Test2::V0;
28
29           ok(1, "pass");
30
31           ...
32
33           done_testing;
34

RESOLVING CONFLICTS WITH MOOSE

36           use Test2::V0 '!meta';
37
38       Moose and Test2::V0 both export very different meta() subs. Adding
39       '!meta' to the import args will prevent the sub from being imported.
40       This bundle also exports the sub under the name meta_check() so you can
41       use that spelling as an alternative.
42
43   TAGS
44       :DEFAULT
45           The following are both identical:
46
47               use Test2::V0;
48
49               use Test2::V0 ':DEFAULT';
50
51   RENAMING ON IMPORT
52           use Test2::V0 ':DEFAULT', '!ok', ok => {-as => 'my_ok'};
53
54       This bundle uses Test2::Util::Importer for exporting, as such you can
55       use any arguments it accepts.
56
57       Explanation:
58
59       '!ok'
60           Do not export ok()
61
62       ok => {-as => 'my_ok'}
63           Actually, go ahead and import ok() but under the name my_ok().
64
65       If you did not add the '!ok' argument then you would have both ok() and
66       my_ok()
67

PRAGMAS

69       All of these can be disabled via individual import arguments, or by the
70       "-no_pragmas" argument.
71
72           use Test2::V0 -no_pragmas => 1;
73
74   STRICT
75       strict is turned on for you. You can disable this with the "-no_strict"
76       or "-no_pragmas" import arguments:
77
78           use Test2::V0 -no_strict => 1;
79
80   WARNINGS
81       warnings are turned on for you. You can disable this with the
82       "-no_warnings" or "-no_pragmas" import arguments:
83
84           use Test2::V0 -no_warnings => 1;
85
86   UTF8
87       This is actually done via the Test2::Plugin::UTF8 plugin, see the
88       "PLUGINS" section for details.
89
90       Note: "-no_pragmas => 1" will turn off the entire plugin.
91

PLUGINS

93   SRAND
94       See Test2::Plugin::SRand.
95
96       This will set the random seed to today's date. You can provide an
97       alternate seed with the "-srand" import option:
98
99           use Test2::V0 -srand => 1234;
100
101   UTF8
102       See Test2::Plugin::UTF8.
103
104       This will set the file, and all output handles (including formatter
105       handles), to utf8. This will turn on the utf8 pragma for the current
106       scope.
107
108       This can be disabled using the "-no_utf8 => 1" or "-no_pragmas => 1"
109       import arguments.
110
111           use Test2::V0 -no_utf8 => 1;
112
113   EXIT SUMMARY
114       See Test2::Plugin::ExitSummary.
115
116       This plugin has no configuration.
117

API FUNCTIONS

119       See Test2::API for these
120
121       $ctx = context()
122       $events = intercept { ... }
123

TOOLS

125   TARGET
126       See Test2::Tools::Target.
127
128       You can specify a target class with the "-target" import argument. If
129       you do not provide a target then $CLASS and CLASS() will not be
130       imported.
131
132           use Test2::V0 -target => 'My::Class';
133
134           print $CLASS;  # My::Class
135           print CLASS(); # My::Class
136
137       Or you can specify names:
138
139           use Test2::V0 -target => { pkg => 'Some::Package' };
140
141           pkg()->xxx; # Call 'xxx' on Some::Package
142           $pkg->xxx;  # Same
143
144       $CLASS
145           Package variable that contains the target class name.
146
147       $class = CLASS()
148           Constant function that returns the target class name.
149
150   DEFER
151       See Test2::Tools::Defer.
152
153       def $func => @args;
154       do_def()
155
156   BASIC
157       See Test2::Tools::Basic.
158
159       ok($bool, $name)
160       ok($bool, $name, @diag)
161       pass($name)
162       pass($name, @diag)
163       fail($name)
164       fail($name, @diag)
165       diag($message)
166       note($message)
167       $todo = todo($reason)
168       todo $reason => sub { ... }
169       skip($reason, $count)
170       plan($count)
171       skip_all($reason)
172       done_testing()
173       bail_out($reason)
174
175   COMPARE
176       See Test2::Tools::Compare.
177
178       is($got, $want, $name)
179       isnt($got, $do_not_want, $name)
180       like($got, qr/match/, $name)
181       unlike($got, qr/mismatch/, $name)
182       $check = match(qr/pattern/)
183       $check = mismatch(qr/pattern/)
184       $check = validator(sub { return $bool })
185       $check = hash { ... }
186       $check = array { ... }
187       $check = bag { ... }
188       $check = object { ... }
189       $check = meta { ... }
190       $check = number($num)
191       $check = string($str)
192       $check = check_isa($class_name)
193       $check = in_set(@things)
194       $check = not_in_set(@things)
195       $check = check_set(@things)
196       $check = item($thing)
197       $check = item($idx => $thing)
198       $check = field($name => $val)
199       $check = call($method => $expect)
200       $check = call_list($method => $expect)
201       $check = call_hash($method => $expect)
202       $check = prop($name => $expect)
203       $check = check($thing)
204       $check = T()
205       $check = F()
206       $check = D()
207       $check = DF()
208       $check = E()
209       $check = DNE()
210       $check = FDNE()
211       $check = U()
212       $check = L()
213       $check = exact_ref($ref)
214       end()
215       etc()
216       filter_items { grep { ... } @_ }
217       $check = event $type => ...
218       @checks = fail_events $type => ...
219
220   CLASSIC COMPARE
221       See Test2::Tools::ClassicCompare.
222
223       cmp_ok($got, $op, $want, $name)
224
225   SUBTEST
226       See Test2::Tools::Subtest.
227
228       subtest $name => sub { ... };
229           (Note: This is called subtest_buffered() in the Tools module.)
230
231   CLASS
232       See Test2::Tools::Class.
233
234       can_ok($thing, @methods)
235       isa_ok($thing, @classes)
236       DOES_ok($thing, @roles)
237
238   ENCODING
239       See Test2::Tools::Encoding.
240
241       set_encoding($encoding)
242
243   EXPORTS
244       See Test2::Tools::Exports.
245
246       imported_ok('function', '$scalar', ...)
247       not_imported_ok('function', '$scalar', ...)
248
249   REF
250       See Test2::Tools::Ref.
251
252       ref_ok($ref, $type)
253       ref_is($got, $want)
254       ref_is_not($got, $do_not_want)
255
256       See Test2::Tools::Refcount.
257
258       is_refcount($ref, $count, $description)
259       is_oneref($ref, $description)
260       $count = refcount($ref)
261
262   MOCK
263       See Test2::Tools::Mock.
264
265       $control = mock ...
266       $bool = mocked($thing)
267
268   EXCEPTION
269       See Test2::Tools::Exception.
270
271       $exception = dies { ... }
272       $bool = lives { ... }
273       $bool = try_ok { ... }
274
275   WARNINGS
276       See Test2::Tools::Warnings.
277
278       $count = warns { ... }
279       $warning = warning { ... }
280       $warnings_ref = warnings { ... }
281       $bool = no_warnings { ... }
282

SOURCE

284       The source code repository for Test2-Suite can be found at
285       https://github.com/Test-More/Test2-Suite/.
286

MAINTAINERS

288       Chad Granum <exodist@cpan.org>
289

AUTHORS

291       Chad Granum <exodist@cpan.org>
292
294       Copyright 2018 Chad Granum <exodist@cpan.org>.
295
296       This program is free software; you can redistribute it and/or modify it
297       under the same terms as Perl itself.
298
299       See http://dev.perl.org/licenses/
300
301
302
303perl v5.38.0                      2023-07-21                      Test2::V0(3)
Impressum