Mark all .t and .pm files as non executable
[p5sagit/p5-mst-13.2.git] / lib / Pod / t / man-options.t
index f00e7d1..04895d5 100644 (file)
@@ -25,6 +25,19 @@ END {
 
 use Pod::Man;
 
+# Redirect stderr to a file.
+sub stderr_save {
+    open (OLDERR, '>&STDERR') or die "Can't dup STDERR: $!\n";
+    open (STDERR, '> out.err') or die "Can't redirect STDERR: $!\n";
+}
+
+# Restore stderr.
+sub stderr_restore {
+    close STDERR;
+    open (STDERR, '>&OLDERR') or die "Can't dup STDERR: $!\n";
+    close OLDERR;
+}
+
 $loaded = 1;
 print "ok 1\n";
 
@@ -45,12 +58,13 @@ while (<DATA>) {
     close TMP;
     my $parser = Pod::Man->new (%options) or die "Cannot create parser\n";
     open (OUT, '> out.tmp') or die "Cannot create out.tmp: $!\n";
+    stderr_save;
     $parser->parse_from_file ('tmp.pod', \*OUT);
+    stderr_restore;
     close OUT;
     my $accents = 0;
     open (TMP, 'out.tmp') or die "Cannot open out.tmp: $!\n";
     while (<TMP>) {
-        $accents = 1 if /Accent mark definitions/;
         last if /^\.nh/;
     }
     my $output;
@@ -60,24 +74,36 @@ while (<DATA>) {
     }
     close TMP;
     unlink ('tmp.pod', 'out.tmp');
-    if (($options{utf8} && !$accents) || (!$options{utf8} && $accents)) {
+    my $expected = '';
+    while (<DATA>) {
+        last if $_ eq "###\n";
+        $expected .= $_;
+    }
+    if ($output eq $expected) {
         print "ok $n\n";
     } else {
         print "not ok $n\n";
-        print ($accents ? "Saw accents\n" : "Saw no accents\n");
-        print ($options{utf8} ? "Wanted no accents\n" : "Wanted accents\n");
+        print "Expected\n========\n$expected\nOutput\n======\n$output\n";
     }
     $n++;
-    my $expected = '';
+    open (ERR, 'out.err') or die "Cannot open out.err: $!\n";
+    my $errors;
+    {
+        local $/;
+        $errors = <ERR>;
+    }
+    close ERR;
+    unlink ('out.err');
+    $expected = '';
     while (<DATA>) {
         last if $_ eq "###\n";
         $expected .= $_;
     }
-    if ($output eq $expected) {
+    if ($errors eq $expected) {
         print "ok $n\n";
     } else {
         print "not ok $n\n";
-        print "Expected\n========\n$expected\nOutput\n======\n$output\n";
+        print "Expected errors:\n    ${expected}Errors:\n    $errors";
     }
     $n++;
 }
@@ -89,54 +115,61 @@ while (<DATA>) {
 __DATA__
 
 ###
-utf8 1
+fixed CR
+fixedbold CY
+fixeditalic CW
+fixedbolditalic CX
 ###
-=head1 BEYONCÉ
-
-Beyoncé!  Beyoncé!  Beyoncé!!
-
-    Beyoncé!  Beyoncé!
-      Beyoncé!  Beyoncé!
-        Beyoncé!  Beyoncé!
+=head1 FIXED FONTS
 
-Older versions did not convert Beyoncé in verbatim.
+C<foo B<bar I<baz>> I<bay>>
+###
+.SH "FIXED FONTS"
+.IX Header "FIXED FONTS"
+\&\f(CR\*(C`foo \f(CYbar \f(CXbaz\f(CY\f(CR \f(CWbay\f(CR\*(C'\fR
 ###
-.SH "BEYONCÉ"
-.IX Header "BEYONCÉ"
-Beyoncé!  Beyoncé!  Beyoncé!!
-.PP
-.Vb 3
-\&    Beyoncé!  Beyoncé!
-\&      Beyoncé!  Beyoncé!
-\&        Beyoncé!  Beyoncé!
-.Ve
-.PP
-Older versions did not convert Beyoncé in verbatim.
 ###
 
 ###
-utf8 1
 ###
-=head1 SE<lt>E<gt> output with UTF-8
+=over 4
+
+=item Foo
+
+Bar.
 
-This is S<non-breaking output>.
+=head1 NEXT
+###
+.IP "Foo" 4
+.IX Item "Foo"
+Bar.
+.SH "NEXT"
+.IX Header "NEXT"
+.SH "POD ERRORS"
+.IX Header "POD ERRORS"
+Hey! \fBThe above document had some coding errors, which are explained below:\fR
+.IP "Around line 7:" 4
+.IX Item "Around line 7:"
+You forgot a '=back' before '=head1'
 ###
-.SH "S<> output with UTF\-8"
-.IX Header "S<> output with UTF-8"
-This is non\-breaking output.
 ###
 
 ###
-fixed CR
-fixedbold CY
-fixeditalic CW
-fixedbolditalic CX
+stderr 1
 ###
-=head1 FIXED FONTS
+=over 4
 
-C<foo B<bar I<baz>> I<bay>>
+=item Foo
+
+Bar.
+
+=head1 NEXT
 ###
-.SH "FIXED FONTS"
-.IX Header "FIXED FONTS"
-\&\f(CR\*(C`foo \f(CYbar \f(CXbaz\f(CY\f(CR \f(CWbay\f(CR\*(C'\fR
+.IP "Foo" 4
+.IX Item "Foo"
+Bar.
+.SH "NEXT"
+.IX Header "NEXT"
+###
+tmp.pod around line 7: You forgot a '=back' before '=head1'
 ###