xref: /openbsd-src/gnu/usr.bin/perl/cpan/Test-Simple/lib/Test/use/ok.pm (revision 3d61058aa5c692477b6d18acfbbdb653a9930ff9)
1b8851fccSafresh1package Test::use::ok;
2b8851fccSafresh1use 5.005;
35759b3d2Safresh1
4*3d61058aSafresh1our $VERSION = '1.302199';
55759b3d2Safresh1
6b8851fccSafresh1
7b8851fccSafresh1__END__
8b8851fccSafresh1
9b8851fccSafresh1=head1 NAME
10b8851fccSafresh1
11b8851fccSafresh1Test::use::ok - Alternative to Test::More::use_ok
12b8851fccSafresh1
13b8851fccSafresh1=head1 SYNOPSIS
14b8851fccSafresh1
15b8851fccSafresh1    use ok 'Some::Module';
16b8851fccSafresh1
17b8851fccSafresh1=head1 DESCRIPTION
18b8851fccSafresh1
19b8851fccSafresh1According to the B<Test::More> documentation, it is recommended to run
20b8851fccSafresh1C<use_ok()> inside a C<BEGIN> block, so functions are exported at
21b8851fccSafresh1compile-time and prototypes are properly honored.
22b8851fccSafresh1
23b8851fccSafresh1That is, instead of writing this:
24b8851fccSafresh1
25b8851fccSafresh1    use_ok( 'Some::Module' );
26b8851fccSafresh1    use_ok( 'Other::Module' );
27b8851fccSafresh1
28b8851fccSafresh1One should write this:
29b8851fccSafresh1
30b8851fccSafresh1    BEGIN { use_ok( 'Some::Module' ); }
31b8851fccSafresh1    BEGIN { use_ok( 'Other::Module' ); }
32b8851fccSafresh1
33b8851fccSafresh1However, people often either forget to add C<BEGIN>, or mistakenly group
34b8851fccSafresh1C<use_ok> with other tests in a single C<BEGIN> block, which can create subtle
35b8851fccSafresh1differences in execution order.
36b8851fccSafresh1
37b8851fccSafresh1With this module, simply change all C<use_ok> in test scripts to C<use ok>,
38b8851fccSafresh1and they will be executed at C<BEGIN> time.  The explicit space after C<use>
39b8851fccSafresh1makes it clear that this is a single compile-time action.
40b8851fccSafresh1
41b8851fccSafresh1=head1 SEE ALSO
42b8851fccSafresh1
43b8851fccSafresh1L<Test::More>
44b8851fccSafresh1
45b8851fccSafresh1=head1 MAINTAINER
46b8851fccSafresh1
47b8851fccSafresh1=over 4
48b8851fccSafresh1
49b8851fccSafresh1=item Chad Granum E<lt>exodist@cpan.orgE<gt>
50b8851fccSafresh1
51b8851fccSafresh1=back
52b8851fccSafresh1
53b8851fccSafresh1=encoding utf8
54b8851fccSafresh1
55b8851fccSafresh1=head1 CC0 1.0 Universal
56b8851fccSafresh1
57b8851fccSafresh1To the extent possible under law, 唐鳳 has waived all copyright and related
58*3d61058aSafresh1or neighboring rights to L<Test::use::ok>.
59b8851fccSafresh1
60b8851fccSafresh1This work is published from Taiwan.
61b8851fccSafresh1
62*3d61058aSafresh1L<https://creativecommons.org/publicdomain/zero/1.0/>
63b8851fccSafresh1
64b8851fccSafresh1=cut
65