1Test::Synopsis(3)     User Contributed Perl Documentation    Test::Synopsis(3)
2
3
4

NAME

6       Test::Synopsis - Test your SYNOPSIS code
7

SYNOPSIS

9         # xt/synopsis.t (with Module::Install::AuthorTests)
10         use Test::Synopsis;
11         all_synopsis_ok();
12
13         # Or, run safe without Test::Synopsis
14         use Test::More;
15         eval "use Test::Synopsis";
16         plan skip_all => "Test::Synopsis required for testing" if $@;
17         all_synopsis_ok();
18

DESCRIPTION

20       Test::Synopsis is an (author) test module to find .pm or .pod files
21       under your lib directory and then make sure the example snippet code in
22       your SYNOPSIS section passes the perl compile check.
23
24       Note that this module only checks the perl syntax (by wrapping the code
25       with "sub") and doesn't actually run the code.
26
27       Suppose you have the following POD in your module.
28
29         =head1 NAME
30
31         Awesome::Template - My awesome template
32
33         =head1 SYNOPSIS
34
35           use Awesome::Template;
36
37           my $template = Awesome::Template->new;
38           $tempalte->render("template.at");
39
40         =head1 DESCRIPTION
41
42       An user of your module would try copy-paste this synopsis code and find
43       that this code doesn't compile because there's a typo in your variable
44       name $tempalte. Test::Synopsis will catch that error before you ship
45       it.
46

VARIABLE DECLARATIONS

48       Sometimes you might want to put some undeclared variables in your
49       synopsis, like:
50
51         =head1 SYNOPSIS
52
53           use Data::Dumper::Names;
54           print Dumper($scalar, \@array, \%hash);
55
56       This assumes these variables like $scalar are defined elsewhere in
57       module user's code, but Test::Synopsis, by default, will complain that
58       these variables are not declared:
59
60           Global symbol "$scalar" requires explicit package name at ...
61
62       In this case, you can add the following POD sequence elsewhere in your
63       POD:
64
65         =for test_synopsis
66         no strict 'vars'
67
68       Or more explicitly,
69
70         =for test_synopsis
71         my($scalar, @array, %hash);
72
73       Test::Synopsis will find these "=for" blocks and these statements are
74       prepended before your SYNOPSIS code when being evaluated, so those
75       variable name errors will go away, without adding unnecessary bits in
76       SYNOPSIS which might confuse users.
77

AUTHOR

79       Tatsuhiko Miyagawa <miyagawa@bulknews.net>
80
81       Goro Fuji blogged about the original idea at
82       <http://d.hatena.ne.jp/gfx/20090224/1235449381> based on the testing
83       code taken from Test::Weaken.
84

LICENSE

86       This library is free software; you can redistribute it and/or modify it
87       under the same terms as Perl itself.
88

SEE ALSO

90       Test::Pod, Test::UseAllModules, Test::Inline, Test::Snippet
91
92
93
94perl v5.16.3                      2009-07-06                 Test::Synopsis(3)
Impressum