summaryrefslogtreecommitdiff
path: root/t/pod
diff options
context:
space:
mode:
authorH.Merijn Brand <h.m.brand@xs4all.nl>2005-09-22 14:12:49 +0200
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2005-09-23 15:54:02 +0000
commit12f8b8018bfcb4b65e8ced6f270de8fb3ab8b984 (patch)
tree3433f0649683b1575422f9ce19d3d50dcd92234b /t/pod
parentec1aec95445a95d039a6c0ba6bc5dca901f81175 (diff)
downloadperl-12f8b8018bfcb4b65e8ced6f270de8fb3ab8b984.tar.gz
Re: pod/pod2usage2.t
From: "H.Merijn Brand" <h.m.brand@xs4all.nl> Message-ID: <20050922121249.5077ee3e@pc09> Also, skip all tests on Windows until we find a way to write them portably p4raw-id: //depot/perl@25588
Diffstat (limited to 't/pod')
-rw-r--r--t/pod/pod2usage2.t172
1 files changed, 88 insertions, 84 deletions
diff --git a/t/pod/pod2usage2.t b/t/pod/pod2usage2.t
index 04890f207f..4bdaaee75d 100644
--- a/t/pod/pod2usage2.t
+++ b/t/pod/pod2usage2.t
@@ -1,15 +1,17 @@
#!/usr/bin/perl -w
-use Test;
+use Test::More;
BEGIN {
- plan tests => 8;
+ if ($^O eq 'MSWin32') {
+ plan skip_all => "Not portable on Win32\n";
+ }
+ else {
+ plan tests => 15;
+ }
+ use_ok ("Pod::Usage");
}
-eval "use Pod::Usage";
-
-ok($@ eq '');
-
sub getoutput
{
my ($code) = @_;
@@ -22,7 +24,9 @@ sub getoutput
my @out = <IN>;
close(IN);
my $exit = $?>>8;
- print "\nEXIT=$exit OUTPUT=+++\n@out+++\n";
+ s/^/#/ for @out;
+ local $" = "";
+ print "#EXIT=$exit OUTPUT=+++#@out#+++\n";
return($exit, join("",@out));
}
# child
@@ -35,108 +39,108 @@ sub getoutput
sub compare
{
my ($left,$right) = @_;
- $left =~ s/[ \n]+/\n/sg;
- $right =~ s/[ \n]+/\n/sg;
- $left =~ s/\s+/ /gm;
+ $left =~ s/^#\s+/#/gm;
+ $right =~ s/^#\s+/#/gm;
+ $left =~ s/\s+/ /gm;
$right =~ s/\s+/ /gm;
$left eq $right;
}
-# test 2
my ($exit, $text) = getoutput( sub { pod2usage() } );
-ok($exit == 2 && compare($text, <<'EOT'));
-Usage:
- frobnicate [ -r | --recursive ] [ -f | --force ] [ -n number ] file ...
-
+is ($exit, 2, "Exit status pod2usage ()");
+ok (compare ($text, <<'EOT'), "Output test pod2usage ()");
+#Usage:
+# frobnicate [ -r | --recursive ] [ -f | --force ] [ -n number ] file ...
+#
EOT
-# test 3
($exit, $text) = getoutput( sub { pod2usage(
-message => 'You naughty person, what did you say?',
- -verbose => 1 ) } );
-ok($exit == 1 && compare($text,<<'EOT'));
-You naughty person, what did you say?
- Usage:
- frobnicate [ -r | --recursive ] [ -f | --force ] [ -n number ] file ...
-
- Options:
- -r | --recursive
- Run recursively.
-
- -f | --force
- Just do it!
-
- -n number
- Specify number of frobs, default is 42.
-
+ -verbose => 1 ) });
+is ($exit, 1, "Exit status pod2usage (-message => '...', -verbose => 1)");
+ok (compare ($text, <<'EOT'), "Output test pod2usage (-message => '...', -verbose => 1)");
+#You naughty person, what did you say?
+# Usage:
+# frobnicate [ -r | --recursive ] [ -f | --force ] [ -n number ] file ...
+#
+# Options:
+# -r | --recursive
+# Run recursively.
+#
+# -f | --force
+# Just do it!
+#
+# -n number
+# Specify number of frobs, default is 42.
+#
EOT
-# test 4
($exit, $text) = getoutput( sub { pod2usage(
-verbose => 2, -exit => 42 ) } );
-ok($exit == 42 && compare($text,<<'EOT'));
-NAME
- frobnicate - do what I mean
-
- SYNOPSIS
- frobnicate [ -r | --recursive ] [ -f | --force ] [ -n number ] file ...
-
- DESCRIPTION
- frobnicate does foo and bar and what not.
-
- OPTIONS
- -r | --recursive
- Run recursively.
-
- -f | --force
- Just do it!
-
- -n number
- Specify number of frobs, default is 42.
-
+is ($exit, 42, "Exit status pod2usage (-verbose => 2, -exit => 42)");
+ok (compare ($text, <<'EOT'), "Output test pod2usage (-verbose => 2, -exit => 42)");
+#NAME
+# frobnicate - do what I mean
+#
+# SYNOPSIS
+# frobnicate [ -r | --recursive ] [ -f | --force ] [ -n number ] file ...
+#
+# DESCRIPTION
+# frobnicate does foo and bar and what not.
+#
+# OPTIONS
+# -r | --recursive
+# Run recursively.
+#
+# -f | --force
+# Just do it!
+#
+# -n number
+# Specify number of frobs, default is 42.
+#
EOT
-# test 5
($exit, $text) = getoutput( sub { pod2usage(0) } );
-ok($exit == 0 && compare($text, <<'EOT'));
-Usage:
- frobnicate [ -r | --recursive ] [ -f | --force ] [ -n number ] file ...
-
- Options:
- -r | --recursive
- Run recursively.
-
- -f | --force
- Just do it!
-
- -n number
- Specify number of frobs, default is 42.
-
+is ($exit, 0, "Exit status pod2usage (0)");
+ok (compare ($text, <<'EOT'), "Output test pod2usage (0)");
+#Usage:
+# frobnicate [ -r | --recursive ] [ -f | --force ] [ -n number ] file ...
+#
+# Options:
+# -r | --recursive
+# Run recursively.
+#
+# -f | --force
+# Just do it!
+#
+# -n number
+# Specify number of frobs, default is 42.
+#
EOT
-# test 6
($exit, $text) = getoutput( sub { pod2usage(42) } );
-ok($exit == 42 && compare($text, <<'EOT'));
-Usage:
- frobnicate [ -r | --recursive ] [ -f | --force ] [ -n number ] file ...
-
+is ($exit, 42, "Exit status pod2usage (42)");
+ok (compare ($text, <<'EOT'), "Output test pod2usage (42)");
+#Usage:
+# frobnicate [ -r | --recursive ] [ -f | --force ] [ -n number ] file ...
+#
EOT
-# test 7
($exit, $text) = getoutput( sub { pod2usage(-verbose => 0, -exit => 'NOEXIT') } );
-ok($exit == 0 && compare($text, <<'EOT'));
-Usage:
- frobnicate [ -r | --recursive ] [ -f | --force ] [ -n number ] file ...
-
- --NORMAL-RETURN--
+is ($exit, 0, "Exit status pod2usage (-verbose => 0, -exit => 'NOEXIT')");
+ok (compare ($text, <<'EOT'), "Output test pod2usage (-verbose => 0, -exit => 'NOEXIT')");
+#Usage:
+# frobnicate [ -r | --recursive ] [ -f | --force ] [ -n number ] file ...
+#
+# --NORMAL-RETURN--
EOT
-# test 8
($exit, $text) = getoutput( sub { pod2usage(-verbose => 99, -sections => 'DESCRIPTION') } );
-ok($exit == 1 && compare($text, <<'EOT'));
-Description:
- frobnicate does foo and bar and what not.
-
+is ($exit, 1, "Exit status pod2usage (-verbose => 99, -sections => 'DESCRIPTION')");
+ok (compare ($text, <<'EOT'), "Output test pod2usage (-verbose => 99, -sections => 'DESCRIPTION')");
+#Description:
+# frobnicate does foo and bar and what not.
+#
EOT