This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
c5496bb871015b181703d62690bc0389b8032ee1
[perl5.git] / cpan / podlators / t / text / overstrike.t
1 #!/usr/bin/perl -w
2 #
3 # overstrike.t -- Additional specialized tests for Pod::Text::Overstrike.
4 #
5 # Copyright 2002, 2004, 2006, 2009, 2012, 2013
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 BEGIN {
12     chdir 't' if -d 't';
13     if ($ENV{PERL_CORE}) {
14         @INC = '../lib';
15     }
16     unshift (@INC, '../blib/lib');
17     $| = 1;
18 }
19
20 use strict;
21
22 use Test::More tests => 4;
23 BEGIN { use_ok ('Pod::Text::Overstrike') }
24
25 my $parser = Pod::Text::Overstrike->new;
26 isa_ok ($parser, 'Pod::Text::Overstrike', 'Parser module');
27 my $n = 1;
28 while (<DATA>) {
29     next until $_ eq "###\n";
30     open (TMP, "> tmp$$.pod") or die "Cannot create tmp$$.pod: $!\n";
31     while (<DATA>) {
32         last if $_ eq "###\n";
33         print TMP $_;
34     }
35     close TMP;
36     open (OUT, "> out$$.tmp") or die "Cannot create out$$.tmp: $!\n";
37     $parser->parse_from_file ("tmp$$.pod", \*OUT);
38     close OUT;
39     open (TMP, "out$$.tmp") or die "Cannot open out$$.tmp: $!\n";
40     my $output;
41     {
42         local $/;
43         $output = <TMP>;
44     }
45     close TMP;
46     1 while unlink ("tmp$$.pod", "out$$.tmp");
47     my $expected = '';
48     while (<DATA>) {
49         last if $_ eq "###\n";
50         $expected .= $_;
51     }
52     is ($output, $expected, "Output correct for test $n");
53     $n++;
54 }
55
56 # Below the marker are bits of POD and corresponding expected output.  This is
57 # used to test specific features or problems with Pod::Text::Termcap.  The
58 # input and output are separated by lines containing only ###.
59
60 __DATA__
61
62 ###
63 =head1 WRAPPING
64
65 B<I<Do>> I<B<not>> B<I<include>> B<I<formatting codes when>> B<I<wrapping>>.
66 ###
67 W\bWR\bRA\bAP\bPP\bPI\bIN\bNG\bG
68     D\bDo\bo _\bn_\bo_\bt i\bin\bnc\bcl\blu\bud\bde\be f\bfo\bor\brm\bma\bat\btt\bti\bin\bng\b\b c\bco\bod\bde\bes\b\b w\bwh\bhe\ben\bn w\bwr\bra\bap\bpp\bpi\bin\bng\bg.
69
70 ###
71
72 ###
73 =head1 TAG WIDTH
74
75 =over 10
76
77 =item 12345678
78
79 A
80
81 =item B<12345678>
82
83 B
84
85 =item 1Z<>
86
87 C
88
89 =item B<1>
90
91 D
92
93 =back
94 ###
95 T\bTA\bAG\b\b W\bWI\bID\bDT\bTH\bH
96     12345678  A
97
98     1\b12\b23\b34\b45\b56\b67\b78\b8  B
99
100     1         C
101
102     1\b1         D
103
104 ###