Commit | Line | Data |
---|---|---|
cb21ff46 KE |
1 | #!/usr/bin/perl |
2 | # | |
3 | # Additional tests for Pod::Man heading generation. | |
4 | # | |
f97008e2 | 5 | # Copyright 2002, 2004, 2006, 2008-2009, 2012, 2015, 2018 |
cb21ff46 KE |
6 | # Russ Allbery <rra@cpan.org> |
7 | # | |
8 | # This program is free software; you may redistribute it and/or modify it | |
9 | # under the same terms as Perl itself. | |
f97008e2 SH |
10 | # |
11 | # SPDX-License-Identifier: GPL-1.0-or-later OR Artistic-1.0-Perl | |
cb21ff46 KE |
12 | |
13 | use 5.006; | |
14 | use strict; | |
15 | use warnings; | |
16 | ||
17 | use lib 't/lib'; | |
18 | ||
19 | use Test::More tests => 9; | |
20 | use Test::Podlators qw(read_test_data); | |
21 | ||
22 | BEGIN { | |
23 | use_ok('Pod::Man'); | |
24 | } | |
25 | ||
26 | # Loop through all the test data, generate output, and compare it to the | |
27 | # desired output data. | |
28 | while (defined(my $data = read_test_data(\*DATA, { options => 1 }))) { | |
29 | my $parser = Pod::Man->new(%{ $data->{options} }); | |
30 | isa_ok($parser, 'Pod::Man', 'Parser object'); | |
31 | ||
32 | # Run the parser, storing the output into a Perl variable. | |
33 | my $got; | |
34 | $parser->output_string(\$got); | |
35 | $parser->parse_string_document($data->{input}); | |
36 | ||
37 | # Extract just the heading line. | |
38 | my ($heading) = ($got =~ m{^ ([.]TH [^\n]+ \n)}xms); | |
39 | ||
40 | # Compare the results. | |
41 | is($heading, $data->{output}); | |
42 | } | |
43 | ||
44 | # Below the marker are sets of options, the input data, and the corresponding | |
45 | # expected .TH line from the man page. The options and output are separated | |
46 | # by lines containing only ###. | |
47 | ||
48 | __DATA__ | |
49 | ||
50 | ### | |
51 | date 2009-01-17 | |
52 | release 1.0 | |
53 | ### | |
54 | =head1 NAME | |
55 | ||
56 | test - Test man page | |
57 | ### | |
58 | .TH STDIN 1 "2009-01-17" "1.0" "User Contributed Perl Documentation" | |
59 | ### | |
60 | ||
61 | ### | |
62 | date 2009-01-17 | |
63 | name TEST | |
64 | section 8 | |
65 | release 2.0-beta | |
66 | ### | |
67 | =head1 NAME | |
68 | ||
69 | test - Test man page | |
70 | ### | |
71 | .TH TEST 8 "2009-01-17" "2.0-beta" "User Contributed Perl Documentation" | |
72 | ### | |
73 | ||
74 | ### | |
75 | date 2009-01-17 | |
76 | release 1.0 | |
77 | center Testing Documentation | |
78 | ### | |
79 | =head1 NAME | |
80 | ||
81 | test - Test man page | |
82 | ### | |
83 | .TH STDIN 1 "2009-01-17" "1.0" "Testing Documentation" | |
84 | ### | |
85 | ||
86 | ### | |
87 | date | |
88 | release | |
89 | center | |
90 | ### | |
91 | =head1 NAME | |
92 | ||
93 | test - Test man page | |
94 | ### | |
95 | .TH STDIN 1 "" "" "" | |
96 | ### |