1b8851fccSafresh1#!/usr/bin/perl 2b8851fccSafresh1# 3b8851fccSafresh1# Tests for the automatic determination of the manual page title if not 4b8851fccSafresh1# specified via options to pod2man or the Pod::Man constructor. 5b8851fccSafresh1# 6*56d68f1eSafresh1# Copyright 2015-2016, 2018-2019 Russ Allbery <rra@cpan.org> 7b8851fccSafresh1# 8b8851fccSafresh1# This program is free software; you may redistribute it and/or modify it 9b8851fccSafresh1# under the same terms as Perl itself. 10b46d8ef2Safresh1# 11b46d8ef2Safresh1# SPDX-License-Identifier: GPL-1.0-or-later OR Artistic-1.0-Perl 12b8851fccSafresh1 13*56d68f1eSafresh1use 5.008; 14b8851fccSafresh1use strict; 15b8851fccSafresh1use warnings; 16b8851fccSafresh1 17b8851fccSafresh1use File::Spec; 18b8851fccSafresh1use IO::File; 19b8851fccSafresh1use Test::More tests => 5; 20b8851fccSafresh1 21b8851fccSafresh1BEGIN { 22b8851fccSafresh1 use_ok('Pod::Man'); 23b8851fccSafresh1} 24b8851fccSafresh1 25b8851fccSafresh1# Create a parser and set it up with an input source. There isn't a way to do 26b8851fccSafresh1# this in Pod::Simple without actually parsing the document, so send the 27b8851fccSafresh1# output to a string that we'll ignore. 28b8851fccSafresh1my $path = File::Spec->catfile('t', 'data', 'basic.pod'); 29b8851fccSafresh1my $handle = IO::File->new($path, 'r'); 30b8851fccSafresh1my $parser = Pod::Man->new(errors => 'pod'); 31b8851fccSafresh1my $output; 32b8851fccSafresh1$parser->output_string(\$output); 33b8851fccSafresh1$parser->parse_file($handle); 34b8851fccSafresh1 355759b3d2Safresh1# Check the results of devise_title for this. We should get back STDIN and 365759b3d2Safresh1# not report an error. 37b8851fccSafresh1my ($name, $section) = $parser->devise_title; 38b8851fccSafresh1is($name, 'STDIN', 'devise_title uses STDIN for file handle input'); 395759b3d2Safresh1ok(!$parser->errors_seen, '...and no errors were seen'); 40b8851fccSafresh1 41b8851fccSafresh1# Now check handling of a simple file name with no parent directory, which 42b8851fccSafresh1# simulates a POD file at the top of a distribution. In podlators 4.06, this 43b8851fccSafresh1# produced an erroneous warning. (That wouldn't actually fail this test, but 44b8851fccSafresh1# I'd see it during development, which is good enough and doesn't require 45b8851fccSafresh1# anything too complicated.) 46b8851fccSafresh1$parser->source_filename('Foo.pm'); 47b8851fccSafresh1($name, $section) = $parser->devise_title; 48b8851fccSafresh1is($name, 'Foo', 'devise_title with a simple module name'); 49b8851fccSafresh1is($section, 3, '...and the correct section'); 50