1#!/usr/bin/perl 2# 3# Additional tests for Pod::Man heading generation. 4# 5# Copyright 2002, 2004, 2006, 2008-2009, 2012, 2015, 2018-2019 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. 10# 11# SPDX-License-Identifier: GPL-1.0-or-later OR Artistic-1.0-Perl 12 13use 5.008; 14use strict; 15use warnings; 16 17use lib 't/lib'; 18 19use Test::More tests => 9; 20use Test::Podlators qw(read_test_data); 21 22BEGIN { 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. 28while (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### 51date 2009-01-17 52release 1.0 53### 54=head1 NAME 55 56test - Test man page 57### 58.TH STDIN 1 "2009-01-17" "1.0" "User Contributed Perl Documentation" 59### 60 61### 62date 2009-01-17 63name TEST 64section 8 65release 2.0-beta 66### 67=head1 NAME 68 69test - Test man page 70### 71.TH TEST 8 "2009-01-17" "2.0-beta" "User Contributed Perl Documentation" 72### 73 74### 75date 2009-01-17 76release 1.0 77center Testing Documentation 78### 79=head1 NAME 80 81test - Test man page 82### 83.TH STDIN 1 "2009-01-17" "1.0" "Testing Documentation" 84### 85 86### 87date 88release 89center 90### 91=head1 NAME 92 93test - Test man page 94### 95.TH STDIN 1 "" "" "" 96### 97