Upgrade to podlators-2.0.2
[p5sagit/p5-mst-13.2.git] / lib / Pod / t / text.t
CommitLineData
f011ec7d 1#!/usr/bin/perl -w
8f202758 2# $Id: text.t,v 1.4 2006-01-20 21:20:58 eagle Exp $
f011ec7d 3#
4# text.t -- Additional specialized tests for Pod::Text.
5#
b7ae008f 6# Copyright 2002, 2004 by Russ Allbery <rra@stanford.edu>
f011ec7d 7#
8# This program is free software; you may redistribute it and/or modify it
9# under the same terms as Perl itself.
10
11BEGIN {
12 chdir 't' if -d 't';
13 if ($ENV{PERL_CORE}) {
14 @INC = '../lib';
15 } else {
16 unshift (@INC, '../blib/lib');
17 }
18 unshift (@INC, '../blib/lib');
19 $| = 1;
b7ae008f 20 print "1..3\n";
f011ec7d 21}
22
23END {
24 print "not ok 1\n" unless $loaded;
25}
26
27use Pod::Text;
28
29$loaded = 1;
30print "ok 1\n";
31
8f202758 32my $parser = Pod::Text->new or die "Cannot create parser\n";
f011ec7d 33my $n = 2;
34while (<DATA>) {
35 next until $_ eq "###\n";
36 open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n";
37 while (<DATA>) {
38 last if $_ eq "###\n";
39 print TMP $_;
40 }
41 close TMP;
f011ec7d 42 $parser->parse_from_file ('tmp.pod', 'out.tmp');
43 open (TMP, 'out.tmp') or die "Cannot open out.tmp: $!\n";
44 my $output;
45 {
46 local $/;
47 $output = <TMP>;
48 }
49 close TMP;
50 unlink ('tmp.pod', 'out.tmp');
51 my $expected = '';
52 while (<DATA>) {
53 last if $_ eq "###\n";
54 $expected .= $_;
55 }
56 if ($output eq $expected) {
57 print "ok $n\n";
58 } else {
59 print "not ok $n\n";
60 print "Expected\n========\n$expected\nOutput\n======\n$output\n";
61 }
62 $n++;
63}
64
65# Below the marker are bits of POD and corresponding expected text output.
66# This is used to test specific features or problems with Pod::Text. The
67# input and output are separated by lines containing only ###.
68
69__DATA__
70
71###
72=head1 PERIODS
73
74This C<.> should be quoted.
75###
76PERIODS
77 This "." should be quoted.
78
79###
b7ae008f 80
81###
82=head1 CE<lt>E<gt> WITH SPACES
83
84What does C<< this. >> end up looking like?
85###
86C<> WITH SPACES
87 What does "this." end up looking like?
88
89###