File: podstyle.t

package info (click to toggle)
libmoosex-app-perl 1.43-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 712 kB
  • sloc: perl: 4,011; makefile: 2
file content (46 lines) | stat: -rw-r--r-- 1,005 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# -*- perl -*-

use strict;
use warnings;
use Test::More;

eval "use Pod::Simple::SimpleTree";
plan skip_all => 'Pod::Simple::SimpleTree required' if $@;
eval "use Test::Pod";
plan skip_all => 'Test::Pod required' if $@;
plan skip_all => 'set TEST_AUTHOR to enable this test' unless $ENV{TEST_AUTHOR};

my @files;
foreach (all_pod_files()) {
    next if /Schema\//;
    next if /\.pl$/;
    push @files,$_;
}

my @required_heads=qw(NAME SYNOPSIS DESCRIPTION METHODS AUTHOR);

plan tests => scalar @files * scalar @required_heads;

foreach my $file (@files) {

    my $parser=Pod::Simple::SimpleTree->new;
    $parser->accept_targets('*');
    my $root=$parser->parse_file($file)->root;
    shift(@$root);shift(@$root);

    my @heads;
    my %heads;
    foreach my $node (@$root) {
        next unless $node->[0] eq 'head1';
        push(@heads,$node->[2]);
        $heads{$node->[2]}=1;
    }
   
    foreach my $heading (@required_heads) {
        ok($heads{$heading},"$file has $heading");
    }

}