1#!/usr/bin/perl 2# 3# Tests for the automatic determination of the manual page title if not 4# specified via options to pod2man or the Pod::Man constructor. 5# 6# Copyright 2015-2016, 2018 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.006; 14use strict; 15use warnings; 16 17use File::Spec; 18use IO::File; 19use Test::More tests => 5; 20 21BEGIN { 22 use_ok('Pod::Man'); 23} 24 25# Create a parser and set it up with an input source. There isn't a way to do 26# this in Pod::Simple without actually parsing the document, so send the 27# output to a string that we'll ignore. 28my $path = File::Spec->catfile('t', 'data', 'basic.pod'); 29my $handle = IO::File->new($path, 'r'); 30my $parser = Pod::Man->new(errors => 'pod'); 31my $output; 32$parser->output_string(\$output); 33$parser->parse_file($handle); 34 35# Check the results of devise_title for this. We should get back STDIN and 36# not report an error. 37my ($name, $section) = $parser->devise_title; 38is($name, 'STDIN', 'devise_title uses STDIN for file handle input'); 39ok(!$parser->errors_seen, '...and no errors were seen'); 40 41# Now check handling of a simple file name with no parent directory, which 42# simulates a POD file at the top of a distribution. In podlators 4.06, this 43# produced an erroneous warning. (That wouldn't actually fail this test, but 44# I'd see it during development, which is good enough and doesn't require 45# anything too complicated.) 46$parser->source_filename('Foo.pm'); 47($name, $section) = $parser->devise_title; 48is($name, 'Foo', 'devise_title with a simple module name'); 49is($section, 3, '...and the correct section'); 50