1N/A#!/usr/bin/perl -w
1N/A# $Id: text-options.t,v 1.2 2002/08/04 03:38:24 eagle Exp $
1N/A#
1N/A# text-options.t -- Additional tests for Pod::Text options.
1N/A#
1N/A# Copyright 2002 by Russ Allbery <rra@stanford.edu>
1N/A#
1N/A# This program is free software; you may redistribute it and/or modify it
1N/A# under the same terms as Perl itself.
1N/A
1N/ABEGIN {
1N/A chdir 't' if -d 't';
1N/A if ($ENV{PERL_CORE}) {
1N/A @INC = '../lib';
1N/A } else {
1N/A unshift (@INC, '../blib/lib');
1N/A }
1N/A unshift (@INC, '../blib/lib');
1N/A $| = 1;
1N/A print "1..3\n";
1N/A}
1N/A
1N/AEND {
1N/A print "not ok 1\n" unless $loaded;
1N/A}
1N/A
1N/Ause Pod::Text;
1N/A
1N/A$loaded = 1;
1N/Aprint "ok 1\n";
1N/A
1N/Amy $n = 2;
1N/Awhile (<DATA>) {
1N/A my %options;
1N/A next until $_ eq "###\n";
1N/A while (<DATA>) {
1N/A last if $_ eq "###\n";
1N/A my ($option, $value) = split;
1N/A $options{$option} = $value;
1N/A }
1N/A open (TMP, '> tmp.pod') or die "Cannot create tmp.pod: $!\n";
1N/A while (<DATA>) {
1N/A last if $_ eq "###\n";
1N/A print TMP $_;
1N/A }
1N/A close TMP;
1N/A my $parser = Pod::Text->new (%options) or die "Cannot create parser\n";
1N/A $parser->parse_from_file ('tmp.pod', 'out.tmp');
1N/A open (TMP, 'out.tmp') or die "Cannot open out.tmp: $!\n";
1N/A my $output;
1N/A {
1N/A local $/;
1N/A $output = <TMP>;
1N/A }
1N/A close TMP;
1N/A unlink ('tmp.pod', 'out.tmp');
1N/A my $expected = '';
1N/A while (<DATA>) {
1N/A last if $_ eq "###\n";
1N/A $expected .= $_;
1N/A }
1N/A if ($output eq $expected) {
1N/A print "ok $n\n";
1N/A } else {
1N/A print "not ok $n\n";
1N/A print "Expected\n========\n$expected\nOutput\n======\n$output\n";
1N/A }
1N/A $n++;
1N/A}
1N/A
1N/A# Below the marker are bits of POD and corresponding expected text output.
1N/A# This is used to test specific features or problems with Pod::Text. The
1N/A# input and output are separated by lines containing only ###.
1N/A
1N/A__DATA__
1N/A
1N/A###
1N/Aalt 1
1N/A###
1N/A=head1 SAMPLE
1N/A
1N/A=over 4
1N/A
1N/A=item F
1N/A
1N/AParagraph.
1N/A
1N/A=item Bar
1N/A
1N/A=item B
1N/A
1N/AParagraph.
1N/A
1N/A=item Longer
1N/A
1N/AParagraph.
1N/A
1N/A=back
1N/A
1N/A###
1N/A
1N/A==== SAMPLE ====
1N/A
1N/A: F Paragraph.
1N/A
1N/A: Bar
1N/A: B Paragraph.
1N/A
1N/A: Longer
1N/A Paragraph.
1N/A
1N/A###
1N/A
1N/A###
1N/Amargin 4
1N/A###
1N/A=head1 SAMPLE
1N/A
1N/AThis is some body text that is long enough to be a paragraph that wraps,
1N/Athereby testing margins with wrapped paragraphs.
1N/A
1N/A This is some verbatim text.
1N/A
1N/A=over 6
1N/A
1N/A=item Test
1N/A
1N/AThis is a test of an indented paragraph.
1N/A
1N/AThis is another indented paragraph.
1N/A
1N/A=back
1N/A###
1N/A SAMPLE
1N/A This is some body text that is long enough to be a paragraph that
1N/A wraps, thereby testing margins with wrapped paragraphs.
1N/A
1N/A This is some verbatim text.
1N/A
1N/A Test This is a test of an indented paragraph.
1N/A
1N/A This is another indented paragraph.
1N/A
1N/A###