diff options
author | 2014-03-24 14:58:42 +0000 | |
---|---|---|
committer | 2014-03-24 14:58:42 +0000 | |
commit | 91f110e064cd7c194e59e019b83bb7496c1c84d4 (patch) | |
tree | 3e8e577405dba7e94b43cbf21c22f21aaa5ab949 /gnu/usr.bin/perl/cpan/Pod-Checker/t/pod | |
parent | do not call purge_task every 10 secs, it is only needed once at startup and (diff) | |
download | wireguard-openbsd-91f110e064cd7c194e59e019b83bb7496c1c84d4.tar.xz wireguard-openbsd-91f110e064cd7c194e59e019b83bb7496c1c84d4.zip |
Import perl-5.18.2
OK espie@ sthen@ deraadt@
Diffstat (limited to 'gnu/usr.bin/perl/cpan/Pod-Checker/t/pod')
9 files changed, 598 insertions, 0 deletions
diff --git a/gnu/usr.bin/perl/cpan/Pod-Checker/t/pod/contains_bad_pod.xr b/gnu/usr.bin/perl/cpan/Pod-Checker/t/pod/contains_bad_pod.xr new file mode 100644 index 00000000000..c7907963d95 --- /dev/null +++ b/gnu/usr.bin/perl/cpan/Pod-Checker/t/pod/contains_bad_pod.xr @@ -0,0 +1,5 @@ +=head foo
+
+bar baz.
+
+=cut
diff --git a/gnu/usr.bin/perl/cpan/Pod-Checker/t/pod/empty.xr b/gnu/usr.bin/perl/cpan/Pod-Checker/t/pod/empty.xr new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/gnu/usr.bin/perl/cpan/Pod-Checker/t/pod/empty.xr diff --git a/gnu/usr.bin/perl/cpan/Pod-Checker/t/pod/podchkenc.t b/gnu/usr.bin/perl/cpan/Pod-Checker/t/pod/podchkenc.t new file mode 100644 index 00000000000..e7a5d7a14fd --- /dev/null +++ b/gnu/usr.bin/perl/cpan/Pod-Checker/t/pod/podchkenc.t @@ -0,0 +1,29 @@ +#!/usr/bin/perl
+BEGIN {
+ use File::Basename;
+ my $THISDIR = dirname $0;
+ unshift @INC, $THISDIR;
+ require "testpchk.pl";
+ import TestPodChecker;
+}
+
+# this tests Pod::Checker accepts =encoding directive
+
+my %options = map { $_ => 1 } @ARGV; ## convert cmdline to options-hash
+my $passed = testpodchecker \%options, $0;
+exit( ($passed == 1) ? 0 : -1 ) unless $ENV{HARNESS_ACTIVE};
+
+__END__
+
+=encoding utf8
+
+=encode utf8
+
+dummy error
+
+=head1 An example.
+
+'Twas brillig, and the slithy toves did gyre and gimble in the wabe.
+
+=cut
+
diff --git a/gnu/usr.bin/perl/cpan/Pod-Checker/t/pod/podchkenc.xr b/gnu/usr.bin/perl/cpan/Pod-Checker/t/pod/podchkenc.xr new file mode 100644 index 00000000000..8a21a1272a4 --- /dev/null +++ b/gnu/usr.bin/perl/cpan/Pod-Checker/t/pod/podchkenc.xr @@ -0,0 +1 @@ +*** ERROR: Unknown command 'encode' at line 20 in file t/pod/podchkenc.t
diff --git a/gnu/usr.bin/perl/cpan/Pod-Checker/t/pod/poderrs.t b/gnu/usr.bin/perl/cpan/Pod-Checker/t/pod/poderrs.t new file mode 100644 index 00000000000..362cbb6575e --- /dev/null +++ b/gnu/usr.bin/perl/cpan/Pod-Checker/t/pod/poderrs.t @@ -0,0 +1,241 @@ +BEGIN {
+ use File::Basename;
+ my $THISDIR = dirname $0;
+ unshift @INC, $THISDIR;
+ require "testpchk.pl";
+ import TestPodChecker;
+}
+
+my %options = map { $_ => 1 } @ARGV; ## convert cmdline to options-hash
+my $passed = testpodchecker \%options, $0;
+exit( ($passed == 1) ? 0 : -1 ) unless $ENV{HARNESS_ACTIVE};
+
+### Deliberately throw in some blank but non-empty lines
+
+### The above line should contain spaces
+
+
+__END__
+
+=head2 This should cause a warning
+
+=head1 NAME
+
+poderrors.t - test Pod::Checker on some pod syntax errors
+
+=unknown1 this is an unknown command with two N<unknownA>
+and D<unknownB> interior sequences.
+
+This is some paragraph text with some unknown interior sequences,
+such as Q<unknown2>,
+A<unknown3>,
+and Y<unknown4 V<unknown5>>.
+
+Now try some unterminated sequences like
+I<hello mudda!
+B<hello fadda!
+
+Here I am at C<camp granada!
+
+Camps is very,
+entertaining.
+And they say we'll have some fun if it stops raining!
+
+Okay, now use a non-empty blank line to terminate a paragraph and make
+sure we get a warning.
+
+The above blank line contains tabs and spaces only
+
+=head1 Additional tests
+
+=head2 item without over
+
+=item oops
+
+=head2 back without over
+
+=back
+
+=head2 over without back
+
+=over 4
+
+=item aaps
+
+=head2 end without begin
+
+=end
+
+=head2 begin and begin
+
+=begin html
+
+=begin text
+
+=end
+
+=end
+
+second one results in end w/o begin
+
+=head2 begin w/o formatter
+
+=begin
+
+=end
+
+=head2 for w/o formatter
+
+=for
+
+something...
+
+=head2 Nested sequences of the same type
+
+C<code I<italic C<code again!>>>
+
+=head2 Garbled entities
+
+E<alea iacta est>
+E<C<auml>>
+E<abcI<bla>>
+E<0x100>
+E<07777>
+E<300>
+
+=head2 Unresolved internal links
+
+L</"begin or begin">
+L<"end with begin">
+L</OoPs>
+
+=head2 Some links with problems
+
+L<abc
+def>
+L<>
+L< aha>
+L<oho >
+L<"Warnings"> this one is ok
+L</unescaped> ok too, this POD has an X of the same name
+L<http://www.perl.org> this is OK
+L<The Perl Home Page|http://www.perl.org> this is also OK
+
+=head2 Warnings
+
+L<passwd(5)>
+L<some text with / in it|perlvar/$|> should give warnings as hell
+
+=over 4
+
+=item bla
+
+=back 200
+
+the 200 is evil
+
+=begin html
+
+What?
+
+=end xml
+
+X<unescaped>see these unescaped < and > in the text?
+
+=head2 Misc
+
+Z<ddd> should be empty
+
+X<> should not be empty
+
+=over four
+
+This paragrapgh is misplaced - it ought to be an item.
+
+=item four should be numeric!
+
+=item
+
+=item blah
+
+=item previous is all empty!!!
+
+=back
+
+All empty over/back:
+
+=over 4
+
+=back
+
+item w/o name
+
+=cut
+
+=pod bla
+
+bla is evil
+
+=cut blub
+
+blub is evil
+
+=head2 reoccurence
+
+=over 4
+
+=item Misc
+
+we already have a head Misc
+
+=back
+
+=head2 some heading
+
+=head2 another one
+
+=head2 the next line should be empty
+=head2 ... but there is a command instead
+
+And here is some text
+=head2 again followed by a command
+
+ verbatim
+=item line missing
+
+previous section is empty!
+
+=head1 LINK TESTS
+
+Due to bug reported by Rafael Garcia-Suarez "rgarciasuarez@free.fr":
+
+The following hyperlinks :
+L<"I/O Operators">
+L<perlop/"I/O Operators">
+trigger a podchecker warning (using bleadperl) :
+ node 'I/O Operators' contains non-escaped | or /
+
+=cut
+
+=pod
+
+=head1 ON-OFF tests
+
+The above =pod is OK. The following =cut is ok, the one after not.
+
+=cut
+
+# some comment or code here, not POD
+
+=cut
+
+# more code
+
+=head2 This opens POD
+
+=pod
+
+And the =pod above is too much.
+
+=cut
+
diff --git a/gnu/usr.bin/perl/cpan/Pod-Checker/t/pod/poderrs.xr b/gnu/usr.bin/perl/cpan/Pod-Checker/t/pod/poderrs.xr new file mode 100644 index 00000000000..c1a80c64787 --- /dev/null +++ b/gnu/usr.bin/perl/cpan/Pod-Checker/t/pod/poderrs.xr @@ -0,0 +1,53 @@ +*** WARNING: =head2 without preceding higher level at line 20 in file t/pod/poderrs.t
+*** WARNING: empty section in previous paragraph at line 22 in file t/pod/poderrs.t
+*** ERROR: Unknown command 'unknown1' at line 26 in file t/pod/poderrs.t
+*** ERROR: Unknown interior-sequence 'Q' at line 30 in file t/pod/poderrs.t
+*** ERROR: Unknown interior-sequence 'A' at line 31 in file t/pod/poderrs.t
+*** ERROR: Unknown interior-sequence 'Y' at line 32 in file t/pod/poderrs.t
+*** ERROR: Unknown interior-sequence 'V' at line 32 in file t/pod/poderrs.t
+*** ERROR: unterminated B<...> at line 36 in file t/pod/poderrs.t
+*** ERROR: unterminated I<...> at line 35 in file t/pod/poderrs.t
+*** ERROR: unterminated C<...> at line 38 in file t/pod/poderrs.t
+*** WARNING: line containing nothing but whitespace in paragraph at line 46 in file t/pod/poderrs.t
+*** ERROR: =item without previous =over at line 53 in file t/pod/poderrs.t
+*** ERROR: =back without previous =over at line 57 in file t/pod/poderrs.t
+*** ERROR: =over on line 61 without closing =back (at head2) at line 65 in file t/pod/poderrs.t
+*** ERROR: =end without =begin at line 67 in file t/pod/poderrs.t
+*** ERROR: Nested =begin's (first at line 71:html) at line 73 in file t/pod/poderrs.t
+*** ERROR: =end without =begin at line 77 in file t/pod/poderrs.t
+*** ERROR: No argument for =begin at line 83 in file t/pod/poderrs.t
+*** ERROR: =for without formatter specification at line 89 in file t/pod/poderrs.t
+*** WARNING: nested commands C<...C<...>...> at line 95 in file t/pod/poderrs.t
+*** ERROR: garbled entity E<alea iacta est> at line 99 in file t/pod/poderrs.t
+*** ERROR: garbled entity E<C<auml>> at line 100 in file t/pod/poderrs.t
+*** ERROR: garbled entity E<abcI<bla>> at line 101 in file t/pod/poderrs.t
+*** ERROR: Entity number out of range E<0x100> at line 102 in file t/pod/poderrs.t
+*** ERROR: Entity number out of range E<07777> at line 103 in file t/pod/poderrs.t
+*** ERROR: Entity number out of range E<300> at line 104 in file t/pod/poderrs.t
+*** ERROR: malformed link L<> : empty link at line 116 in file t/pod/poderrs.t
+*** WARNING: ignoring leading whitespace in link at line 117 in file t/pod/poderrs.t
+*** WARNING: ignoring trailing whitespace in link at line 118 in file t/pod/poderrs.t
+*** WARNING: (section) in 'passwd(5)' deprecated at line 126 in file t/pod/poderrs.t
+*** WARNING: node '$|' contains non-escaped | or / at line 127 in file t/pod/poderrs.t
+*** WARNING: alternative text '$|' contains non-escaped | or / at line 127 in file t/pod/poderrs.t
+*** ERROR: Spurious character(s) after =back at line 133 in file t/pod/poderrs.t
+*** ERROR: Nonempty Z<> at line 147 in file t/pod/poderrs.t
+*** ERROR: Empty X<> at line 149 in file t/pod/poderrs.t
+*** WARNING: preceding non-item paragraph(s) at line 155 in file t/pod/poderrs.t
+*** WARNING: No argument for =item at line 157 in file t/pod/poderrs.t
+*** WARNING: previous =item has no contents at line 159 in file t/pod/poderrs.t
+*** WARNING: No items in =over (at line 167) / =back list at line 169 in file t/pod/poderrs.t
+*** ERROR: Spurious text after =pod at line 175 in file t/pod/poderrs.t
+*** ERROR: Spurious text after =cut at line 179 in file t/pod/poderrs.t
+*** WARNING: empty section in previous paragraph at line 195 in file t/pod/poderrs.t
+*** ERROR: Apparent command =head2 not preceded by blank line at line 198 in file t/pod/poderrs.t
+*** WARNING: empty section in previous paragraph at line 197 in file t/pod/poderrs.t
+*** ERROR: Apparent command =head2 not preceded by blank line at line 201 in file t/pod/poderrs.t
+*** ERROR: Apparent command =item not preceded by blank line at line 204 in file t/pod/poderrs.t
+*** ERROR: Spurious =cut command at line 230 in file t/pod/poderrs.t
+*** ERROR: Spurious =pod command at line 236 in file t/pod/poderrs.t
+*** ERROR: unresolved internal link 'begin or begin' at line 108 in file t/pod/poderrs.t
+*** ERROR: unresolved internal link 'end with begin' at line 109 in file t/pod/poderrs.t
+*** ERROR: unresolved internal link 'OoPs' at line 110 in file t/pod/poderrs.t
+*** ERROR: unresolved internal link 'abc def' at line 114 in file t/pod/poderrs.t
+*** ERROR: unresolved internal link 'I/O Operators' at line 213 in file t/pod/poderrs.t
diff --git a/gnu/usr.bin/perl/cpan/Pod-Checker/t/pod/selfcheck.t b/gnu/usr.bin/perl/cpan/Pod-Checker/t/pod/selfcheck.t new file mode 100644 index 00000000000..3b6e352d3a6 --- /dev/null +++ b/gnu/usr.bin/perl/cpan/Pod-Checker/t/pod/selfcheck.t @@ -0,0 +1,45 @@ +#!/usr/bin/perl
+use File::Basename;
+use File::Spec;
+use strict;
+my $THISDIR;
+BEGIN {
+ $THISDIR = dirname $0;
+ unshift @INC, $THISDIR;
+ require "testpchk.pl";
+ import TestPodChecker qw(testpodcheck);
+}
+
+# test that our POD is correct!
+my $path = File::Spec->catfile($THISDIR,(File::Spec->updir()) x 2, 'lib', 'Pod', '*.pm');
+print "THISDIR=$THISDIR PATH=$path\n";
+my @pods = glob($path);
+print "PODS=@pods\n";
+
+print "1..",scalar(@pods),"\n";
+
+my $errs = 0;
+my $testnum = 1;
+foreach my $pod (@pods) {
+ my $out = File::Spec->catfile($THISDIR, basename($pod));
+ $out =~ s{\.pm}{.OUT};
+ my %options = ( -Out => $out );
+ my $failmsg = testpodcheck(-In => $pod, -Out => $out, -Cmp => "$THISDIR/empty.xr");
+ if($failmsg) {
+ if(open(IN, "<$out")) {
+ while(<IN>) {
+ warn "podchecker: $_";
+ }
+ close(IN);
+ } else {
+ warn "Error: Cannot read output file $out: $!\n";
+ }
+ print "not ok $testnum\n";
+ $errs++;
+ } else {
+ print "ok $testnum\n";
+ }
+ $testnum++;
+}
+exit( ($errs == 0) ? 0 : -1 ) unless $ENV{HARNESS_ACTIVE};
+
diff --git a/gnu/usr.bin/perl/cpan/Pod-Checker/t/pod/testcmp.pl b/gnu/usr.bin/perl/cpan/Pod-Checker/t/pod/testcmp.pl new file mode 100644 index 00000000000..b8592fcc2a8 --- /dev/null +++ b/gnu/usr.bin/perl/cpan/Pod-Checker/t/pod/testcmp.pl @@ -0,0 +1,94 @@ +package TestCompare;
+
+use vars qw(@ISA @EXPORT $MYPKG);
+#use strict;
+#use diagnostics;
+use Carp;
+use Exporter;
+use File::Basename;
+use File::Spec;
+use FileHandle;
+
+@ISA = qw(Exporter);
+@EXPORT = qw(&testcmp);
+$MYPKG = eval { (caller)[0] };
+
+##--------------------------------------------------------------------------
+
+=head1 NAME
+
+testcmp -- compare two files line-by-line
+
+=head1 SYNOPSIS
+
+ $is_diff = testcmp($file1, $file2);
+
+or
+
+ $is_diff = testcmp({-cmplines => \&mycmp}, $file1, $file2);
+
+=head2 DESCRIPTION
+
+Compare two text files line-by-line and return 0 if they are the
+same, 1 if they differ. Each of $file1 and $file2 may be a filenames,
+or a filehandles (in which case it must already be open for reading).
+
+If the first argument is a hashref, then the B<-cmplines> key in the
+hash may have a subroutine reference as its corresponding value.
+The referenced user-defined subroutine should be a line-comparator
+function that takes two pre-chomped text-lines as its arguments
+(the first is from $file1 and the second is from $file2). It should
+return 0 if it considers the two lines equivalent, and non-zero
+otherwise.
+
+=cut
+
+##--------------------------------------------------------------------------
+
+sub testcmp( $ $ ; $) {
+ my %opts = ref($_[0]) eq 'HASH' ? %{shift()} : ();
+ my ($file1, $file2) = @_;
+ my ($fh1, $fh2) = ($file1, $file2);
+ unless (ref $fh1) {
+ $fh1 = FileHandle->new($file1, "r") or die "Can't open $file1: $!";
+ }
+ unless (ref $fh2) {
+ $fh2 = FileHandle->new($file2, "r") or die "Can't open $file2: $!";
+ }
+
+ my $cmplines = $opts{'-cmplines'} || undef;
+ my ($f1text, $f2text) = ("", "");
+ my ($line, $diffs) = (0, 0);
+
+ while ( defined($f1text) and defined($f2text) ) {
+ defined($f1text = <$fh1>) and chomp($f1text);
+ defined($f2text = <$fh2>) and chomp($f2text);
+ ++$line;
+ last unless ( defined($f1text) and defined($f2text) );
+ # kill any extra line endings
+ $f1text =~ s/[\r\n]+$//s;
+ $f2text =~ s/[\r\n]+$//s;
+ $diffs = (ref $cmplines) ? &$cmplines($f1text, $f2text)
+ : ($f1text ne $f2text);
+ last if $diffs;
+ }
+ close($fh1) unless (ref $file1);
+ close($fh2) unless (ref $file2);
+
+ $diffs = 1 if (defined($f1text) or defined($f2text));
+ if ( defined($f1text) and defined($f2text) ) {
+ ## these two lines must be different
+ warn "$file1 and $file2 differ at line $line\n";
+ }
+ elsif (defined($f1text) and (! defined($f1text))) {
+ ## file1 must be shorter
+ warn "$file1 is shorter than $file2\n";
+ }
+ elsif (defined $f2text) {
+ ## file2 must be longer
+ warn "$file1 is shorter than $file2\n";
+ }
+ return $diffs;
+}
+
+1;
diff --git a/gnu/usr.bin/perl/cpan/Pod-Checker/t/pod/testpchk.pl b/gnu/usr.bin/perl/cpan/Pod-Checker/t/pod/testpchk.pl new file mode 100644 index 00000000000..0464a9a0fcf --- /dev/null +++ b/gnu/usr.bin/perl/cpan/Pod-Checker/t/pod/testpchk.pl @@ -0,0 +1,130 @@ +package TestPodChecker;
+
+BEGIN {
+ use File::Basename;
+ use File::Spec;
+ push @INC, '..';
+ my $THISDIR = dirname $0;
+ unshift @INC, $THISDIR;
+ require "testcmp.pl";
+ import TestCompare;
+ my $PARENTDIR = dirname $THISDIR;
+ push @INC, map { File::Spec->catfile($_, 'lib') } ($PARENTDIR, $THISDIR);
+ require VMS::Filespec if $^O eq 'VMS';
+}
+
+use Pod::Checker;
+use vars qw(@ISA @EXPORT $MYPKG);
+#use strict;
+#use diagnostics;
+use Carp;
+use Exporter;
+#use File::Compare;
+
+@ISA = qw(Exporter);
+@EXPORT = qw(&testpodchecker);
+@EXPORT_OK = qw(&testpodcheck);
+$MYPKG = eval { (caller)[0] };
+
+sub stripname( $ ) {
+ local $_ = shift;
+ return /(\w[.\w]*)\s*$/ ? $1 : $_;
+}
+
+sub msgcmp( $ $ ) {
+ ## filter out platform-dependent aspects of error messages
+ my ($line1, $line2) = @_;
+ for ($line1, $line2) {
+ ## remove filenames from error messages to avoid any
+ ## filepath naming differences between OS platforms
+ s/(at line \S+ in file) .*\W(\w+\.[tT])\s*$/$1 \L$2\E/;
+ s/.*\W(\w+\.[tT]) (has \d+ pod syntax error)/\L$1\E $2/;
+ }
+ return ($line1 ne $line2);
+}
+
+sub testpodcheck( @ ) {
+ my %args = @_;
+ my $infile = $args{'-In'} || croak "No input file given!";
+ my $outfile = $args{'-Out'} || croak "No output file given!";
+ my $cmpfile = $args{'-Cmp'} || croak "No compare-result file given!";
+
+ my $different = '';
+ my $testname = basename $infile, '.t', '.xr';
+
+ unless (-e $cmpfile) {
+ my $msg = "*** Can't find comparison file $cmpfile for testing $infile";
+ warn "$msg\n";
+ return $msg;
+ }
+
+ print "# Running podchecker for '$testname'...\n";
+ ## Compare the output against the expected result
+ if ($^O eq 'VMS') {
+ for ($infile, $outfile, $cmpfile) {
+ $_ = VMS::Filespec::unixify($_) unless ref;
+ }
+ }
+ podchecker($infile, $outfile);
+ if ( testcmp({'-cmplines' => \&msgcmp}, $outfile, $cmpfile) ) {
+ $different = "$outfile is different from $cmpfile";
+ }
+ else {
+ unlink($outfile);
+ }
+ return $different;
+}
+
+sub testpodchecker( @ ) {
+ my %opts = (ref $_[0] eq 'HASH') ? %{shift()} : ();
+ my @testpods = @_;
+ my ($testname, $testdir) = ("", "");
+ my ($podfile, $cmpfile) = ("", "");
+ my ($outfile, $errfile) = ("", "");
+ my $passes = 0;
+ my $failed = 0;
+ local $_;
+
+ print "1..", scalar @testpods, "\n" unless ($opts{'-xrgen'});
+
+ for $podfile (@testpods) {
+ ($testname, $_) = fileparse($podfile);
+ $testdir ||= $_;
+ $testname =~ s/\.t$//;
+ $cmpfile = $testdir . $testname . '.xr';
+ $outfile = $testdir . $testname . '.OUT';
+
+ if ($opts{'-xrgen'}) {
+ if ($opts{'-force'} or ! -e $cmpfile) {
+ ## Create the comparison file
+ print "# Creating expected result for \"$testname\"" .
+ " podchecker test ...\n";
+ podchecker($podfile, $cmpfile);
+ }
+ else {
+ print "# File $cmpfile already exists" .
+ " (use '-force' to regenerate it).\n";
+ }
+ next;
+ }
+
+ my $failmsg = testpodcheck
+ -In => $podfile,
+ -Out => $outfile,
+ -Cmp => $cmpfile;
+ if ($failmsg) {
+ ++$failed;
+ print "#\tFAILED. ($failmsg)\n";
+ print "not ok ", $failed+$passes, "\n";
+ }
+ else {
+ ++$passes;
+ unlink($outfile);
+ print "#\tPASSED.\n";
+ print "ok ", $failed+$passes, "\n";
+ }
+ }
+ return $passes;
+}
+
+1;
|