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 = DNE()
209 $check = FDNE()
210 $check = exact_ref($ref)
211 end()
212 etc()
213 filter_items { grep { ... } @_ }
214 $check = event $type => ...
215 @checks = fail_events $type => ...
216
217 CLASSIC COMPARE
218 See Test2::Tools::ClassicCompare.
219
220 cmp_ok($got, $op, $want, $name)
221
222 SUBTEST
223 See Test2::Tools::Subtest.
224
225 subtest $name => sub { ... };
226 (Note: This is called "subtest_buffered()" in the Tools module.)
227
228 CLASS
229 See Test2::Tools::Class.
230
231 can_ok($thing, @methods)
232 isa_ok($thing, @classes)
233 DOES_ok($thing, @roles)
234
235 ENCODING
236 See Test2::Tools::Encoding.
237
238 set_encoding($encoding)
239
240 EXPORTS
241 See Test2::Tools::Exports.
242
243 imported_ok('function', '$scalar', ...)
244 not_imported_ok('function', '$scalar', ...)
245
246 REF
247 See Test2::Tools::Ref.
248
249 ref_ok($ref, $type)
250 ref_is($got, $want)
251 ref_is_not($got, $do_not_want)
252
253 MOCK
254 See Test2::Tools::Mock.
255
256 $control = mock ...
257 $bool = mocked($thing)
258
259 EXCEPTION
260 See Test2::Tools::Exception.
261
262 $exception = dies { ... }
263 $bool = lives { ... }
264 $bool = try_ok { ... }
265
266 WARNINGS
267 See Test2::Tools::Warnings.
268
269 $count = warns { ... }
270 $warning = warning { ... }
271 $warnings_ref = warnings { ... }
272 $bool = no_warnings { ... }
273
275 The source code repository for Test2-Suite can be found at
276 https://github.com/Test-More/Test2-Suite/.
277
279 Chad Granum <exodist@cpan.org>
280
282 Chad Granum <exodist@cpan.org>
283
285 Copyright 2018 Chad Granum <exodist@cpan.org>.
286
287 This program is free software; you can redistribute it and/or modify it
288 under the same terms as Perl itself.
289
290 See http://dev.perl.org/licenses/
291
292
293
294perl v5.32.1 2021-01-27 Test2::V0(3)