1Test2::V0(3) User Contributed Perl Documentation Test2::V0(3)
2
3
4
6 Test2::V0 - 0Th edition of the Test2 recommended bundle.
7
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
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
27 use Test2::V0;
28
29 ok(1, "pass");
30
31 ...
32
33 done_testing;
34
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
41 can 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 Importer for exporting, as such you can use any
55 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()"
66 and "my_ok()"
67
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
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
119 See Test2::API for these
120
121 $ctx = context()
122 $events = intercept { ... }
123
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 MOCK
257 See Test2::Tools::Mock.
258
259 $control = mock ...
260 $bool = mocked($thing)
261
262 EXCEPTION
263 See Test2::Tools::Exception.
264
265 $exception = dies { ... }
266 $bool = lives { ... }
267 $bool = try_ok { ... }
268
269 WARNINGS
270 See Test2::Tools::Warnings.
271
272 $count = warns { ... }
273 $warning = warning { ... }
274 $warnings_ref = warnings { ... }
275 $bool = no_warnings { ... }
276
278 The source code repository for Test2-Suite can be found at
279 https://github.com/Test-More/Test2-Suite/.
280
282 Chad Granum <exodist@cpan.org>
283
285 Chad Granum <exodist@cpan.org>
286
288 Copyright 2018 Chad Granum <exodist@cpan.org>.
289
290 This program is free software; you can redistribute it and/or modify it
291 under the same terms as Perl itself.
292
293 See http://dev.perl.org/licenses/
294
295
296
297perl v5.36.0 2022-07-22 Test2::V0(3)