Commit | Line | Data |
---|---|---|
55595e83 SP |
1 | #!/usr/bin/perl -w |
2 | # | |
3 | # man-options.t -- Additional tests for Pod::Man options. | |
4 | # | |
5 | # Copyright 2002, 2004, 2006, 2008 Russ Allbery <rra@stanford.edu> | |
6 | # | |
7 | # This program is free software; you may redistribute it and/or modify it | |
8 | # under the same terms as Perl itself. | |
9 | ||
10 | BEGIN { | |
11 | chdir 't' if -d 't'; | |
12 | if ($ENV{PERL_CORE}) { | |
13 | @INC = '../lib'; | |
14 | } else { | |
15 | unshift (@INC, '../blib/lib'); | |
16 | } | |
17 | unshift (@INC, '../blib/lib'); | |
18 | $| = 1; | |
19 | print "1..2\n"; | |
20 | } | |
21 | ||
22 | END { | |
23 | print "not ok 1\n" unless $loaded; | |
24 | } | |
25 | ||
26 | use Pod::Man; | |
27 | ||
28 | $loaded = 1; | |
29 | print "ok 1\n"; | |
30 | ||
31 | my $n = 2; | |
32 | while (<DATA>) { | |
33 | my %options; | |
34 | next until $_ eq "###\n"; | |
35 | while (<DATA>) { | |
36 | last if $_ eq "###\n"; | |
37 | my ($option, $value) = split; | |
38 | $options{$option} = $value; | |
39 | } | |
40 | open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n"; | |
41 | while (<DATA>) { | |
42 | last if $_ eq "###\n"; | |
43 | print TMP $_; | |
44 | } | |
45 | close TMP; | |
46 | my $parser = Pod::Man->new (%options) or die "Cannot create parser\n"; | |
47 | open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n"; | |
48 | $parser->parse_from_file ('tmp.pod', \*OUT); | |
49 | close OUT; | |
50 | open (TMP, 'out.tmp') or die "Cannot open out.tmp: $!\n"; | |
51 | while (<TMP>) { last if /^\.nh/ } | |
52 | my $output; | |
53 | { | |
54 | local $/; | |
55 | $output = <TMP>; | |
56 | } | |
57 | close TMP; | |
58 | unlink ('tmp.pod', 'out.tmp'); | |
59 | my $expected = ''; | |
60 | while (<DATA>) { | |
61 | last if $_ eq "###\n"; | |
62 | $expected .= $_; | |
63 | } | |
64 | if ($output eq $expected) { | |
65 | print "ok $n\n"; | |
66 | } else { | |
67 | print "not ok $n\n"; | |
68 | print "Expected\n========\n$expected\nOutput\n======\n$output\n"; | |
69 | } | |
70 | $n++; | |
71 | } | |
72 | ||
73 | # Below the marker are bits of POD and corresponding expected text output. | |
74 | # This is used to test specific features or problems with Pod::Man. The | |
75 | # input and output are separated by lines containing only ###. | |
76 | ||
77 | __DATA__ | |
78 | ||
79 | ### | |
80 | utf8 1 | |
81 | ### | |
82 | =head1 BEYONCÉ | |
83 | ||
84 | Beyoncé! Beyoncé! Beyoncé!! | |
85 | ||
86 | Beyoncé! Beyoncé! | |
87 | Beyoncé! Beyoncé! | |
88 | Beyoncé! Beyoncé! | |
89 | ||
90 | Older versions did not convert Beyoncé in verbatim. | |
91 | ### | |
92 | .SH "BEYONCÉ" | |
93 | .IX Header "BEYONCÉ" | |
94 | Beyoncé! Beyoncé! Beyoncé!! | |
95 | .PP | |
96 | .Vb 3 | |
97 | \& Beyoncé! Beyoncé! | |
98 | \& Beyoncé! Beyoncé! | |
99 | \& Beyoncé! Beyoncé! | |
100 | .Ve | |
101 | .PP | |
102 | Older versions did not convert Beyoncé in verbatim. | |
103 | ### |