summaryrefslogtreecommitdiff
path: root/cpan/podlators/t/man/heading.t
blob: dea3176670f5274836915d5fda9f9283783c1e30 (plain)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/usr/bin/perl
#
# Additional tests for Pod::Man heading generation.
#
# Copyright 2002, 2004, 2006, 2008-2009, 2012, 2015, 2018-2019, 2022
#     Russ Allbery <rra@cpan.org>
#
# This program is free software; you may redistribute it and/or modify it
# under the same terms as Perl itself.
#
# SPDX-License-Identifier: GPL-1.0-or-later OR Artistic-1.0-Perl

use 5.008;
use strict;
use warnings;

use lib 't/lib';

use Test::More tests => 11;
use Test::Podlators qw(read_test_data);

BEGIN {
    use_ok('Pod::Man');
}

# Loop through all the test data, generate output, and compare it to the
# desired output data.
my $testnum = 1;
while (defined(my $data = read_test_data(\*DATA, { options => 1 }))) {
    my $parser = Pod::Man->new(%{ $data->{options} });
    isa_ok($parser, 'Pod::Man', 'Parser object');

    # Run the parser, storing the output into a Perl variable.
    my $got;
    $parser->output_string(\$got);
    $parser->parse_string_document($data->{input});

    # Extract just the heading line.
    my ($heading) = ($got =~ m{^ ([.]TH [^\n]+ \n)}xms);

    # Compare the results.
    is($heading, $data->{output}, "Test $testnum");
    $testnum++;
}

# Below the marker are sets of options, the input data, and the corresponding
# expected .TH line from the man page.  The options and output are separated
# by lines containing only ###.

__DATA__

###
date 2009-01-17
release 1.0
###
=head1 NAME

test - Test man page
###
.TH STDIN 1 2009-01-17 1.0 "User Contributed Perl Documentation"
###

###
date 2009-01-17
name TEST
section 8
release 2.0-beta
###
=head1 NAME

test - Test man page
###
.TH TEST 8 2009-01-17 2.0-beta "User Contributed Perl Documentation"
###

###
date 2009-01-17
release 1.0
center Testing Documentation
###
=head1 NAME

test - Test man page
###
.TH STDIN 1 2009-01-17 1.0 "Testing Documentation"
###

###
date
release
center
###
=head1 NAME

test - Test man page
###
.TH STDIN 1 "" "" ""
###

###
date foo ""bar""
release "quoted"
section 4"
name "BAR
center Something
###
=head1 NAME

test - Test man page
###
.TH """BAR" "4""" "foo """"bar""""" """quoted""" Something
###