Test::Pod::Content(3pm)

Test::Pod::Content3pm

Test a pod's content

Usage

 use Test::Pod::Content tests => 3;
 pod_section_is 'Test::Pod::Content' , 'NAME', "Test::Pod::Content - Test a Pod's content", 'NAME section';
 pod_section_like 'Test/Pod/Content.pm', 'SYNOPSIS', qr{ use \s Test::Pod::Content; }xm, 'SYNOPSIS section';
 pod_section_like 'Test/Pod/Content.pm', 'DESCRIPTION', qr{ Test::Pod::Content \s provides \s the }xm, 'DESCRIPTION section';

Overview

This is a very simple module for testing a Pod's content. It is mainly intended for testing the content of generated Pod - that is, the Pod included in perl modules generated by some mechanism.

Another usage example is to test whether all files contain the same copyright notice:

 plan tests => scalar @filelist;
 for my $file (sort @filelist) {
    pod_section_like( $file, 'LICENSE AND COPYRIGHT', qr{
        This \s library \s is \s free \s software\. \s
        You \s may \s distribute/modify \s it \s under \s
        the \s same \s terms \s as \s perl \s itself
    }xms, "$file License notice");
 }

See the files in the t/ directory for live examples.

Test::Pod::Content has a very simple concept of Pods: To Test::Pod::Content, a Pod is separated into section. Each section starts with a =head(1|2|3|4) directive, and ends with the next =head, or with the end of the document (=cut).

This is a very drastic simplification of Pod's document object model, and only allows for coarse-grained tests.

Test::Pod::Content provides the following subroutines for testing a Pod's content:

Subroutines/methods

pod_section_is

  pod_section_is $file, $section, $content, $comment;

Tests whether a Pod section contains exactly the text given. Most useful for testing the NAME section. You probably want to use pod_section_like for all other sections.

$file may either be a filename (including path) or a module name. Test::Pod::Content will search in @INC for the file/module given.

pod_section_like

 pod_section_like $file, $section, qr{ use \s Test::Pod::Content\s }xm, $comment;

Tests whether the text in a Pod section matches the given regex. Be sure to include the m / s regex qualifier if you expect your Pod section to span multiple lines.

$file may either be a filename (including path) or a module name. Test::Pod::Content will search in @INC for the file/module given.

Bugs and limitations

•

Performance

Every call to a pod_section_* method searches for the file in question in @INC and parses it from its start. This means that every test requires a Pod parser run, which is quite inefficient if you conduct a big number of tests.

•

Pod Syntax

Test::Pod::Coverage may report wrong test results if your pod is not syntactically correct. You should use Test::Pod to check your Pod's syntax.

Dependencies

Test::More

Pod::Simple

version

Incompatibilities

None known

Repository information

 $Id: Content.pm 505 2008-06-22 09:54:54Z kutterma $
 $Revision: 505 $
 $Source: a $
 $Date: 2008-06-22 11:54:54 +0200 (So, 22 Jun 2008) $
 $HeadURL: http://svn.hyper-framework.org/Hyper/Test-Pod-Content/trunk/lib/Test/Pod/Content.pm $

Releases

7 releases since Debian 7 (Wheezy); the text changed 3 times.

  1. 7–8
  2. 9–10
  3. 11
  4. 12–13

Author

Martin Kutter <martin.kutter fen-net.de>

From libtest-pod-content-perl 0.0.6-4 in Debian 13 (Trixie). Parsed by carta from the page's man source.