1#!/usr/bin/perl 2# 3# Test Pod::Text::Termcap behavior with various snippets. 4# 5# Copyright 2002, 2004, 2006, 2009, 2012-2014, 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 => 15; 20use Test::Podlators qw(test_snippet); 21 22# Load the module. 23BEGIN { 24 use_ok('Pod::Text::Termcap'); 25} 26 27# Hard-code a few values to try to get reproducible results. 28$ENV{COLUMNS} = 80; 29$ENV{TERM} = 'xterm'; 30$ENV{TERMPATH} = File::Spec->catfile('t', 'data', 'termcap'); 31$ENV{TERMCAP} = 'xterm:co=#80:do=^J:md=\E[1m:us=\E[4m:me=\E[m'; 32 33# Check the regex that matches a single formatting character. 34my $parser = Pod::Text::Termcap->new(); 35is($parser->format_regex(), "\\\e\\[1m|\\\e\\[4m|\\\e\\[m", 'Character regex'); 36 37# List of snippets run by this test. 38my @snippets = qw(escape-wrapping tag-width tag-wrapping width wrapping); 39 40# Run all the tests. 41for my $snippet (@snippets) { 42 test_snippet('Pod::Text::Termcap', "termcap/$snippet"); 43} 44 45# Now test with an unknown terminal type. 46$ENV{TERM} = 'unknown'; 47$ENV{TERMCAP} = 'unknown:co=#80:do=^J'; 48test_snippet('Pod::Text::Termcap', 'termcap/term-unknown'); 49 50# Test the character regex with a fake terminal type that only provides bold 51# and normal, not underline. 52$ENV{TERM} = 'fake-test-terminal'; 53$ENV{TERMCAP} = 'fake-test-terminal:md=\E[1m:me=\E[m'; 54$parser = Pod::Text::Termcap->new(); 55is($parser->format_regex(), "\\\e\\[1m|\\\e\\[m", 'Limited character regex'); 56