summaryrefslogtreecommitdiff
path: root/gnu/usr.bin/perl/lib/Test
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2009-10-12 18:24:50 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2009-10-12 18:24:50 +0000
commit7bed5fce775e8466f8c0c970eaeb5071d8a7718c (patch)
treec0c8e293312f13dfe8f57376c94f545c453ced38 /gnu/usr.bin/perl/lib/Test
parent4c85db8b5736693bd819a09987f0dc89a9f1c24d (diff)
Merge in perl 5.10.1
Diffstat (limited to 'gnu/usr.bin/perl/lib/Test')
-rw-r--r--gnu/usr.bin/perl/lib/Test/Builder.pm401
-rw-r--r--gnu/usr.bin/perl/lib/Test/Builder/Module.pm3
-rw-r--r--gnu/usr.bin/perl/lib/Test/Builder/Tester/Color.pm2
-rw-r--r--gnu/usr.bin/perl/lib/Test/Harness.pm1169
-rw-r--r--gnu/usr.bin/perl/lib/Test/Harness/Assert.pm68
-rw-r--r--gnu/usr.bin/perl/lib/Test/Harness/Changes188
-rw-r--r--gnu/usr.bin/perl/lib/Test/Harness/Iterator.pm61
-rw-r--r--gnu/usr.bin/perl/lib/Test/Harness/Point.pm152
-rw-r--r--gnu/usr.bin/perl/lib/Test/Harness/Results.pm182
-rw-r--r--gnu/usr.bin/perl/lib/Test/Harness/Straps.pm693
-rw-r--r--gnu/usr.bin/perl/lib/Test/Harness/TAP.pod366
-rw-r--r--gnu/usr.bin/perl/lib/Test/Harness/Util.pm133
-rw-r--r--gnu/usr.bin/perl/lib/Test/Harness/bin/prove330
-rw-r--r--gnu/usr.bin/perl/lib/Test/Harness/t/00compile.t24
-rw-r--r--gnu/usr.bin/perl/lib/Test/Harness/t/assert.t28
-rw-r--r--gnu/usr.bin/perl/lib/Test/Harness/t/base.t15
-rw-r--r--gnu/usr.bin/perl/lib/Test/Harness/t/callback.t60
-rw-r--r--gnu/usr.bin/perl/lib/Test/Harness/t/failure.t53
-rwxr-xr-xgnu/usr.bin/perl/lib/Test/Harness/t/from_line.t64
-rwxr-xr-xgnu/usr.bin/perl/lib/Test/Harness/t/harness.t22
-rwxr-xr-xgnu/usr.bin/perl/lib/Test/Harness/t/inc_taint.t28
-rw-r--r--gnu/usr.bin/perl/lib/Test/Harness/t/nonumbers.t14
-rw-r--r--gnu/usr.bin/perl/lib/Test/Harness/t/ok.t8
-rwxr-xr-xgnu/usr.bin/perl/lib/Test/Harness/t/point-parse.t106
-rwxr-xr-xgnu/usr.bin/perl/lib/Test/Harness/t/point.t58
-rwxr-xr-xgnu/usr.bin/perl/lib/Test/Harness/t/prove-globbing.t31
-rwxr-xr-xgnu/usr.bin/perl/lib/Test/Harness/t/prove-switches.t85
-rw-r--r--gnu/usr.bin/perl/lib/Test/Harness/t/strap-analyze.t493
-rw-r--r--gnu/usr.bin/perl/lib/Test/Harness/t/strap.t224
-rw-r--r--gnu/usr.bin/perl/lib/Test/Harness/t/test-harness.t479
-rwxr-xr-xgnu/usr.bin/perl/lib/Test/Harness/t/version.t23
-rw-r--r--gnu/usr.bin/perl/lib/Test/More.pm153
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple.pm2
-rwxr-xr-xgnu/usr.bin/perl/lib/Test/Simple/t/00test_harness_check.t1
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/BEGIN_require_ok.t16
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/BEGIN_use_ok.t11
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/Builder.t30
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/Builder/Builder.t1
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/Builder/carp.t1
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/Builder/create.t22
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/Builder/curr_test.t12
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/Builder/details.t14
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/Builder/has_plan.t1
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/Builder/has_plan2.t1
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/Builder/is_fh.t1
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/Builder/maybe_regex.t1
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/Builder/no_diag.t1
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/Builder/no_ending.t1
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/Builder/no_header.t1
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/Builder/ok_obj.t1
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/Builder/output.t127
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/Builder/reset.t73
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/Builder/reset_outputs.t36
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/Builder/try.t1
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/More.t8
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/Tester/tbt_01basic.t5
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/Tester/tbt_02fhrestore.t1
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/Tester/tbt_03die.t1
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/Tester/tbt_04line_num.t7
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/Tester/tbt_05faildiag.t1
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/Tester/tbt_06errormess.t1
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/Tester/tbt_07args.t1
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/bad_plan.t30
-rwxr-xr-xgnu/usr.bin/perl/lib/Test/Simple/t/bail_out.t17
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/buffer.t1
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/carp.t32
-rwxr-xr-xgnu/usr.bin/perl/lib/Test/Simple/t/circular_data.t1
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/cmp_ok.t1
-rwxr-xr-xgnu/usr.bin/perl/lib/Test/Simple/t/create.t45
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/curr_test.t11
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/details.t93
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/diag.t31
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/died.t1
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/dont_overwrite_die_handler.t1
-rwxr-xr-xgnu/usr.bin/perl/lib/Test/Simple/t/eq_set.t1
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/exit.t120
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/explain.t1
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/extra.t1
-rwxr-xr-xgnu/usr.bin/perl/lib/Test/Simple/t/extra_one.t1
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/fail-like.t5
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/fail-more.t432
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/fail.t61
-rwxr-xr-xgnu/usr.bin/perl/lib/Test/Simple/t/fail_one.t48
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/filehandles.t1
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/fork.t1
-rwxr-xr-xgnu/usr.bin/perl/lib/Test/Simple/t/harness_active.t1
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/has_plan.t23
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/has_plan2.t30
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/import.t1
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/is_deeply_dne_bug.t1
-rwxr-xr-xgnu/usr.bin/perl/lib/Test/Simple/t/is_deeply_fail.t1
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/is_deeply_with_threads.t1
-rwxr-xr-xgnu/usr.bin/perl/lib/Test/Simple/t/is_fh.t29
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/lib/Dummy.pm4
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/lib/MyOverload.pm15
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/lib/NoExporter.pm4
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/lib/SigDie.pm4
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/lib/TieOut.pm29
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/maybe_regex.t50
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/missing.t1
-rwxr-xr-xgnu/usr.bin/perl/lib/Test/Simple/t/no_diag.t8
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/no_ending.t21
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/no_header.t21
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/no_plan.t12
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/no_tests.t1
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/note.t18
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/ok_obj.t29
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/output.t92
-rwxr-xr-xgnu/usr.bin/perl/lib/Test/Simple/t/overload.t30
-rwxr-xr-xgnu/usr.bin/perl/lib/Test/Simple/t/overload_threads.t1
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/plan.t1
-rwxr-xr-xgnu/usr.bin/perl/lib/Test/Simple/t/plan_bad.t1
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/plan_is_noplan.t47
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/plan_no_plan.t1
-rwxr-xr-xgnu/usr.bin/perl/lib/Test/Simple/t/plan_shouldnt_import.t1
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/plan_skip_all.t1
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/pod-coverage.t28
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/pod.t7
-rwxr-xr-xgnu/usr.bin/perl/lib/Test/Simple/t/require_ok.t1
-rwxr-xr-xgnu/usr.bin/perl/lib/Test/Simple/t/reset.t88
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/simple.t1
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/skip.t3
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/skipall.t42
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/tbm_doesnt_set_exported_to.t1
-rwxr-xr-xgnu/usr.bin/perl/lib/Test/Simple/t/tbt_01basic.t62
-rwxr-xr-xgnu/usr.bin/perl/lib/Test/Simple/t/tbt_02fhrestore.t65
-rwxr-xr-xgnu/usr.bin/perl/lib/Test/Simple/t/tbt_03die.t19
-rwxr-xr-xgnu/usr.bin/perl/lib/Test/Simple/t/tbt_04line_num.t15
-rwxr-xr-xgnu/usr.bin/perl/lib/Test/Simple/t/tbt_05faildiag.t51
-rwxr-xr-xgnu/usr.bin/perl/lib/Test/Simple/t/tbt_06errormess.t127
-rwxr-xr-xgnu/usr.bin/perl/lib/Test/Simple/t/tbt_07args.t222
-rwxr-xr-xgnu/usr.bin/perl/lib/Test/Simple/t/thread_taint.t1
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/threads.t1
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/todo.t3
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/try.t35
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/undef.t24
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/use_ok.t1
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/useing.t1
-rw-r--r--gnu/usr.bin/perl/lib/Test/Simple/t/utf8.t1
-rw-r--r--gnu/usr.bin/perl/lib/Test/t/fail.t140
-rw-r--r--gnu/usr.bin/perl/lib/Test/t/skip.t115
-rw-r--r--gnu/usr.bin/perl/lib/Test/t/todo.t212
142 files changed, 1197 insertions, 7580 deletions
diff --git a/gnu/usr.bin/perl/lib/Test/Builder.pm b/gnu/usr.bin/perl/lib/Test/Builder.pm
index 2a136830b5a..cd5779f75b6 100644
--- a/gnu/usr.bin/perl/lib/Test/Builder.pm
+++ b/gnu/usr.bin/perl/lib/Test/Builder.pm
@@ -4,9 +4,16 @@ use 5.006;
use strict;
use warnings;
-our $VERSION = '0.86';
+our $VERSION = '0.92';
$VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval)
+BEGIN {
+ if( $] < 5.008 ) {
+ require Test::Builder::IO::Scalar;
+ }
+}
+
+
# Make Test::Builder thread-safe for ithreads.
BEGIN {
use Config;
@@ -99,7 +106,7 @@ Returns a Test::Builder object representing the current state of the
test.
Since you only run one test per program C<new> always returns the same
-Test::Builder object. No matter how many times you call new(), you're
+Test::Builder object. No matter how many times you call C<new()>, you're
getting the same object. This is called a singleton. This is done so that
multiple modules share such global information as the test counter and
where test output is going.
@@ -161,6 +168,8 @@ sub reset { ## no critic (Subroutines::ProhibitBuiltinHomonyms)
$self->{Have_Plan} = 0;
$self->{No_Plan} = 0;
+ $self->{Have_Output_Plan} = 0;
+
$self->{Original_Pid} = $$;
share( $self->{Curr_Test} );
@@ -180,6 +189,7 @@ sub reset { ## no critic (Subroutines::ProhibitBuiltinHomonyms)
$self->{Todo} = undef;
$self->{Todo_Stack} = [];
$self->{Start_Todo} = 0;
+ $self->{Opened_Testhandles} = 0;
$self->_dup_stdhandles;
@@ -204,10 +214,16 @@ are. You usually only want to call one of these methods.
A convenient way to set up your tests. Call this and Test::Builder
will print the appropriate headers and take the appropriate actions.
-If you call plan(), don't call any of the other methods below.
+If you call C<plan()>, don't call any of the other methods below.
=cut
+my %plan_cmds = (
+ no_plan => \&no_plan,
+ skip_all => \&skip_all,
+ tests => \&_plan_tests,
+);
+
sub plan {
my( $self, $cmd, $arg ) = @_;
@@ -215,27 +231,11 @@ sub plan {
local $Level = $Level + 1;
- $self->croak("You tried to plan twice")
- if $self->{Have_Plan};
+ $self->croak("You tried to plan twice") if $self->{Have_Plan};
- if( $cmd eq 'no_plan' ) {
- $self->carp("no_plan takes no arguments") if $arg;
- $self->no_plan;
- }
- elsif( $cmd eq 'skip_all' ) {
- return $self->skip_all($arg);
- }
- elsif( $cmd eq 'tests' ) {
- if($arg) {
- local $Level = $Level + 1;
- return $self->expected_tests($arg);
- }
- elsif( !defined $arg ) {
- $self->croak("Got an undefined number of tests");
- }
- else {
- $self->croak("You said to run 0 tests");
- }
+ if( my $method = $plan_cmds{$cmd} ) {
+ local $Level = $Level + 1;
+ $self->$method($arg);
}
else {
my @args = grep { defined } ( $cmd, $arg );
@@ -245,12 +245,31 @@ sub plan {
return 1;
}
+
+sub _plan_tests {
+ my($self, $arg) = @_;
+
+ if($arg) {
+ local $Level = $Level + 1;
+ return $self->expected_tests($arg);
+ }
+ elsif( !defined $arg ) {
+ $self->croak("Got an undefined number of tests");
+ }
+ else {
+ $self->croak("You said to run 0 tests");
+ }
+
+ return;
+}
+
+
=item B<expected_tests>
my $max = $Test->expected_tests;
$Test->expected_tests($max);
-Gets/sets the # of tests we expect this test to run and prints out
+Gets/sets the number of tests we expect this test to run and prints out
the appropriate headers.
=cut
@@ -266,7 +285,7 @@ sub expected_tests {
$self->{Expected_Tests} = $max;
$self->{Have_Plan} = 1;
- $self->_print("1..$max\n") unless $self->no_header;
+ $self->_output_plan($max) unless $self->no_header;
}
return $self->{Expected_Tests};
}
@@ -275,12 +294,14 @@ sub expected_tests {
$Test->no_plan;
-Declares that this test will run an indeterminate # of tests.
+Declares that this test will run an indeterminate number of tests.
=cut
sub no_plan {
- my $self = shift;
+ my($self, $arg) = @_;
+
+ $self->carp("no_plan takes no arguments") if $arg;
$self->{No_Plan} = 1;
$self->{Have_Plan} = 1;
@@ -288,11 +309,122 @@ sub no_plan {
return 1;
}
+
+=begin private
+
+=item B<_output_plan>
+
+ $tb->_output_plan($max);
+ $tb->_output_plan($max, $directive);
+ $tb->_output_plan($max, $directive => $reason);
+
+Handles displaying the test plan.
+
+If a C<$directive> and/or C<$reason> are given they will be output with the
+plan. So here's what skipping all tests looks like:
+
+ $tb->_output_plan(0, "SKIP", "Because I said so");
+
+It sets C<< $tb->{Have_Output_Plan} >> and will croak if the plan was already
+output.
+
+=end private
+
+=cut
+
+sub _output_plan {
+ my($self, $max, $directive, $reason) = @_;
+
+ $self->carp("The plan was already output") if $self->{Have_Output_Plan};
+
+ my $plan = "1..$max";
+ $plan .= " # $directive" if defined $directive;
+ $plan .= " $reason" if defined $reason;
+
+ $self->_print("$plan\n");
+
+ $self->{Have_Output_Plan} = 1;
+
+ return;
+}
+
+=item B<done_testing>
+
+ $Test->done_testing();
+ $Test->done_testing($num_tests);
+
+Declares that you are done testing, no more tests will be run after this point.
+
+If a plan has not yet been output, it will do so.
+
+$num_tests is the number of tests you planned to run. If a numbered
+plan was already declared, and if this contradicts, a failing test
+will be run to reflect the planning mistake. If C<no_plan> was declared,
+this will override.
+
+If C<done_testing()> is called twice, the second call will issue a
+failing test.
+
+If C<$num_tests> is omitted, the number of tests run will be used, like
+no_plan.
+
+C<done_testing()> is, in effect, used when you'd want to use C<no_plan>, but
+safer. You'd use it like so:
+
+ $Test->ok($a == $b);
+ $Test->done_testing();
+
+Or to plan a variable number of tests:
+
+ for my $test (@tests) {
+ $Test->ok($test);
+ }
+ $Test->done_testing(@tests);
+
+=cut
+
+sub done_testing {
+ my($self, $num_tests) = @_;
+
+ # If done_testing() specified the number of tests, shut off no_plan.
+ if( defined $num_tests ) {
+ $self->{No_Plan} = 0;
+ }
+ else {
+ $num_tests = $self->current_test;
+ }
+
+ if( $self->{Done_Testing} ) {
+ my($file, $line) = @{$self->{Done_Testing}}[1,2];
+ $self->ok(0, "done_testing() was already called at $file line $line");
+ return;
+ }
+
+ $self->{Done_Testing} = [caller];
+
+ if( $self->expected_tests && $num_tests != $self->expected_tests ) {
+ $self->ok(0, "planned to run @{[ $self->expected_tests ]} ".
+ "but done_testing() expects $num_tests");
+ }
+ else {
+ $self->{Expected_Tests} = $num_tests;
+ }
+
+ $self->_output_plan($num_tests) unless $self->{Have_Output_Plan};
+
+ $self->{Have_Plan} = 1;
+
+ return 1;
+}
+
+
=item B<has_plan>
$plan = $Test->has_plan
-Find out whether a plan has been defined. $plan is either C<undef> (no plan has been set), C<no_plan> (indeterminate # of tests) or an integer (the number of expected tests).
+Find out whether a plan has been defined. C<$plan> is either C<undef> (no plan
+has been set), C<no_plan> (indeterminate # of tests) or an integer (the number
+of expected tests).
=cut
@@ -309,20 +441,16 @@ sub has_plan {
$Test->skip_all;
$Test->skip_all($reason);
-Skips all the tests, using the given $reason. Exits immediately with 0.
+Skips all the tests, using the given C<$reason>. Exits immediately with 0.
=cut
sub skip_all {
my( $self, $reason ) = @_;
- my $out = "1..0";
- $out .= " # Skip $reason" if $reason;
- $out .= "\n";
-
$self->{Skip_All} = 1;
- $self->_print($out) unless $self->no_header;
+ $self->_output_plan(0, "SKIP", $reason) unless $self->no_header;
exit(0);
}
@@ -356,7 +484,7 @@ These actually run the tests, analogous to the functions in Test::More.
They all return true if the test passed, false if the test failed.
-$name is always optional.
+C<$name> is always optional.
=over 4
@@ -364,8 +492,8 @@ $name is always optional.
$Test->ok($test, $name);
-Your basic test. Pass if $test is true, fail if $test is false. Just
-like Test::Simple's ok().
+Your basic test. Pass if C<$test> is true, fail if $test is false. Just
+like Test::Simple's C<ok()>.
=cut
@@ -376,8 +504,6 @@ sub ok {
# store, so we turn it into a boolean.
$test = $test ? 1 : 0;
- $self->_plan_check;
-
lock $self->{Curr_Test};
$self->{Curr_Test}++;
@@ -510,14 +636,14 @@ sub _is_dualvar {
$Test->is_eq($got, $expected, $name);
-Like Test::More's is(). Checks if $got eq $expected. This is the
+Like Test::More's C<is()>. Checks if C<$got eq $expected>. This is the
string version.
=item B<is_num>
$Test->is_num($got, $expected, $name);
-Like Test::More's is(). Checks if $got == $expected. This is the
+Like Test::More's C<is()>. Checks if C<$got == $expected>. This is the
numeric version.
=cut
@@ -607,14 +733,14 @@ DIAGNOSTIC
$Test->isnt_eq($got, $dont_expect, $name);
-Like Test::More's isnt(). Checks if $got ne $dont_expect. This is
+Like Test::More's C<isnt()>. Checks if C<$got ne $dont_expect>. This is
the string version.
=item B<isnt_num>
$Test->isnt_num($got, $dont_expect, $name);
-Like Test::More's isnt(). Checks if $got ne $dont_expect. This is
+Like Test::More's C<isnt()>. Checks if C<$got ne $dont_expect>. This is
the numeric version.
=cut
@@ -656,17 +782,17 @@ sub isnt_num {
$Test->like($this, qr/$regex/, $name);
$Test->like($this, '/$regex/', $name);
-Like Test::More's like(). Checks if $this matches the given $regex.
+Like Test::More's C<like()>. Checks if $this matches the given C<$regex>.
-You'll want to avoid qr// if you want your tests to work before 5.005.
+You'll want to avoid C<qr//> if you want your tests to work before 5.005.
=item B<unlike>
$Test->unlike($this, qr/$regex/, $name);
$Test->unlike($this, '/$regex/', $name);
-Like Test::More's unlike(). Checks if $this B<does not match> the
-given $regex.
+Like Test::More's C<unlike()>. Checks if $this B<does not match> the
+given C<$regex>.
=cut
@@ -688,7 +814,7 @@ sub unlike {
$Test->cmp_ok($this, $type, $that, $name);
-Works just like Test::More's cmp_ok().
+Works just like Test::More's C<cmp_ok()>.
$Test->cmp_ok($big_num, '!=', $other_big_num);
@@ -813,7 +939,7 @@ BAIL_OUT() used to be BAILOUT()
$Test->skip;
$Test->skip($why);
-Skips the current test, reporting $why.
+Skips the current test, reporting C<$why>.
=cut
@@ -822,8 +948,6 @@ sub skip {
$why ||= '';
$self->_unoverload_str( \$why );
- $self->_plan_check;
-
lock( $self->{Curr_Test} );
$self->{Curr_Test}++;
@@ -853,7 +977,7 @@ sub skip {
$Test->todo_skip;
$Test->todo_skip($why);
-Like skip(), only it will declare the test as failing and TODO. Similar
+Like C<skip()>, only it will declare the test as failing and TODO. Similar
to
print "not ok $tnum # TODO $why\n";
@@ -864,8 +988,6 @@ sub todo_skip {
my( $self, $why ) = @_;
$why ||= '';
- $self->_plan_check;
-
lock( $self->{Curr_Test} );
$self->{Curr_Test}++;
@@ -895,10 +1017,10 @@ sub todo_skip {
$Test->skip_rest;
$Test->skip_rest($reason);
-Like skip(), only it skips all the rest of the tests you plan to run
+Like C<skip()>, only it skips all the rest of the tests you plan to run
and terminates the test.
-If you're running under no_plan, it skips once and terminates the
+If you're running under C<no_plan>, it skips once and terminates the
test.
=end _unimplemented
@@ -920,13 +1042,13 @@ These methods are useful when writing your own test methods.
Convenience method for building testing functions that take regular
expressions as arguments, but need to work before perl 5.005.
-Takes a quoted regular expression produced by qr//, or a string
+Takes a quoted regular expression produced by C<qr//>, or a string
representing a regular expression.
Returns a Perl value which may be used instead of the corresponding
-regular expression, or undef if its argument is not recognised.
+regular expression, or C<undef> if its argument is not recognised.
-For example, a version of like(), sans the useful diagnostic messages,
+For example, a version of C<like()>, sans the useful diagnostic messages,
could be written as:
sub laconic_like {
@@ -1029,11 +1151,11 @@ DIAGNOSTIC
my($return_from_code, $error) = $Test->try(sub { code });
Works like eval BLOCK except it ensures it has no effect on the rest
-of the test (ie. $@ is not set) nor is effected by outside
-interference (ie. $SIG{__DIE__}) and works around some quirks in older
+of the test (ie. C<$@> is not set) nor is effected by outside
+interference (ie. C<$SIG{__DIE__}>) and works around some quirks in older
Perls.
-$error is what would normally be in $@.
+C<$error> is what would normally be in C<$@>.
It is suggested you use this in place of eval BLOCK.
@@ -1064,7 +1186,7 @@ sub _try {
my $is_fh = $Test->is_fh($thing);
-Determines if the given $thing can be used as a filehandle.
+Determines if the given C<$thing> can be used as a filehandle.
=cut
@@ -1093,7 +1215,7 @@ sub is_fh {
$Test->level($how_high);
-How far up the call stack should $Test look when reporting where the
+How far up the call stack should C<$Test> look when reporting where the
test failed.
Defaults to 1.
@@ -1158,7 +1280,7 @@ sub use_numbers {
$Test->no_diag($no_diag);
If set true no diagnostics will be printed. This includes calls to
-diag().
+C<diag()>.
=item B<no_ending>
@@ -1208,11 +1330,11 @@ Test::Builder's default output settings will not be affected.
$Test->diag(@msgs);
-Prints out the given @msgs. Like C<print>, arguments are simply
+Prints out the given C<@msgs>. Like C<print>, arguments are simply
appended together.
-Normally, it uses the failure_output() handle, but if this is for a
-TODO test, the todo_output() handle is used.
+Normally, it uses the C<failure_output()> handle, but if this is for a
+TODO test, the C<todo_output()> handle is used.
Output will be indented and marked with a # so as not to interfere
with test output. A newline will be put on the end if there isn't one
@@ -1220,7 +1342,7 @@ already.
We encourage using this rather than calling print directly.
-Returns false. Why? Because diag() is often used in conjunction with
+Returns false. Why? Because C<diag()> is often used in conjunction with
a failing test (C<ok() || diag()>) it "passes through" the failure.
return ok(...) || diag(...);
@@ -1240,7 +1362,7 @@ sub diag {
$Test->note(@msgs);
-Like diag(), but it prints to the C<output()> handle so it will not
+Like C<diag()>, but it prints to the C<output()> handle so it will not
normally be seen by the user except in verbose mode.
=cut
@@ -1318,7 +1440,7 @@ sub explain {
$Test->_print(@msgs);
-Prints to the output() filehandle.
+Prints to the C<output()> filehandle.
=end _private
@@ -1352,28 +1474,32 @@ sub _print_to_fh {
=item B<output>
- $Test->output($fh);
- $Test->output($file);
-
-Where normal "ok/not ok" test output should go.
+=item B<failure_output>
-Defaults to STDOUT.
+=item B<todo_output>
-=item B<failure_output>
+ my $filehandle = $Test->output;
+ $Test->output($filehandle);
+ $Test->output($filename);
+ $Test->output(\$scalar);
- $Test->failure_output($fh);
- $Test->failure_output($file);
+These methods control where Test::Builder will print its output.
+They take either an open C<$filehandle>, a C<$filename> to open and write to
+or a C<$scalar> reference to append to. It will always return a C<$filehandle>.
-Where diagnostic output on test failures and diag() should go.
+B<output> is where normal "ok/not ok" test output goes.
-Defaults to STDERR.
+Defaults to STDOUT.
-=item B<todo_output>
+B<failure_output> is where diagnostic output on test failures and
+C<diag()> goes. It is normally not read by Test::Harness and instead is
+displayed to the user.
- $Test->todo_output($fh);
- $Test->todo_output($file);
+Defaults to STDERR.
-Where diagnostics about todo test failures and diag() should go.
+C<todo_output> is used instead of C<failure_output()> for the
+diagnostics of a failing TODO test. These will not be seen by the
+user.
Defaults to STDOUT.
@@ -1414,6 +1540,18 @@ sub _new_fh {
if( $self->is_fh($file_or_fh) ) {
$fh = $file_or_fh;
}
+ elsif( ref $file_or_fh eq 'SCALAR' ) {
+ # Scalar refs as filehandles was added in 5.8.
+ if( $] >= 5.008 ) {
+ open $fh, ">>", $file_or_fh
+ or $self->croak("Can't open scalar ref $file_or_fh: $!");
+ }
+ # Emulate scalar ref filehandles with a tie.
+ else {
+ $fh = Test::Builder::IO::Scalar->new($file_or_fh)
+ or $self->croak("Can't tie scalar ref $file_or_fh");
+ }
+ }
else {
open $fh, ">", $file_or_fh
or $self->croak("Can't open test output log $file_or_fh: $!");
@@ -1451,12 +1589,10 @@ sub _dup_stdhandles {
return;
}
-my $Opened_Testhandles = 0;
-
sub _open_testhandles {
my $self = shift;
- return if $Opened_Testhandles;
+ return if $self->{Opened_Testhandles};
# We dup STDOUT and STDERR so people can change them in their
# test suites while still getting normal test output.
@@ -1466,7 +1602,7 @@ sub _open_testhandles {
# $self->_copy_io_layers( \*STDOUT, $Testout );
# $self->_copy_io_layers( \*STDERR, $Testerr );
- $Opened_Testhandles = 1;
+ $self->{Opened_Testhandles} = 1;
return;
}
@@ -1509,14 +1645,14 @@ sub reset_outputs {
$tb->carp(@message);
Warns with C<@message> but the message will appear to come from the
-point where the original test function was called (C<$tb->caller>).
+point where the original test function was called (C<< $tb->caller >>).
=item croak
$tb->croak(@message);
Dies with C<@message> but the message will appear to come from the
-point where the original test function was called (C<$tb->caller>).
+point where the original test function was called (C<< $tb->caller >>).
=cut
@@ -1538,16 +1674,6 @@ sub croak {
return die $self->_message_at_caller(@_);
}
-sub _plan_check {
- my $self = shift;
-
- unless( $self->{Have_Plan} ) {
- local $Level = $Level + 2;
- $self->croak("You tried to run a test without a plan");
- }
-
- return;
-}
=back
@@ -1575,9 +1701,6 @@ sub current_test {
lock( $self->{Curr_Test} );
if( defined $num ) {
- $self->croak("Can't change the current test number without a plan!")
- unless $self->{Have_Plan};
-
$self->{Curr_Test} = $num;
# If the test counter is being pushed forward fill in the details.
@@ -1625,7 +1748,7 @@ sub summary {
my @tests = $Test->details;
-Like summary(), but with a lot more detail.
+Like C<summary()>, but with a lot more detail.
$tests[$test_num - 1] =
{ 'ok' => is the test considered a pass?
@@ -1639,7 +1762,7 @@ Like summary(), but with a lot more detail.
'actual_ok' is a reflection of whether or not the test literally
printed 'ok' or 'not ok'. This is for examining the result of 'todo'
-tests.
+tests.
'name' is the name of the test.
@@ -1652,16 +1775,16 @@ of ''. Type can be one of the following:
unknown see below
Sometimes the Test::Builder test counter is incremented without it
-printing any test output, for example, when current_test() is changed.
+printing any test output, for example, when C<current_test()> is changed.
In these cases, Test::Builder doesn't know the result of the test, so
its type is 'unknown'. These details for these tests are filled in.
-They are considered ok, but the name and actual_ok is left undef.
+They are considered ok, but the name and actual_ok is left C<undef>.
For example "not ok 23 - hole count # TODO insufficient donuts" would
result in this structure:
$tests[22] = # 23 - 1, since arrays start from 0.
- { ok => 1, # logically, the test passed since it's todo
+ { ok => 1, # logically, the test passed since its todo
actual_ok => 0, # in absolute terms, it failed
name => 'hole count',
type => 'todo',
@@ -1681,20 +1804,20 @@ sub details {
my $todo_reason = $Test->todo($pack);
If the current tests are considered "TODO" it will return the reason,
-if any. This reason can come from a $TODO variable or the last call
-to C<<todo_start()>>.
+if any. This reason can come from a C<$TODO> variable or the last call
+to C<todo_start()>.
Since a TODO test does not need a reason, this function can return an
-empty string even when inside a TODO block. Use C<<$Test->in_todo>>
+empty string even when inside a TODO block. Use C<< $Test->in_todo >>
to determine if you are currently inside a TODO block.
-todo() is about finding the right package to look for $TODO in. It's
+C<todo()> is about finding the right package to look for C<$TODO> in. It's
pretty good at guessing the right package to look at. It first looks for
the caller based on C<$Level + 1>, since C<todo()> is usually called inside
a test function. As a last resort it will use C<exported_to()>.
Sometimes there is some confusion about where todo() should be looking
-for the $TODO variable. If you want to be sure, tell it explicitly
+for the C<$TODO> variable. If you want to be sure, tell it explicitly
what $pack to use.
=cut
@@ -1716,8 +1839,8 @@ sub todo {
my $todo_reason = $Test->find_TODO();
my $todo_reason = $Test->find_TODO($pack):
-Like C<<todo()>> but only returns the value of C<<$TODO>> ignoring
-C<<todo_start()>>.
+Like C<todo()> but only returns the value of C<$TODO> ignoring
+C<todo_start()>.
=cut
@@ -1836,11 +1959,11 @@ sub todo_end {
my($pack, $file, $line) = $Test->caller;
my($pack, $file, $line) = $Test->caller($height);
-Like the normal caller(), except it reports according to your level().
+Like the normal C<caller()>, except it reports according to your C<level()>.
-C<$height> will be added to the level().
+C<$height> will be added to the C<level()>.
-If caller() winds up off the top of the stack it report the highest context.
+If C<caller()> winds up off the top of the stack it report the highest context.
=cut
@@ -1880,8 +2003,6 @@ sub _sanity_check {
my $self = shift;
$self->_whoa( $self->{Curr_Test} < 0, 'Says here you ran a negative number of tests!' );
- $self->_whoa( !$self->{Have_Plan} and $self->{Curr_Test},
- 'Somehow your tests ran without a plan!' );
$self->_whoa( $self->{Curr_Test} != @{ $self->{Test_Results} },
'Somehow you got a different number of results than tests ran!' );
@@ -1892,8 +2013,8 @@ sub _sanity_check {
$self->_whoa($check, $description);
-A sanity check, similar to assert(). If the $check is true, something
-has gone horribly wrong. It will die with the given $description and
+A sanity check, similar to C<assert()>. If the C<$check> is true, something
+has gone horribly wrong. It will die with the given C<$description> and
a note to contact the author.
=cut
@@ -1915,9 +2036,9 @@ WHOA
_my_exit($exit_num);
-Perl seems to have some trouble with exiting inside an END block. 5.005_03
-and 5.6.1 both seem to do odd things. Instead, this function edits $?
-directly. It should ONLY be called from inside an END block. It
+Perl seems to have some trouble with exiting inside an C<END> block. 5.005_03
+and 5.6.1 both seem to do odd things. Instead, this function edits C<$?>
+directly. It should B<only> be called from inside an C<END> block. It
doesn't actually exit, that's your job.
=cut
@@ -1938,7 +2059,6 @@ sub _ending {
my $self = shift;
my $real_exit_code = $?;
- $self->_sanity_check();
# Don't bother with an ending if this is a forked copy. Only the parent
# should do the ending.
@@ -1946,6 +2066,11 @@ sub _ending {
return;
}
+ # Ran tests but never declared a plan or hit done_testing
+ if( !$self->{Have_Plan} and $self->{Curr_Test} ) {
+ $self->diag("Tests were run but no plan was declared and done_testing() was not seen.");
+ }
+
# Exit if plan() was never called. This is so "require Test::Simple"
# doesn't puke.
if( !$self->{Have_Plan} ) {
@@ -1962,7 +2087,7 @@ sub _ending {
if(@$test_results) {
# The plan? We have no plan.
if( $self->{No_Plan} ) {
- $self->_print("1..$self->{Curr_Test}\n") unless $self->no_header;
+ $self->_output_plan($self->{Curr_Test}) unless $self->no_header;
$self->{Expected_Tests} = $self->{Curr_Test};
}
@@ -2057,12 +2182,11 @@ So the exit codes are...
If you fail more than 254 tests, it will be reported as 254.
-
=head1 THREADS
In perl 5.8.1 and later, Test::Builder is thread-safe. The test
number is shared amongst all threads. This means if one thread sets
-the test number using current_test() they will all be effected.
+the test number using C<current_test()> they will all be effected.
While versions earlier than 5.8.1 had threads they contain too many
bugs to support.
@@ -2070,6 +2194,21 @@ bugs to support.
Test::Builder is only thread-aware if threads.pm is loaded I<before>
Test::Builder.
+=head1 MEMORY
+
+An informative hash, accessable via C<<details()>>, is stored for each
+test you perform. So memory usage will scale linearly with each test
+run. Although this is not a problem for most test suites, it can
+become an issue if you do large (hundred thousands to million)
+combinatorics tests in the same run.
+
+In such cases, you are advised to either split the test file into smaller
+ones, or use a reverse approach, doing "normal" (code) compares and
+triggering fail() should anything go unexpected.
+
+Future versions of Test::Builder will have a way to turn history off.
+
+
=head1 EXAMPLES
CPAN can provide the best examples. Test::Simple, Test::More,
@@ -2089,7 +2228,7 @@ E<lt>schwern@pobox.comE<gt>
Copyright 2002-2008 by chromatic E<lt>chromatic@wgz.orgE<gt> and
Michael G Schwern E<lt>schwern@pobox.comE<gt>.
-This program is free software; you can redistribute it and/or
+This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
See F<http://www.perl.com/perl/misc/Artistic.html>
diff --git a/gnu/usr.bin/perl/lib/Test/Builder/Module.pm b/gnu/usr.bin/perl/lib/Test/Builder/Module.pm
index 75da4aa6b98..a2d8e5bb60c 100644
--- a/gnu/usr.bin/perl/lib/Test/Builder/Module.pm
+++ b/gnu/usr.bin/perl/lib/Test/Builder/Module.pm
@@ -7,7 +7,8 @@ use Test::Builder;
require Exporter;
our @ISA = qw(Exporter);
-our $VERSION = '0.86';
+our $VERSION = '0.92';
+$VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval)
# 5.004's Exporter doesn't have export_to_level.
my $_export_to_level = sub {
diff --git a/gnu/usr.bin/perl/lib/Test/Builder/Tester/Color.pm b/gnu/usr.bin/perl/lib/Test/Builder/Tester/Color.pm
index 125ecc52857..264fddbfd86 100644
--- a/gnu/usr.bin/perl/lib/Test/Builder/Tester/Color.pm
+++ b/gnu/usr.bin/perl/lib/Test/Builder/Tester/Color.pm
@@ -1,9 +1,11 @@
package Test::Builder::Tester::Color;
use strict;
+our $VERSION = "1.18";
require Test::Builder::Tester;
+
=head1 NAME
Test::Builder::Tester::Color - turn on colour in Test::Builder::Tester
diff --git a/gnu/usr.bin/perl/lib/Test/Harness.pm b/gnu/usr.bin/perl/lib/Test/Harness.pm
deleted file mode 100644
index 1991a60f673..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Harness.pm
+++ /dev/null
@@ -1,1169 +0,0 @@
-# -*- Mode: cperl; cperl-indent-level: 4 -*-
-
-package Test::Harness;
-
-require 5.00405;
-use Test::Harness::Straps;
-use Test::Harness::Assert;
-use Exporter;
-use Benchmark;
-use Config;
-use strict;
-
-
-use vars qw(
- $VERSION
- @ISA @EXPORT @EXPORT_OK
- $Verbose $Switches $Debug
- $verbose $switches $debug
- $Columns
- $Timer
- $ML $Last_ML_Print
- $Strap
- $has_time_hires
-);
-
-BEGIN {
- eval q{use Time::HiRes 'time'};
- $has_time_hires = !$@;
-}
-
-=head1 NAME
-
-Test::Harness - Run Perl standard test scripts with statistics
-
-=head1 VERSION
-
-Version 2.64
-
-=cut
-
-$VERSION = '2.64';
-
-# Backwards compatibility for exportable variable names.
-*verbose = *Verbose;
-*switches = *Switches;
-*debug = *Debug;
-
-$ENV{HARNESS_ACTIVE} = 1;
-$ENV{HARNESS_VERSION} = $VERSION;
-
-END {
- # For VMS.
- delete $ENV{HARNESS_ACTIVE};
- delete $ENV{HARNESS_VERSION};
-}
-
-my $Files_In_Dir = $ENV{HARNESS_FILELEAK_IN_DIR};
-
-# Stolen from Params::Util
-sub _CLASS {
- (defined $_[0] and ! ref $_[0] and $_[0] =~ m/^[^\W\d]\w*(?:::\w+)*$/s) ? $_[0] : undef;
-}
-
-# Strap Overloading
-if ( $ENV{HARNESS_STRAPS_CLASS} ) {
- die 'Set HARNESS_STRAP_CLASS, singular, not HARNESS_STRAPS_CLASS';
-}
-my $HARNESS_STRAP_CLASS = $ENV{HARNESS_STRAP_CLASS} || 'Test::Harness::Straps';
-if ( $HARNESS_STRAP_CLASS =~ /\.pm$/ ) {
- # "Class" is actually a filename, that should return the
- # class name as its true return value.
- $HARNESS_STRAP_CLASS = require $HARNESS_STRAP_CLASS;
- if ( !_CLASS($HARNESS_STRAP_CLASS) ) {
- die "HARNESS_STRAP_CLASS '$HARNESS_STRAP_CLASS' is not a valid class name";
- }
-}
-else {
- # It is a class name within the current @INC
- if ( !_CLASS($HARNESS_STRAP_CLASS) ) {
- die "HARNESS_STRAP_CLASS '$HARNESS_STRAP_CLASS' is not a valid class name";
- }
- eval "require $HARNESS_STRAP_CLASS";
- die $@ if $@;
-}
-if ( !$HARNESS_STRAP_CLASS->isa('Test::Harness::Straps') ) {
- die "HARNESS_STRAP_CLASS '$HARNESS_STRAP_CLASS' must be a Test::Harness::Straps subclass";
-}
-
-$Strap = $HARNESS_STRAP_CLASS->new;
-
-sub strap { return $Strap };
-
-@ISA = ('Exporter');
-@EXPORT = qw(&runtests);
-@EXPORT_OK = qw(&execute_tests $verbose $switches);
-
-$Verbose = $ENV{HARNESS_VERBOSE} || 0;
-$Debug = $ENV{HARNESS_DEBUG} || 0;
-$Switches = '-w';
-$Columns = $ENV{HARNESS_COLUMNS} || $ENV{COLUMNS} || 80;
-$Columns--; # Some shells have trouble with a full line of text.
-$Timer = $ENV{HARNESS_TIMER} || 0;
-
-=head1 SYNOPSIS
-
- use Test::Harness;
-
- runtests(@test_files);
-
-=head1 DESCRIPTION
-
-B<STOP!> If all you want to do is write a test script, consider
-using Test::Simple. Test::Harness is the module that reads the
-output from Test::Simple, Test::More and other modules based on
-Test::Builder. You don't need to know about Test::Harness to use
-those modules.
-
-Test::Harness runs tests and expects output from the test in a
-certain format. That format is called TAP, the Test Anything
-Protocol. It is defined in L<Test::Harness::TAP>.
-
-C<Test::Harness::runtests(@tests)> runs all the testscripts named
-as arguments and checks standard output for the expected strings
-in TAP format.
-
-The F<prove> utility is a thin wrapper around Test::Harness.
-
-=head2 Taint mode
-
-Test::Harness will honor the C<-T> or C<-t> in the #! line on your
-test files. So if you begin a test with:
-
- #!perl -T
-
-the test will be run with taint mode on.
-
-=head2 Configuration variables.
-
-These variables can be used to configure the behavior of
-Test::Harness. They are exported on request.
-
-=over 4
-
-=item C<$Test::Harness::Verbose>
-
-The package variable C<$Test::Harness::Verbose> is exportable and can be
-used to let C<runtests()> display the standard output of the script
-without altering the behavior otherwise. The F<prove> utility's C<-v>
-flag will set this.
-
-=item C<$Test::Harness::switches>
-
-The package variable C<$Test::Harness::switches> is exportable and can be
-used to set perl command line options used for running the test
-script(s). The default value is C<-w>. It overrides C<HARNESS_PERL_SWITCHES>.
-
-=item C<$Test::Harness::Timer>
-
-If set to true, and C<Time::HiRes> is available, print elapsed seconds
-after each test file.
-
-=back
-
-
-=head2 Failure
-
-When tests fail, analyze the summary report:
-
- t/base..............ok
- t/nonumbers.........ok
- t/ok................ok
- t/test-harness......ok
- t/waterloo..........dubious
- Test returned status 3 (wstat 768, 0x300)
- DIED. FAILED tests 1, 3, 5, 7, 9, 11, 13, 15, 17, 19
- Failed 10/20 tests, 50.00% okay
- Failed Test Stat Wstat Total Fail List of Failed
- ---------------------------------------------------------------
- t/waterloo.t 3 768 20 10 1 3 5 7 9 11 13 15 17 19
- Failed 1/5 test scripts, 80.00% okay. 10/44 subtests failed, 77.27% okay.
-
-Everything passed but F<t/waterloo.t>. It failed 10 of 20 tests and
-exited with non-zero status indicating something dubious happened.
-
-The columns in the summary report mean:
-
-=over 4
-
-=item B<Failed Test>
-
-The test file which failed.
-
-=item B<Stat>
-
-If the test exited with non-zero, this is its exit status.
-
-=item B<Wstat>
-
-The wait status of the test.
-
-=item B<Total>
-
-Total number of tests expected to run.
-
-=item B<Fail>
-
-Number which failed, either from "not ok" or because they never ran.
-
-=item B<List of Failed>
-
-A list of the tests which failed. Successive failures may be
-abbreviated (ie. 15-20 to indicate that tests 15, 16, 17, 18, 19 and
-20 failed).
-
-=back
-
-
-=head1 FUNCTIONS
-
-The following functions are available.
-
-=head2 runtests( @test_files )
-
-This runs all the given I<@test_files> and divines whether they passed
-or failed based on their output to STDOUT (details above). It prints
-out each individual test which failed along with a summary report and
-a how long it all took.
-
-It returns true if everything was ok. Otherwise it will C<die()> with
-one of the messages in the DIAGNOSTICS section.
-
-=cut
-
-sub runtests {
- my(@tests) = @_;
-
- local ($\, $,);
-
- my ($tot, $failedtests,$todo_passed) = execute_tests(tests => \@tests);
- print get_results($tot, $failedtests,$todo_passed);
-
- my $ok = _all_ok($tot);
-
- assert(($ok xor keys %$failedtests),
- q{ok status jives with $failedtests});
-
- if (! $ok) {
- die("Failed $tot->{bad}/$tot->{tests} test programs. " .
- "@{[$tot->{max} - $tot->{ok}]}/$tot->{max} subtests failed.\n");
- }
-
- return $ok;
-}
-
-# my $ok = _all_ok(\%tot);
-# Tells you if this test run is overall successful or not.
-
-sub _all_ok {
- my($tot) = shift;
-
- return $tot->{bad} == 0 && ($tot->{max} || $tot->{skipped}) ? 1 : 0;
-}
-
-# Returns all the files in a directory. This is shorthand for backwards
-# compatibility on systems where C<glob()> doesn't work right.
-
-sub _globdir {
- local *DIRH;
-
- opendir DIRH, shift;
- my @f = readdir DIRH;
- closedir DIRH;
-
- return @f;
-}
-
-=head2 execute_tests( tests => \@test_files, out => \*FH )
-
-Runs all the given C<@test_files> (just like C<runtests()>) but
-doesn't generate the final report. During testing, progress
-information will be written to the currently selected output
-filehandle (usually C<STDOUT>), or to the filehandle given by the
-C<out> parameter. The I<out> is optional.
-
-Returns a list of two values, C<$total> and C<$failed>, describing the
-results. C<$total> is a hash ref summary of all the tests run. Its
-keys and values are this:
-
- bonus Number of individual todo tests unexpectedly passed
- max Number of individual tests ran
- ok Number of individual tests passed
- sub_skipped Number of individual tests skipped
- todo Number of individual todo tests
-
- files Number of test files ran
- good Number of test files passed
- bad Number of test files failed
- tests Number of test files originally given
- skipped Number of test files skipped
-
-If C<< $total->{bad} == 0 >> and C<< $total->{max} > 0 >>, you've
-got a successful test.
-
-C<$failed> is a hash ref of all the test scripts that failed. Each key
-is the name of a test script, each value is another hash representing
-how that script failed. Its keys are these:
-
- name Name of the test which failed
- estat Script's exit value
- wstat Script's wait status
- max Number of individual tests
- failed Number which failed
- canon List of tests which failed (as string).
-
-C<$failed> should be empty if everything passed.
-
-=cut
-
-sub execute_tests {
- my %args = @_;
- my @tests = @{$args{tests}};
- my $out = $args{out} || select();
-
- # We allow filehandles that are symbolic refs
- no strict 'refs';
- _autoflush($out);
- _autoflush(\*STDERR);
-
- my %failedtests;
- my %todo_passed;
-
- # Test-wide totals.
- my(%tot) = (
- bonus => 0,
- max => 0,
- ok => 0,
- files => 0,
- bad => 0,
- good => 0,
- tests => scalar @tests,
- sub_skipped => 0,
- todo => 0,
- skipped => 0,
- bench => 0,
- );
-
- my @dir_files;
- @dir_files = _globdir $Files_In_Dir if defined $Files_In_Dir;
- my $run_start_time = new Benchmark;
-
- my $width = _leader_width(@tests);
- foreach my $tfile (@tests) {
- $Last_ML_Print = 0; # so each test prints at least once
- my($leader, $ml) = _mk_leader($tfile, $width);
- local $ML = $ml;
-
- print $out $leader;
-
- $tot{files}++;
-
- $Strap->{_seen_header} = 0;
- if ( $Test::Harness::Debug ) {
- print $out "# Running: ", $Strap->_command_line($tfile), "\n";
- }
- my $test_start_time = $Timer ? time : 0;
- my $results = $Strap->analyze_file($tfile) or
- do { warn $Strap->{error}, "\n"; next };
- my $elapsed;
- if ( $Timer ) {
- $elapsed = time - $test_start_time;
- if ( $has_time_hires ) {
- $elapsed = sprintf( " %8d ms", $elapsed*1000 );
- }
- else {
- $elapsed = sprintf( " %8s s", $elapsed ? $elapsed : "<1" );
- }
- }
- else {
- $elapsed = "";
- }
-
- # state of the current test.
- my @failed = grep { !$results->details->[$_-1]{ok} }
- 1..@{$results->details};
- my @todo_pass = grep { $results->details->[$_-1]{actual_ok} &&
- $results->details->[$_-1]{type} eq 'todo' }
- 1..@{$results->details};
-
- my %test = (
- ok => $results->ok,
- 'next' => $Strap->{'next'},
- max => $results->max,
- failed => \@failed,
- todo_pass => \@todo_pass,
- todo => $results->todo,
- bonus => $results->bonus,
- skipped => $results->skip,
- skip_reason => $results->skip_reason,
- skip_all => $Strap->{skip_all},
- ml => $ml,
- );
-
- $tot{bonus} += $results->bonus;
- $tot{max} += $results->max;
- $tot{ok} += $results->ok;
- $tot{todo} += $results->todo;
- $tot{sub_skipped} += $results->skip;
-
- my $estatus = $results->exit;
- my $wstatus = $results->wait;
-
- if ( $results->passing ) {
- # XXX Combine these first two
- if ($test{max} and $test{skipped} + $test{bonus}) {
- my @msg;
- push(@msg, "$test{skipped}/$test{max} skipped: $test{skip_reason}")
- if $test{skipped};
- if ($test{bonus}) {
- my ($txt, $canon) = _canondetail($test{todo},0,'TODO passed',
- @{$test{todo_pass}});
- $todo_passed{$tfile} = {
- canon => $canon,
- max => $test{todo},
- failed => $test{bonus},
- name => $tfile,
- estat => '',
- wstat => '',
- };
-
- push(@msg, "$test{bonus}/$test{max} unexpectedly succeeded\n$txt");
- }
- print $out "$test{ml}ok$elapsed\n ".join(', ', @msg)."\n";
- }
- elsif ( $test{max} ) {
- print $out "$test{ml}ok$elapsed\n";
- }
- elsif ( defined $test{skip_all} and length $test{skip_all} ) {
- print $out "skipped\n all skipped: $test{skip_all}\n";
- $tot{skipped}++;
- }
- else {
- print $out "skipped\n all skipped: no reason given\n";
- $tot{skipped}++;
- }
- $tot{good}++;
- }
- else {
- # List unrun tests as failures.
- if ($test{'next'} <= $test{max}) {
- push @{$test{failed}}, $test{'next'}..$test{max};
- }
- # List overruns as failures.
- else {
- my $details = $results->details;
- foreach my $overrun ($test{max}+1..@$details) {
- next unless ref $details->[$overrun-1];
- push @{$test{failed}}, $overrun
- }
- }
-
- if ($wstatus) {
- $failedtests{$tfile} = _dubious_return(\%test, \%tot,
- $estatus, $wstatus);
- $failedtests{$tfile}{name} = $tfile;
- }
- elsif ( $results->seen ) {
- if (@{$test{failed}} and $test{max}) {
- my ($txt, $canon) = _canondetail($test{max},$test{skipped},'Failed',
- @{$test{failed}});
- print $out "$test{ml}$txt";
- $failedtests{$tfile} = { canon => $canon,
- max => $test{max},
- failed => scalar @{$test{failed}},
- name => $tfile,
- estat => '',
- wstat => '',
- };
- }
- else {
- print $out "Don't know which tests failed: got $test{ok} ok, ".
- "expected $test{max}\n";
- $failedtests{$tfile} = { canon => '??',
- max => $test{max},
- failed => '??',
- name => $tfile,
- estat => '',
- wstat => '',
- };
- }
- $tot{bad}++;
- }
- else {
- print $out "FAILED before any test output arrived\n";
- $tot{bad}++;
- $failedtests{$tfile} = { canon => '??',
- max => '??',
- failed => '??',
- name => $tfile,
- estat => '',
- wstat => '',
- };
- }
- }
-
- if (defined $Files_In_Dir) {
- my @new_dir_files = _globdir $Files_In_Dir;
- if (@new_dir_files != @dir_files) {
- my %f;
- @f{@new_dir_files} = (1) x @new_dir_files;
- delete @f{@dir_files};
- my @f = sort keys %f;
- print $out "LEAKED FILES: @f\n";
- @dir_files = @new_dir_files;
- }
- }
- } # foreach test
- $tot{bench} = timediff(new Benchmark, $run_start_time);
-
- $Strap->_restore_PERL5LIB;
-
- return(\%tot, \%failedtests, \%todo_passed);
-}
-
-# Turns on autoflush for the handle passed
-sub _autoflush {
- my $flushy_fh = shift;
- my $old_fh = select $flushy_fh;
- $| = 1;
- select $old_fh;
-}
-
-=for private _mk_leader
-
- my($leader, $ml) = _mk_leader($test_file, $width);
-
-Generates the 't/foo........' leader for the given C<$test_file> as well
-as a similar version which will overwrite the current line (by use of
-\r and such). C<$ml> may be empty if Test::Harness doesn't think you're
-on TTY.
-
-The C<$width> is the width of the "yada/blah.." string.
-
-=cut
-
-sub _mk_leader {
- my($te, $width) = @_;
- chomp($te);
- $te =~ s/\.\w+$/./;
-
- if ($^O eq 'VMS') {
- $te =~ s/^.*\.t\./\[.t./s;
- }
- my $leader = "$te" . '.' x ($width - length($te));
- my $ml = "";
-
- if ( -t STDOUT and not $ENV{HARNESS_NOTTY} and not $Verbose ) {
- $ml = "\r" . (' ' x 77) . "\r$leader"
- }
-
- return($leader, $ml);
-}
-
-=for private _leader_width
-
- my($width) = _leader_width(@test_files);
-
-Calculates how wide the leader should be based on the length of the
-longest test name.
-
-=cut
-
-sub _leader_width {
- my $maxlen = 0;
- my $maxsuflen = 0;
- foreach (@_) {
- my $suf = /\.(\w+)$/ ? $1 : '';
- my $len = length;
- my $suflen = length $suf;
- $maxlen = $len if $len > $maxlen;
- $maxsuflen = $suflen if $suflen > $maxsuflen;
- }
- # + 3 : we want three dots between the test name and the "ok"
- return $maxlen + 3 - $maxsuflen;
-}
-
-sub get_results {
- my $tot = shift;
- my $failedtests = shift;
- my $todo_passed = shift;
-
- my $out = '';
-
- my $bonusmsg = _bonusmsg($tot);
-
- if (_all_ok($tot)) {
- $out .= "All tests successful$bonusmsg.\n";
- if ($tot->{bonus}) {
- my($fmt_top, $fmt) = _create_fmts("Passed TODO",$todo_passed);
- # Now write to formats
- $out .= swrite( $fmt_top );
- for my $script (sort keys %{$todo_passed||{}}) {
- my $Curtest = $todo_passed->{$script};
- $out .= swrite( $fmt, @{ $Curtest }{qw(name estat wstat max failed canon)} );
- }
- }
- }
- elsif (!$tot->{tests}){
- die "FAILED--no tests were run for some reason.\n";
- }
- elsif (!$tot->{max}) {
- my $blurb = $tot->{tests}==1 ? "script" : "scripts";
- die "FAILED--$tot->{tests} test $blurb could be run, ".
- "alas--no output ever seen\n";
- }
- else {
- my $subresults = sprintf( " %d/%d subtests failed.",
- $tot->{max} - $tot->{ok}, $tot->{max} );
-
- my($fmt_top, $fmt1, $fmt2) = _create_fmts("Failed Test",$failedtests);
-
- # Now write to formats
- $out .= swrite( $fmt_top );
- for my $script (sort keys %$failedtests) {
- my $Curtest = $failedtests->{$script};
- $out .= swrite( $fmt1, @{ $Curtest }{qw(name estat wstat max failed canon)} );
- $out .= swrite( $fmt2, $Curtest->{canon} );
- }
- if ($tot->{bad}) {
- $bonusmsg =~ s/^,\s*//;
- $out .= "$bonusmsg.\n" if $bonusmsg;
- $out .= "Failed $tot->{bad}/$tot->{tests} test scripts.$subresults\n";
- }
- }
-
- $out .= sprintf("Files=%d, Tests=%d, %s\n",
- $tot->{files}, $tot->{max}, timestr($tot->{bench}, 'nop'));
- return $out;
-}
-
-sub swrite {
- my $format = shift;
- $^A = '';
- formline($format,@_);
- my $out = $^A;
- $^A = '';
- return $out;
-}
-
-
-my %Handlers = (
- header => \&header_handler,
- test => \&test_handler,
- bailout => \&bailout_handler,
-);
-
-$Strap->set_callback(\&strap_callback);
-sub strap_callback {
- my($self, $line, $type, $totals) = @_;
- print $line if $Verbose;
-
- my $meth = $Handlers{$type};
- $meth->($self, $line, $type, $totals) if $meth;
-};
-
-
-sub header_handler {
- my($self, $line, $type, $totals) = @_;
-
- warn "Test header seen more than once!\n" if $self->{_seen_header};
-
- $self->{_seen_header}++;
-
- warn "1..M can only appear at the beginning or end of tests\n"
- if $totals->seen && ($totals->max < $totals->seen);
-};
-
-sub test_handler {
- my($self, $line, $type, $totals) = @_;
-
- my $curr = $totals->seen;
- my $next = $self->{'next'};
- my $max = $totals->max;
- my $detail = $totals->details->[-1];
-
- if( $detail->{ok} ) {
- _print_ml_less("ok $curr/$max");
-
- if( $detail->{type} eq 'skip' ) {
- $totals->set_skip_reason( $detail->{reason} )
- unless defined $totals->skip_reason;
- $totals->set_skip_reason( 'various reasons' )
- if $totals->skip_reason ne $detail->{reason};
- }
- }
- else {
- _print_ml("NOK $curr/$max");
- }
-
- if( $curr > $next ) {
- print "Test output counter mismatch [test $curr]\n";
- }
- elsif( $curr < $next ) {
- print "Confused test output: test $curr answered after ".
- "test ", $next - 1, "\n";
- }
-
-};
-
-sub bailout_handler {
- my($self, $line, $type, $totals) = @_;
-
- die "FAILED--Further testing stopped" .
- ($self->{bailout_reason} ? ": $self->{bailout_reason}\n" : ".\n");
-};
-
-
-sub _print_ml {
- print join '', $ML, @_ if $ML;
-}
-
-
-# Print updates only once per second.
-sub _print_ml_less {
- my $now = CORE::time;
- if ( $Last_ML_Print != $now ) {
- _print_ml(@_);
- $Last_ML_Print = $now;
- }
-}
-
-sub _bonusmsg {
- my($tot) = @_;
-
- my $bonusmsg = '';
- $bonusmsg = (" ($tot->{bonus} subtest".($tot->{bonus} > 1 ? 's' : '').
- " UNEXPECTEDLY SUCCEEDED)")
- if $tot->{bonus};
-
- if ($tot->{skipped}) {
- $bonusmsg .= ", $tot->{skipped} test"
- . ($tot->{skipped} != 1 ? 's' : '');
- if ($tot->{sub_skipped}) {
- $bonusmsg .= " and $tot->{sub_skipped} subtest"
- . ($tot->{sub_skipped} != 1 ? 's' : '');
- }
- $bonusmsg .= ' skipped';
- }
- elsif ($tot->{sub_skipped}) {
- $bonusmsg .= ", $tot->{sub_skipped} subtest"
- . ($tot->{sub_skipped} != 1 ? 's' : '')
- . " skipped";
- }
- return $bonusmsg;
-}
-
-# Test program go boom.
-sub _dubious_return {
- my($test, $tot, $estatus, $wstatus) = @_;
-
- my $failed = '??';
- my $canon = '??';
-
- printf "$test->{ml}dubious\n\tTest returned status $estatus ".
- "(wstat %d, 0x%x)\n",
- $wstatus,$wstatus;
- print "\t\t(VMS status is $estatus)\n" if $^O eq 'VMS';
-
- $tot->{bad}++;
-
- if ($test->{max}) {
- if ($test->{'next'} == $test->{max} + 1 and not @{$test->{failed}}) {
- print "\tafter all the subtests completed successfully\n";
- $failed = 0; # But we do not set $canon!
- }
- else {
- push @{$test->{failed}}, $test->{'next'}..$test->{max};
- $failed = @{$test->{failed}};
- (my $txt, $canon) = _canondetail($test->{max},$test->{skipped},'Failed',@{$test->{failed}});
- print "DIED. ",$txt;
- }
- }
-
- return { canon => $canon, max => $test->{max} || '??',
- failed => $failed,
- estat => $estatus, wstat => $wstatus,
- };
-}
-
-
-sub _create_fmts {
- my $failed_str = shift;
- my $failedtests = shift;
-
- my ($type) = split /\s/,$failed_str;
- my $short = substr($type,0,4);
- my $total = $short eq 'Pass' ? 'TODOs' : 'Total';
- my $middle_str = " Stat Wstat $total $short ";
- my $list_str = "List of $type";
-
- # Figure out our longest name string for formatting purposes.
- my $max_namelen = length($failed_str);
- foreach my $script (keys %$failedtests) {
- my $namelen = length $failedtests->{$script}->{name};
- $max_namelen = $namelen if $namelen > $max_namelen;
- }
-
- my $list_len = $Columns - length($middle_str) - $max_namelen;
- if ($list_len < length($list_str)) {
- $list_len = length($list_str);
- $max_namelen = $Columns - length($middle_str) - $list_len;
- if ($max_namelen < length($failed_str)) {
- $max_namelen = length($failed_str);
- $Columns = $max_namelen + length($middle_str) + $list_len;
- }
- }
-
- my $fmt_top = sprintf("%-${max_namelen}s", $failed_str)
- . $middle_str
- . $list_str . "\n"
- . "-" x $Columns
- . "\n";
-
- my $fmt1 = "@" . "<" x ($max_namelen - 1)
- . " @>> @>>>> @>>>> @>>> "
- . "^" . "<" x ($list_len - 1) . "\n";
- my $fmt2 = "~~" . " " x ($Columns - $list_len - 2) . "^"
- . "<" x ($list_len - 1) . "\n";
-
- return($fmt_top, $fmt1, $fmt2);
-}
-
-sub _canondetail {
- my $max = shift;
- my $skipped = shift;
- my $type = shift;
- my @detail = @_;
- my %seen;
- @detail = sort {$a <=> $b} grep !$seen{$_}++, @detail;
- my $detail = @detail;
- my @result = ();
- my @canon = ();
- my $min;
- my $last = $min = shift @detail;
- my $canon;
- my $uc_type = uc($type);
- if (@detail) {
- for (@detail, $detail[-1]) { # don't forget the last one
- if ($_ > $last+1 || $_ == $last) {
- push @canon, ($min == $last) ? $last : "$min-$last";
- $min = $_;
- }
- $last = $_;
- }
- local $" = ", ";
- push @result, "$uc_type tests @canon\n";
- $canon = join ' ', @canon;
- }
- else {
- push @result, "$uc_type test $last\n";
- $canon = $last;
- }
-
- return (join("", @result), $canon)
- if $type=~/todo/i;
- push @result, "\t$type $detail/$max tests, ";
- if ($max) {
- push @result, sprintf("%.2f",100*(1-$detail/$max)), "% okay";
- }
- else {
- push @result, "?% okay";
- }
- my $ender = 's' x ($skipped > 1);
- if ($skipped) {
- my $good = $max - $detail - $skipped;
- my $skipmsg = " (less $skipped skipped test$ender: $good okay, ";
- if ($max) {
- my $goodper = sprintf("%.2f",100*($good/$max));
- $skipmsg .= "$goodper%)";
- }
- else {
- $skipmsg .= "?%)";
- }
- push @result, $skipmsg;
- }
- push @result, "\n";
- my $txt = join "", @result;
- return ($txt, $canon);
-}
-
-1;
-__END__
-
-
-=head1 EXPORT
-
-C<&runtests> is exported by Test::Harness by default.
-
-C<&execute_tests>, C<$verbose>, C<$switches> and C<$debug> are
-exported upon request.
-
-=head1 DIAGNOSTICS
-
-=over 4
-
-=item C<All tests successful.\nFiles=%d, Tests=%d, %s>
-
-If all tests are successful some statistics about the performance are
-printed.
-
-=item C<FAILED tests %s\n\tFailed %d/%d tests, %.2f%% okay.>
-
-For any single script that has failing subtests statistics like the
-above are printed.
-
-=item C<Test returned status %d (wstat %d)>
-
-Scripts that return a non-zero exit status, both C<$? E<gt>E<gt> 8>
-and C<$?> are printed in a message similar to the above.
-
-=item C<Failed 1 test, %.2f%% okay. %s>
-
-=item C<Failed %d/%d tests, %.2f%% okay. %s>
-
-If not all tests were successful, the script dies with one of the
-above messages.
-
-=item C<FAILED--Further testing stopped: %s>
-
-If a single subtest decides that further testing will not make sense,
-the script dies with this message.
-
-=back
-
-=head1 ENVIRONMENT VARIABLES THAT TEST::HARNESS SETS
-
-Test::Harness sets these before executing the individual tests.
-
-=over 4
-
-=item C<HARNESS_ACTIVE>
-
-This is set to a true value. It allows the tests to determine if they
-are being executed through the harness or by any other means.
-
-=item C<HARNESS_VERSION>
-
-This is the version of Test::Harness.
-
-=back
-
-=head1 ENVIRONMENT VARIABLES THAT AFFECT TEST::HARNESS
-
-=over 4
-
-=item C<HARNESS_COLUMNS>
-
-This value will be used for the width of the terminal. If it is not
-set then it will default to C<COLUMNS>. If this is not set, it will
-default to 80. Note that users of Bourne-sh based shells will need to
-C<export COLUMNS> for this module to use that variable.
-
-=item C<HARNESS_COMPILE_TEST>
-
-When true it will make harness attempt to compile the test using
-C<perlcc> before running it.
-
-B<NOTE> This currently only works when sitting in the perl source
-directory!
-
-=item C<HARNESS_DEBUG>
-
-If true, Test::Harness will print debugging information about itself as
-it runs the tests. This is different from C<HARNESS_VERBOSE>, which prints
-the output from the test being run. Setting C<$Test::Harness::Debug> will
-override this, or you can use the C<-d> switch in the F<prove> utility.
-
-=item C<HARNESS_FILELEAK_IN_DIR>
-
-When set to the name of a directory, harness will check after each
-test whether new files appeared in that directory, and report them as
-
- LEAKED FILES: scr.tmp 0 my.db
-
-If relative, directory name is with respect to the current directory at
-the moment runtests() was called. Putting absolute path into
-C<HARNESS_FILELEAK_IN_DIR> may give more predictable results.
-
-=item C<HARNESS_NOTTY>
-
-When set to a true value, forces it to behave as though STDOUT were
-not a console. You may need to set this if you don't want harness to
-output more frequent progress messages using carriage returns. Some
-consoles may not handle carriage returns properly (which results in a
-somewhat messy output).
-
-=item C<HARNESS_PERL>
-
-Usually your tests will be run by C<$^X>, the currently-executing Perl.
-However, you may want to have it run by a different executable, such as
-a threading perl, or a different version.
-
-If you're using the F<prove> utility, you can use the C<--perl> switch.
-
-=item C<HARNESS_PERL_SWITCHES>
-
-Its value will be prepended to the switches used to invoke perl on
-each test. For example, setting C<HARNESS_PERL_SWITCHES> to C<-W> will
-run all tests with all warnings enabled.
-
-=item C<HARNESS_TIMER>
-
-Setting this to true will make the harness display the number of
-milliseconds each test took. You can also use F<prove>'s C<--timer>
-switch.
-
-=item C<HARNESS_VERBOSE>
-
-If true, Test::Harness will output the verbose results of running
-its tests. Setting C<$Test::Harness::verbose> will override this,
-or you can use the C<-v> switch in the F<prove> utility.
-
-If true, Test::Harness will output the verbose results of running
-its tests. Setting C<$Test::Harness::verbose> will override this,
-or you can use the C<-v> switch in the F<prove> utility.
-
-=item C<HARNESS_STRAP_CLASS>
-
-Defines the Test::Harness::Straps subclass to use. The value may either
-be a filename or a class name.
-
-If HARNESS_STRAP_CLASS is a class name, the class must be in C<@INC>
-like any other class.
-
-If HARNESS_STRAP_CLASS is a filename, the .pm file must return the name
-of the class, instead of the canonical "1".
-
-=back
-
-=head1 EXAMPLE
-
-Here's how Test::Harness tests itself
-
- $ cd ~/src/devel/Test-Harness
- $ perl -Mblib -e 'use Test::Harness qw(&runtests $verbose);
- $verbose=0; runtests @ARGV;' t/*.t
- Using /home/schwern/src/devel/Test-Harness/blib
- t/base..............ok
- t/nonumbers.........ok
- t/ok................ok
- t/test-harness......ok
- All tests successful.
- Files=4, Tests=24, 2 wallclock secs ( 0.61 cusr + 0.41 csys = 1.02 CPU)
-
-=head1 SEE ALSO
-
-The included F<prove> utility for running test scripts from the command line,
-L<Test> and L<Test::Simple> for writing test scripts, L<Benchmark> for
-the underlying timing routines, and L<Devel::Cover> for test coverage
-analysis.
-
-=head1 TODO
-
-Provide a way of running tests quietly (ie. no printing) for automated
-validation of tests. This will probably take the form of a version
-of runtests() which rather than printing its output returns raw data
-on the state of the tests. (Partially done in Test::Harness::Straps)
-
-Document the format.
-
-Fix HARNESS_COMPILE_TEST without breaking its core usage.
-
-Figure a way to report test names in the failure summary.
-
-Rework the test summary so long test names are not truncated as badly.
-(Partially done with new skip test styles)
-
-Add option for coverage analysis.
-
-Trap STDERR.
-
-Implement Straps total_results()
-
-Remember exit code
-
-Completely redo the print summary code.
-
-Straps->analyze_file() not taint clean, don't know if it can be
-
-Fix that damned VMS nit.
-
-Add a test for verbose.
-
-Change internal list of test results to a hash.
-
-Fix stats display when there's an overrun.
-
-Fix so perls with spaces in the filename work.
-
-Keeping whittling away at _run_all_tests()
-
-Clean up how the summary is printed. Get rid of those damned formats.
-
-=head1 BUGS
-
-Please report any bugs or feature requests to
-C<bug-test-harness at rt.cpan.org>, or through the web interface at
-L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Harness>.
-I will be notified, and then you'll automatically be notified of progress on
-your bug as I make changes.
-
-=head1 SUPPORT
-
-You can find documentation for this module with the F<perldoc> command.
-
- perldoc Test::Harness
-
-You can get docs for F<prove> with
-
- prove --man
-
-You can also look for information at:
-
-=over 4
-
-=item * AnnoCPAN: Annotated CPAN documentation
-
-L<http://annocpan.org/dist/Test-Harness>
-
-=item * CPAN Ratings
-
-L<http://cpanratings.perl.org/d/Test-Harness>
-
-=item * RT: CPAN's request tracker
-
-L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Test-Harness>
-
-=item * Search CPAN
-
-L<http://search.cpan.org/dist/Test-Harness>
-
-=back
-
-=head1 SOURCE CODE
-
-The source code repository for Test::Harness is at
-L<http://svn.perl.org/modules/Test-Harness>.
-
-=head1 AUTHORS
-
-Either Tim Bunce or Andreas Koenig, we don't know. What we know for
-sure is, that it was inspired by Larry Wall's F<TEST> script that came
-with perl distributions for ages. Numerous anonymous contributors
-exist. Andreas Koenig held the torch for many years, and then
-Michael G Schwern.
-
-Current maintainer is Andy Lester C<< <andy at petdance.com> >>.
-
-=head1 COPYRIGHT
-
-Copyright 2002-2006
-by Michael G Schwern C<< <schwern at pobox.com> >>,
-Andy Lester C<< <andy at petdance.com> >>.
-
-This program is free software; you can redistribute it and/or
-modify it under the same terms as Perl itself.
-
-See L<http://www.perl.com/perl/misc/Artistic.html>.
-
-=cut
diff --git a/gnu/usr.bin/perl/lib/Test/Harness/Assert.pm b/gnu/usr.bin/perl/lib/Test/Harness/Assert.pm
deleted file mode 100644
index 5321def4033..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Harness/Assert.pm
+++ /dev/null
@@ -1,68 +0,0 @@
-# $Id: Assert.pm,v 1.2 2002/04/26 05:12:27 schwern Exp $
-
-package Test::Harness::Assert;
-
-use strict;
-require Exporter;
-use vars qw($VERSION @EXPORT @ISA);
-
-$VERSION = '0.01';
-
-@ISA = qw(Exporter);
-@EXPORT = qw(assert);
-
-
-=head1 NAME
-
-Test::Harness::Assert - simple assert
-
-=head1 SYNOPSIS
-
- ### FOR INTERNAL USE ONLY ###
-
- use Test::Harness::Assert;
-
- assert( EXPR, $name );
-
-=head1 DESCRIPTION
-
-A simple assert routine since we don't have Carp::Assert handy.
-
-B<For internal use by Test::Harness ONLY!>
-
-=head2 Functions
-
-=over 4
-
-=item B<assert>
-
- assert( EXPR, $name );
-
-If the expression is false the program aborts.
-
-=cut
-
-sub assert ($;$) {
- my($assert, $name) = @_;
-
- unless( $assert ) {
- require Carp;
- my $msg = 'Assert failed';
- $msg .= " - '$name'" if defined $name;
- $msg .= '!';
- Carp::croak($msg);
- }
-
-}
-
-=head1 AUTHOR
-
-Michael G Schwern E<lt>schwern@pobox.comE<gt>
-
-=head1 SEE ALSO
-
-L<Carp::Assert>
-
-=cut
-
-1;
diff --git a/gnu/usr.bin/perl/lib/Test/Harness/Changes b/gnu/usr.bin/perl/lib/Test/Harness/Changes
deleted file mode 100644
index 892c24308ab..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Harness/Changes
+++ /dev/null
@@ -1,188 +0,0 @@
-Revision history for Perl extension Test::Harness
-
-2.26 Wed Jun 19 16:58:02 EDT 2002
- - Workaround for MacPerl's lack of a working putenv. It will never
- see the PERL5LIB environment variable (perl@16942).
-
-2.25 Sun Jun 16 03:00:33 EDT 2002
- - $Strap is now a global to allow Test::Harness::Straps
- experimentation.
- - Little spelling nit in a diagnostic.
- - Chris Richmond noted that the runtests() docs were wrong. It will
- die, not return false, when any tests fail. This is silly, but
- historically necessary for 'make test'. Docs corrected.
- - MacPerl test fixes from Pudge. (mutation of bleadperl@16989)
- - Undef warning introduced in 2.24 on skipped tests with no reasons
- fixed.
- * Test::Harness now depends on File::Spec
-
-2.24 Wed May 29 19:02:18 EDT 2002
- * Nikola Knezevic found a bug when tests are completely skipped
- but no reason is given it was considered a failure.
- * Made Test::Harness::Straps->analyze_file & Test::Harness a bit
- more graceful when the test doesn't exist.
-
-2.23 Wed May 22 12:59:47 EDT 2002
- - reason for all skip wasn't being displayed. Broken in 2.20.
- - Changed the wait status tests to conform with POSIX standards.
- - Quieted some SYSTEM$ABORT noise leaking out from dying test tests
- on VMS.
-
-2.22 Fri May 17 19:01:35 EDT 2002
- - Fixed parsing of #!/usr/bin/perl-current to not see a -t.
- (RT #574)
- - Fixed exit codes on MPE/iX
-
-2.21 Mon May 6 00:43:22 EDT 2002
- - removed a bunch of dead code left over after 2.20's gutting.
- - The fix for the $^X "bug" added in 2.02 has been removed. It
- caused more trouble than the old bug (I'd never seen a problem
- before anyway)
- - 2.20 broke $verbose
-
-2.20 Sat May 4 22:31:20 EDT 2002
- * An almost complete conversion of the Test::Harness test parsing
- to use Test::Harness::Straps.
-
-2.04 Tue Apr 30 00:54:49 EDT 2002
- * Changing the output format of skips
- - Taking into account VMS's special exit codes in the tests.
-
-2.03 Thu Apr 25 01:01:34 EDT 2002
- * $^X fix made safer.
- - Noise from loading wait.ph to analyze core files supressed
- - MJD found a situation where a test could run Test::Harness
- out of memory. Protecting against that specific case.
- - Made the 1..M docs a bit clearer.
- - Fixed TODO tests so Test::Harness does not display a NOK for
- them.
- - Test::Harness::Straps->analyze_file() docs were not clear as to
- its effects
-
-2.02 Thu Mar 14 18:06:04 EST 2002
- * Ken Williams fixed the long standing $^X bug.
- * Added HARNESS_VERBOSE
- * Fixed a bug where Test::Harness::Straps was considering a test that
- is ok but died as passing.
- - Added the exit and wait codes of the test to the
- analyze_file() results.
-
-2.01 Thu Dec 27 18:54:36 EST 2001
- * Added 'passing' to the results to tell you if the test passed
- * Added Test::Harness::Straps example (examples/mini_harness.plx)
- * Header-at-end tests were being interpreted as failing sometimes
- - The 'skip_all' results from analyze* was not being set
- - analyze_fh() and analyze_file() now work more efficiently, reading
- line-by-line instead of slurping as before.
-
-2.00 Sun Dec 23 19:13:57 EST 2001
- - Fixed a warning on VMS.
- - Removed a little unnecessary code from analyze_file()
- - Made sure filehandles are getting closed
- - analyze() now considers "not \nok" to be a failure (VMSism)
- but Test::Harness still doesn't.
-
-2.00_05 Mon Dec 17 22:08:02 EST 2001
- * Wasn't filtering @INC properly when a test is run with -T, caused the
- command line to be too long on VMS. VMS should be 100% now.
- - Little bug in the skip 'various reasons' logic.
- - Minor POD nit in 5.004_04
- - Little speling mistak
-
-2.00_04 Sun Dec 16 00:33:32 EST 2001
- * Major Test::Harness::Straps doc bug.
-
-2.00_03 Sat Dec 15 23:52:17 EST 2001
- * First release candidate
- * 'summary' is now 'details'
- * Test #1 is now element 0 on the details array. It works out better
- that way.
- * analyze_file() is more portable, but no longer taint clean
- * analyze_file() properly preserves @INC and handles -T switches
- - minor mistake in the test header line parsing
-
-1.26 Mon Nov 12 15:44:01 EST 2001
- * An excuse to upload a new version to CPAN to get Test::Harness
- back on the index.
-
-2.00_00 Sat Sep 29 00:12:03 EDT 2001
- * Partial gutting of the internals
- * Added Test::Harness::Straps
-
-1.25 Tue Aug 7 08:51:09 EDT 2001
- * Fixed a bug with tests failing if they're all skipped
- reported by Stas Bekman.
- - Fixed a very minor warning in 5.004_04
- - Fixed displaying filenames not from @ARGV
- - Merging with bleadperl
- - minor fixes to the filename in the report
- - '[no reason given]' skip reason
-
-1.24 Tue Aug 7 08:51:09 EDT 2001
- - Added internal information about number of todo tests
-
-1.23 Tue Jul 31 15:06:47 EDT 2001
- - Merged in Ilya's "various reasons" patch
- * Fixed "not ok 23 - some name # TODO" style tests
-
-1.22 Mon Jun 25 02:00:02 EDT 2001
- * Fixed bug with failing tests using header at end.
- - Documented how Test::Harness deals with garbage input
- - Turned on test counter mismatch warning
-
-1.21 Wed May 23 19:22:53 BST 2001
- * No longer considered unstable. Merging back with the perl core.
- - Fixed minor nit about the report summary
- - Added docs on the meaning of the failure report
- - Minor POD nits fixed mirroring perl change 9176
- - TODO and SEE ALSO expanded
-
-1.20 Wed Mar 14 23:09:20 GMT 2001 by Michael G Schwern *UNSTABLE*
- * Fixed and tested with 5.004!
- - Added EXAMPLE docs
- - Added TODO docs
- - Now uneffected by -l, $\ or $,
-
-1.19 Sat Mar 10 00:43:29 GMT 2001 by Michael G Schwern *UNSTABLE*
- - More internal reworking
- * Removed use of experimental /(?>...)/ feature for backwards compat
- * Removed use of open(my $fh, $file) for backwards compatibility
- * Removed use of Tie::StdHandle in tests for backwards compat
- * Added dire warning that this is unstable.
- - Added some tests from the old CPAN release
-
-1.18 Mon Mar 5 17:35:11 GMT 2001 by Michael G Schwern
- * Under new management!
- * Test::Harness is now being concurrently shipped on CPAN as well
- as in the core.
- - Switched "our" for "use vars" and moved the minimum version back
- to 5.004. This may be optimistic.
-
-
-*** Missing version history to be extracted from Perl changes ***
-
-
-1.07 Fri Feb 23 1996 by Andreas Koenig
- - Gisle sent me a documentation patch that showed me, that the
- unless(/^#/) is unnessessary. Applied the patch and deleted the block
- checking for "comment" lines. -- All lines are comment lines that do
- not match /^1\.\.([0-9]+)/ or /^(not\s+)?ok\b/.
- - Ilyaz request to print "ok (empty test case)" whenever we say 1..0
- implemented.
- - Harness now doesn't abort anymore if we received confused test output,
- just warns instead.
-
-1.05 Wed Jan 31 1996 by Andreas Koenig
- - More updates on docu and introduced the liberality that the script
- output may omit the test numbers.
-
-1.03 Mon January 28 1996 by Andreas Koenig
- - Added the statistics for subtests. Updated the documentation.
-
-1.02 by Andreas Koenig
- - This version reports a list of the tests that failed accompanied by
- some trivial statistics. The older (unnumbered) version stopped
- processing after the first failed test.
- - Additionally it reports the exit status if there is one.
-
-
diff --git a/gnu/usr.bin/perl/lib/Test/Harness/Iterator.pm b/gnu/usr.bin/perl/lib/Test/Harness/Iterator.pm
deleted file mode 100644
index 5e227939a0d..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Harness/Iterator.pm
+++ /dev/null
@@ -1,61 +0,0 @@
-package Test::Harness::Iterator;
-
-use strict;
-use vars qw($VERSION);
-$VERSION = 0.01;
-
-
-=head1 NAME
-
-Test::Harness::Iterator - Internal Test::Harness Iterator
-
-=head1 SYNOPSIS
-
- use Test::Harness::Iterator;
- use Test::Harness::Iterator;
- my $it = Test::Harness::Iterator->new(\*TEST);
- my $it = Test::Harness::Iterator->new(\@array);
-
- my $line = $it->next;
-
-
-=head1 DESCRIPTION
-
-B<FOR INTERNAL USE ONLY!>
-
-This is a simple iterator wrapper for arrays and filehandles.
-
-=cut
-
-sub new {
- my($proto, $thing) = @_;
-
- my $self = {};
- if( ref $thing eq 'GLOB' ) {
- bless $self, 'Test::Harness::Iterator::FH';
- $self->{fh} = $thing;
- }
- elsif( ref $thing eq 'ARRAY' ) {
- bless $self, 'Test::Harness::Iterator::ARRAY';
- $self->{idx} = 0;
- $self->{array} = $thing;
- }
- else {
- warn "Can't iterate with a ", ref $thing;
- }
-
- return $self;
-}
-
-package Test::Harness::Iterator::FH;
-sub next {
- my $fh = $_[0]->{fh};
- return scalar <$fh>;
-}
-
-
-package Test::Harness::Iterator::ARRAY;
-sub next {
- my $self = shift;
- return $self->{array}->[$self->{idx}++];
-}
diff --git a/gnu/usr.bin/perl/lib/Test/Harness/Point.pm b/gnu/usr.bin/perl/lib/Test/Harness/Point.pm
deleted file mode 100644
index 9f82fe9fc98..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Harness/Point.pm
+++ /dev/null
@@ -1,152 +0,0 @@
-# -*- Mode: cperl; cperl-indent-level: 4 -*-
-package Test::Harness::Point;
-
-use strict;
-use vars qw($VERSION);
-$VERSION = '0.01';
-
-=head1 NAME
-
-Test::Harness::Point - object for tracking a single test point
-
-=head1 SYNOPSIS
-
-One Test::Harness::Point object represents a single test point.
-
-=head1 CONSTRUCTION
-
-=head2 new()
-
- my $point = new Test::Harness::Point;
-
-Create a test point object.
-
-=cut
-
-sub new {
- my $class = shift;
- my $self = bless {}, $class;
-
- return $self;
-}
-
-my $test_line_regex = qr/
- ^
- (not\ )? # failure?
- ok\b
- (?:\s+(\d+))? # optional test number
- \s*
- (.*) # and the rest
-/ox;
-
-=head1 from_test_line( $line )
-
-Constructor from a TAP test line, or empty return if the test line
-is not a test line.
-
-=cut
-
-sub from_test_line {
- my $class = shift;
- my $line = shift or return;
-
- # We pulverize the line down into pieces in three parts.
- my ($not, $number, $extra) = ($line =~ $test_line_regex ) or return;
-
- my $point = $class->new;
- $point->set_number( $number );
- $point->set_ok( !$not );
-
- if ( $extra ) {
- my ($description,$directive) = split( /(?:[^\\]|^)#/, $extra, 2 );
- $description =~ s/^- //; # Test::More puts it in there
- $point->set_description( $description );
- if ( $directive ) {
- $point->set_directive( $directive );
- }
- } # if $extra
-
- return $point;
-} # from_test_line()
-
-=head1 ACCESSORS
-
-Each of the following fields has a getter and setter method.
-
-=over 4
-
-=item * ok
-
-=item * number
-
-=cut
-
-sub ok { my $self = shift; $self->{ok} }
-sub set_ok {
- my $self = shift;
- my $ok = shift;
- $self->{ok} = $ok ? 1 : 0;
-}
-sub pass {
- my $self = shift;
-
- return ($self->ok || $self->is_todo || $self->is_skip) ? 1 : 0;
-}
-
-sub number { my $self = shift; $self->{number} }
-sub set_number { my $self = shift; $self->{number} = shift }
-
-sub description { my $self = shift; $self->{description} }
-sub set_description {
- my $self = shift;
- $self->{description} = shift;
- $self->{name} = $self->{description}; # history
-}
-
-sub directive { my $self = shift; $self->{directive} }
-sub set_directive {
- my $self = shift;
- my $directive = shift;
-
- $directive =~ s/^\s+//;
- $directive =~ s/\s+$//;
- $self->{directive} = $directive;
-
- my ($type,$reason) = ($directive =~ /^\s*(\S+)(?:\s+(.*))?$/);
- $self->set_directive_type( $type );
- $reason = "" unless defined $reason;
- $self->{directive_reason} = $reason;
-}
-sub set_directive_type {
- my $self = shift;
- $self->{directive_type} = lc shift;
- $self->{type} = $self->{directive_type}; # History
-}
-sub set_directive_reason {
- my $self = shift;
- $self->{directive_reason} = shift;
-}
-sub directive_type { my $self = shift; $self->{directive_type} }
-sub type { my $self = shift; $self->{directive_type} }
-sub directive_reason{ my $self = shift; $self->{directive_reason} }
-sub reason { my $self = shift; $self->{directive_reason} }
-sub is_todo {
- my $self = shift;
- my $type = $self->directive_type;
- return $type && ( $type eq 'todo' );
-}
-sub is_skip {
- my $self = shift;
- my $type = $self->directive_type;
- return $type && ( $type eq 'skip' );
-}
-
-sub diagnostics {
- my $self = shift;
- return @{$self->{diagnostics}} if wantarray;
- return join( "\n", @{$self->{diagnostics}} );
-}
-sub add_diagnostic { my $self = shift; push @{$self->{diagnostics}}, @_ }
-
-
-1;
diff --git a/gnu/usr.bin/perl/lib/Test/Harness/Results.pm b/gnu/usr.bin/perl/lib/Test/Harness/Results.pm
deleted file mode 100644
index f4f4c4eca0d..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Harness/Results.pm
+++ /dev/null
@@ -1,182 +0,0 @@
-# -*- Mode: cperl; cperl-indent-level: 4 -*-
-package Test::Harness::Results;
-
-use strict;
-use vars qw($VERSION);
-$VERSION = '0.01';
-
-=head1 NAME
-
-Test::Harness::Results - object for tracking results from a single test file
-
-=head1 SYNOPSIS
-
-One Test::Harness::Results object represents the results from one
-test file getting analyzed.
-
-=head1 CONSTRUCTION
-
-=head2 new()
-
- my $results = new Test::Harness::Results;
-
-Create a test point object. Typically, however, you'll not create
-one yourself, but access a Results object returned to you by
-Test::Harness::Results.
-
-=cut
-
-sub new {
- my $class = shift;
- my $self = bless {}, $class;
-
- return $self;
-}
-
-=head1 ACCESSORS
-
-The following data points are defined:
-
- passing true if the whole test is considered a pass
- (or skipped), false if its a failure
-
- exit the exit code of the test run, if from a file
- wait the wait code of the test run, if from a file
-
- max total tests which should have been run
- seen total tests actually seen
- skip_all if the whole test was skipped, this will
- contain the reason.
-
- ok number of tests which passed
- (including todo and skips)
-
- todo number of todo tests seen
- bonus number of todo tests which
- unexpectedly passed
-
- skip number of tests skipped
-
-So a successful test should have max == seen == ok.
-
-
-There is one final item, the details.
-
- details an array ref reporting the result of
- each test looks like this:
-
- $results{details}[$test_num - 1] =
- { ok => is the test considered ok?
- actual_ok => did it literally say 'ok'?
- name => name of the test (if any)
- diagnostics => test diagnostics (if any)
- type => 'skip' or 'todo' (if any)
- reason => reason for the above (if any)
- };
-
-Element 0 of the details is test #1. I tried it with element 1 being
-#1 and 0 being empty, this is less awkward.
-
-
-Each of the following fields has a getter and setter method.
-
-=over 4
-
-=item * wait
-
-=item * exit
-
-=cut
-
-sub set_wait { my $self = shift; $self->{wait} = shift }
-sub wait {
- my $self = shift;
- return $self->{wait} || 0;
-}
-
-sub set_skip_all { my $self = shift; $self->{skip_all} = shift }
-sub skip_all {
- my $self = shift;
- return $self->{skip_all};
-}
-
-sub inc_max { my $self = shift; $self->{max} += (@_ ? shift : 1) }
-sub max {
- my $self = shift;
- return $self->{max} || 0;
-}
-
-sub set_passing { my $self = shift; $self->{passing} = shift }
-sub passing {
- my $self = shift;
- return $self->{passing} || 0;
-}
-
-sub inc_ok { my $self = shift; $self->{ok} += (@_ ? shift : 1) }
-sub ok {
- my $self = shift;
- return $self->{ok} || 0;
-}
-
-sub set_exit {
- my $self = shift;
- if ($^O eq 'VMS') {
- eval {
- use vmsish q(status);
- $self->{exit} = shift; # must be in same scope as pragma
- }
- }
- else {
- $self->{exit} = shift;
- }
-}
-sub exit {
- my $self = shift;
- return $self->{exit} || 0;
-}
-
-sub inc_bonus { my $self = shift; $self->{bonus}++ }
-sub bonus {
- my $self = shift;
- return $self->{bonus} || 0;
-}
-
-sub set_skip_reason { my $self = shift; $self->{skip_reason} = shift }
-sub skip_reason {
- my $self = shift;
- return $self->{skip_reason} || 0;
-}
-
-sub inc_skip { my $self = shift; $self->{skip}++ }
-sub skip {
- my $self = shift;
- return $self->{skip} || 0;
-}
-
-sub inc_todo { my $self = shift; $self->{todo}++ }
-sub todo {
- my $self = shift;
- return $self->{todo} || 0;
-}
-
-sub inc_seen { my $self = shift; $self->{seen}++ }
-sub seen {
- my $self = shift;
- return $self->{seen} || 0;
-}
-
-sub set_details {
- my $self = shift;
- my $index = shift;
- my $details = shift;
-
- my $array = ($self->{details} ||= []);
- $array->[$index-1] = $details;
-}
-
-sub details {
- my $self = shift;
- return $self->{details} || [];
-}
-
-1;
diff --git a/gnu/usr.bin/perl/lib/Test/Harness/Straps.pm b/gnu/usr.bin/perl/lib/Test/Harness/Straps.pm
deleted file mode 100644
index 75300450c6f..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Harness/Straps.pm
+++ /dev/null
@@ -1,693 +0,0 @@
-# -*- Mode: cperl; cperl-indent-level: 4 -*-
-# $Id: Straps.pm,v 1.13 2002/06/19 21:01:04 schwern Exp $
-
-package Test::Harness::Straps;
-
-use strict;
-use vars qw($VERSION);
-use Config;
-$VERSION = '0.14';
-
-use Test::Harness::Assert;
-use Test::Harness::Iterator;
-
-# Flags used as return values from our methods. Just for internal
-# clarification.
-my $TRUE = (1==1);
-my $FALSE = !$TRUE;
-my $YES = $TRUE;
-my $NO = $FALSE;
-
-
-=head1 NAME
-
-Test::Harness::Straps - detailed analysis of test results
-
-=head1 SYNOPSIS
-
- use Test::Harness::Straps;
-
- my $strap = Test::Harness::Straps->new;
-
- # Various ways to interpret a test
- my %results = $strap->analyze($name, \@test_output);
- my %results = $strap->analyze_fh($name, $test_filehandle);
- my %results = $strap->analyze_file($test_file);
-
- # UNIMPLEMENTED
- my %total = $strap->total_results;
-
- # Altering the behavior of the strap UNIMPLEMENTED
- my $verbose_output = $strap->dump_verbose();
- $strap->dump_verbose_fh($output_filehandle);
-
-
-=head1 DESCRIPTION
-
-B<THIS IS ALPHA SOFTWARE> in that the interface is subject to change
-in incompatible ways. It is otherwise stable.
-
-Test::Harness is limited to printing out its results. This makes
-analysis of the test results difficult for anything but a human. To
-make it easier for programs to work with test results, we provide
-Test::Harness::Straps. Instead of printing the results, straps
-provide them as raw data. You can also configure how the tests are to
-be run.
-
-The interface is currently incomplete. I<Please> contact the author
-if you'd like a feature added or something change or just have
-comments.
-
-=head2 Construction
-
-=over 4
-
-=item B<new>
-
- my $strap = Test::Harness::Straps->new;
-
-Initialize a new strap.
-
-=cut
-
-sub new {
- my($proto) = shift;
- my($class) = ref $proto || $proto;
-
- my $self = bless {}, $class;
- $self->_init;
-
- return $self;
-}
-
-=begin _private
-
-=item B<_init>
-
- $strap->_init;
-
-Initialize the internal state of a strap to make it ready for parsing.
-
-=cut
-
-sub _init {
- my($self) = shift;
-
- $self->{_is_vms} = $^O eq 'VMS';
-}
-
-=end _private
-
-=back
-
-=head2 Analysis
-
-=over 4
-
-=item B<analyze>
-
- my %results = $strap->analyze($name, \@test_output);
-
-Analyzes the output of a single test, assigning it the given $name for
-use in the total report. Returns the %results of the test. See
-L<Results>.
-
-@test_output should be the raw output from the test, including newlines.
-
-=cut
-
-sub analyze {
- my($self, $name, $test_output) = @_;
-
- my $it = Test::Harness::Iterator->new($test_output);
- return $self->_analyze_iterator($name, $it);
-}
-
-
-sub _analyze_iterator {
- my($self, $name, $it) = @_;
-
- $self->_reset_file_state;
- $self->{file} = $name;
- my %totals = (
- max => 0,
- seen => 0,
-
- ok => 0,
- todo => 0,
- skip => 0,
- bonus => 0,
-
- details => []
- );
-
- # Set them up here so callbacks can have them.
- $self->{totals}{$name} = \%totals;
- while( defined(my $line = $it->next) ) {
- $self->_analyze_line($line, \%totals);
- last if $self->{saw_bailout};
- }
-
- $totals{skip_all} = $self->{skip_all} if defined $self->{skip_all};
-
- my $passed = !$totals{max} ||
- ($totals{max} && $totals{seen} &&
- $totals{max} == $totals{seen} &&
- $totals{max} == $totals{ok});
- $totals{passing} = $passed ? 1 : 0;
-
- return %totals;
-}
-
-
-sub _analyze_line {
- my($self, $line, $totals) = @_;
-
- my %result = ();
-
- $self->{line}++;
-
- my $type;
- if( $self->_is_header($line) ) {
- $type = 'header';
-
- $self->{saw_header}++;
-
- $totals->{max} += $self->{max};
- }
- elsif( $self->_is_test($line, \%result) ) {
- $type = 'test';
-
- $totals->{seen}++;
- $result{number} = $self->{'next'} unless $result{number};
-
- # sometimes the 'not ' and the 'ok' are on different lines,
- # happens often on VMS if you do:
- # print "not " unless $test;
- # print "ok $num\n";
- if( $self->{saw_lone_not} &&
- ($self->{lone_not_line} == $self->{line} - 1) )
- {
- $result{ok} = 0;
- }
-
- my $pass = $result{ok};
- $result{type} = 'todo' if $self->{todo}{$result{number}};
-
- if( $result{type} eq 'todo' ) {
- $totals->{todo}++;
- $pass = 1;
- $totals->{bonus}++ if $result{ok}
- }
- elsif( $result{type} eq 'skip' ) {
- $totals->{skip}++;
- $pass = 1;
- }
-
- $totals->{ok}++ if $pass;
-
- if( $result{number} > 100000 ) {
- warn "Enormous test number seen [test $result{number}]\n";
- warn "Can't detailize, too big.\n";
- }
- else {
- $totals->{details}[$result{number} - 1] =
- {$self->_detailize($pass, \%result)};
- }
-
- # XXX handle counter mismatch
- }
- elsif ( $self->_is_bail_out($line, \$self->{bailout_reason}) ) {
- $type = 'bailout';
- $self->{saw_bailout} = 1;
- }
- else {
- $type = 'other';
- }
-
- $self->{callback}->($self, $line, $type, $totals) if $self->{callback};
-
- $self->{'next'} = $result{number} + 1 if $type eq 'test';
-}
-
-=item B<analyze_fh>
-
- my %results = $strap->analyze_fh($name, $test_filehandle);
-
-Like C<analyze>, but it reads from the given filehandle.
-
-=cut
-
-sub analyze_fh {
- my($self, $name, $fh) = @_;
-
- my $it = Test::Harness::Iterator->new($fh);
- $self->_analyze_iterator($name, $it);
-}
-
-=item B<analyze_file>
-
- my %results = $strap->analyze_file($test_file);
-
-Like C<analyze>, but it runs the given $test_file and parses it's
-results. It will also use that name for the total report.
-
-=cut
-
-sub analyze_file {
- my($self, $file) = @_;
-
- unless( -e $file ) {
- $self->{error} = "$file does not exist";
- return;
- }
-
- unless( -r $file ) {
- $self->{error} = "$file is not readable";
- return;
- }
-
- local $ENV{PERL5LIB} = $self->_INC2PERL5LIB;
-
- # Is this necessary anymore?
- my $cmd = $self->{_is_vms} ? "MCR $^X" : $^X;
-
- my $switches = $self->_switches($file);
-
- # *sigh* this breaks under taint, but open -| is unportable.
- unless( open(FILE, "$cmd $switches $file|") ) {
- print "can't run $file. $!\n";
- return;
- }
-
- my %results = $self->analyze_fh($file, \*FILE);
- my $exit = close FILE;
- $results{'wait'} = $?;
- if( $? && $self->{_is_vms} ) {
- eval q{use vmsish "status"; $results{'exit'} = $?};
- }
- else {
- $results{'exit'} = _wait2exit($?);
- }
- $results{passing} = 0 unless $? == 0;
-
- $self->_restore_PERL5LIB();
-
- return %results;
-}
-
-
-eval { require POSIX; &POSIX::WEXITSTATUS(0) };
-if( $@ ) {
- *_wait2exit = sub { $_[0] >> 8 };
-}
-else {
- *_wait2exit = sub { POSIX::WEXITSTATUS($_[0]) }
-}
-
-
-=begin _private
-
-=item B<_switches>
-
- my $switches = $self->_switches($file);
-
-Formats and returns the switches necessary to run the test.
-
-=cut
-
-sub _switches {
- my($self, $file) = @_;
-
- local *TEST;
- open(TEST, $file) or print "can't open $file. $!\n";
- my $first = <TEST>;
- my $s = '';
- $s .= " $ENV{'HARNESS_PERL_SWITCHES'}"
- if exists $ENV{'HARNESS_PERL_SWITCHES'};
-
- if ($first =~ /^#!.*\bperl.*\s-\w*([Tt]+)/) {
- # When taint mode is on, PERL5LIB is ignored. So we need to put
- # all that on the command line as -Is.
- $s .= join " ", qq[ "-$1"], map {qq["-I$_"]} $self->_filtered_INC;
- }
- elsif ($^O eq 'MacOS') {
- # MacPerl's putenv is broken, so it will not see PERL5LIB.
- $s .= join " ", map {qq["-I$_"]} $self->_filtered_INC;
- }
-
- close(TEST) or print "can't close $file. $!\n";
-
- return $s;
-}
-
-
-=item B<_INC2PERL5LIB>
-
- local $ENV{PERL5LIB} = $self->_INC2PERL5LIB;
-
-Takes the current value of @INC and turns it into something suitable
-for putting onto PERL5LIB.
-
-=cut
-
-sub _INC2PERL5LIB {
- my($self) = shift;
-
- $self->{_old5lib} = $ENV{PERL5LIB};
-
- return join $Config{path_sep}, $self->_filtered_INC;
-}
-
-=item B<_filtered_INC>
-
- my @filtered_inc = $self->_filtered_INC;
-
-Shortens @INC by removing redundant and unnecessary entries.
-Necessary for OS's with limited command line lengths, like VMS.
-
-=cut
-
-sub _filtered_INC {
- my($self, @inc) = @_;
- @inc = @INC unless @inc;
-
- # VMS has a 255-byte limit on the length of %ENV entries, so
- # toss the ones that involve perl_root, the install location
- # for VMS
- if( $self->{_is_vms} ) {
- @inc = grep !/perl_root/i, @inc;
- }
-
- return @inc;
-}
-
-
-=item B<_restore_PERL5LIB>
-
- $self->_restore_PERL5LIB;
-
-This restores the original value of the PERL5LIB environment variable.
-Necessary on VMS, otherwise a no-op.
-
-=cut
-
-sub _restore_PERL5LIB {
- my($self) = shift;
-
- return unless $self->{_is_vms};
-
- if (defined $self->{_old5lib}) {
- $ENV{PERL5LIB} = $self->{_old5lib};
- }
-}
-
-
-=end _private
-
-=back
-
-
-=begin _private
-
-=head2 Parsing
-
-Methods for identifying what sort of line you're looking at.
-
-=over 4
-
-=item B<_is_comment>
-
- my $is_comment = $strap->_is_comment($line, \$comment);
-
-Checks if the given line is a comment. If so, it will place it into
-$comment (sans #).
-
-=cut
-
-sub _is_comment {
- my($self, $line, $comment) = @_;
-
- if( $line =~ /^\s*\#(.*)/ ) {
- $$comment = $1;
- return $YES;
- }
- else {
- return $NO;
- }
-}
-
-=item B<_is_header>
-
- my $is_header = $strap->_is_header($line);
-
-Checks if the given line is a header (1..M) line. If so, it places
-how many tests there will be in $strap->{max}, a list of which tests
-are todo in $strap->{todo} and if the whole test was skipped
-$strap->{skip_all} contains the reason.
-
-=cut
-
-# Regex for parsing a header. Will be run with /x
-my $Extra_Header_Re = <<'REGEX';
- ^
- (?: \s+ todo \s+ ([\d \t]+) )? # optional todo set
- (?: \s* \# \s* ([\w:]+\s?) (.*) )? # optional skip with optional reason
-REGEX
-
-sub _is_header {
- my($self, $line) = @_;
-
- if( my($max, $extra) = $line =~ /^1\.\.(\d+)(.*)/ ) {
- $self->{max} = $max;
- assert( $self->{max} >= 0, 'Max # of tests looks right' );
-
- if( defined $extra ) {
- my($todo, $skip, $reason) = $extra =~ /$Extra_Header_Re/xo;
-
- $self->{todo} = { map { $_ => 1 } split /\s+/, $todo } if $todo;
-
- $self->{skip_all} = $reason if defined $skip and $skip =~ /^Skip/i;
- }
-
- return $YES;
- }
- else {
- return $NO;
- }
-}
-
-=item B<_is_test>
-
- my $is_test = $strap->_is_test($line, \%test);
-
-Checks if the $line is a test report (ie. 'ok/not ok'). Reports the
-result back in %test which will contain:
-
- ok did it succeed? This is the literal 'ok' or 'not ok'.
- name name of the test (if any)
- number test number (if any)
-
- type 'todo' or 'skip' (if any)
- reason why is it todo or skip? (if any)
-
-If will also catch lone 'not' lines, note it saw them
-$strap->{saw_lone_not} and the line in $strap->{lone_not_line}.
-
-=cut
-
-my $Report_Re = <<'REGEX';
- ^
- (not\ )? # failure?
- ok\b
- (?:\s+(\d+))? # optional test number
- \s*
- (.*) # and the rest
-REGEX
-
-my $Extra_Re = <<'REGEX';
- ^
- (.*?) (?:(?:[^\\]|^)# (.*))?
- $
-REGEX
-
-sub _is_test {
- my($self, $line, $test) = @_;
-
- # We pulverize the line down into pieces in three parts.
- if( my($not, $num, $extra) = $line =~ /$Report_Re/ox ) {
- my($name, $control) = split /(?:[^\\]|^)#/, $extra if $extra;
- my($type, $reason) = $control =~ /^\s*(\S+)(?:\s+(.*))?$/ if $control;
-
- $test->{number} = $num;
- $test->{ok} = $not ? 0 : 1;
- $test->{name} = $name;
-
- if( defined $type ) {
- $test->{type} = $type =~ /^TODO$/i ? 'todo' :
- $type =~ /^Skip/i ? 'skip' : 0;
- }
- else {
- $test->{type} = '';
- }
- $test->{reason} = $reason;
-
- return $YES;
- }
- else{
- # Sometimes the "not " and "ok" will be on seperate lines on VMS.
- # We catch this and remember we saw it.
- if( $line =~ /^not\s+$/ ) {
- $self->{saw_lone_not} = 1;
- $self->{lone_not_line} = $self->{line};
- }
-
- return $NO;
- }
-}
-
-=item B<_is_bail_out>
-
- my $is_bail_out = $strap->_is_bail_out($line, \$reason);
-
-Checks if the line is a "Bail out!". Places the reason for bailing
-(if any) in $reason.
-
-=cut
-
-sub _is_bail_out {
- my($self, $line, $reason) = @_;
-
- if( $line =~ /^Bail out!\s*(.*)/i ) {
- $$reason = $1 if $1;
- return $YES;
- }
- else {
- return $NO;
- }
-}
-
-=item B<_reset_file_state>
-
- $strap->_reset_file_state;
-
-Resets things like $strap->{max}, $strap->{skip_all}, etc... so its
-ready to parse the next file.
-
-=cut
-
-sub _reset_file_state {
- my($self) = shift;
-
- delete @{$self}{qw(max skip_all todo)};
- $self->{line} = 0;
- $self->{saw_header} = 0;
- $self->{saw_bailout}= 0;
- $self->{saw_lone_not} = 0;
- $self->{lone_not_line} = 0;
- $self->{bailout_reason} = '';
- $self->{'next'} = 1;
-}
-
-=back
-
-=end _private
-
-
-=head2 Results
-
-The %results returned from analyze() contain the following information:
-
- passing true if the whole test is considered a pass
- (or skipped), false if its a failure
-
- exit the exit code of the test run, if from a file
- wait the wait code of the test run, if from a file
-
- max total tests which should have been run
- seen total tests actually seen
- skip_all if the whole test was skipped, this will
- contain the reason.
-
- ok number of tests which passed
- (including todo and skips)
-
- todo number of todo tests seen
- bonus number of todo tests which
- unexpectedly passed
-
- skip number of tests skipped
-
-So a successful test should have max == seen == ok.
-
-
-There is one final item, the details.
-
- details an array ref reporting the result of
- each test looks like this:
-
- $results{details}[$test_num - 1] =
- { ok => is the test considered ok?
- actual_ok => did it literally say 'ok'?
- name => name of the test (if any)
- type => 'skip' or 'todo' (if any)
- reason => reason for the above (if any)
- };
-
-Element 0 of the details is test #1. I tried it with element 1 being
-#1 and 0 being empty, this is less awkward.
-
-=begin _private
-
-=over 4
-
-=item B<_detailize>
-
- my %details = $strap->_detailize($pass, \%test);
-
-Generates the details based on the last test line seen. $pass is true
-if it was considered to be a passed test. %test is the results of the
-test you're summarizing.
-
-=cut
-
-sub _detailize {
- my($self, $pass, $test) = @_;
-
- my %details = ( ok => $pass,
- actual_ok => $test->{ok}
- );
-
- assert( !(grep !defined $details{$_}, keys %details),
- 'test contains the ok and actual_ok info' );
-
- # We don't want these to be undef because they are often
- # checked and don't want the checker to have to deal with
- # uninitialized vars.
- foreach my $piece (qw(name type reason)) {
- $details{$piece} = defined $test->{$piece} ? $test->{$piece} : '';
- }
-
- return %details;
-}
-
-=back
-
-=end _private
-
-=head1 EXAMPLES
-
-See F<examples/mini_harness.plx> for an example of use.
-
-=head1 AUTHOR
-
-Michael G Schwern E<lt>schwern@pobox.comE<gt>
-
-=head1 SEE ALSO
-
-L<Test::Harness>
-
-=cut
-
-
-1;
diff --git a/gnu/usr.bin/perl/lib/Test/Harness/TAP.pod b/gnu/usr.bin/perl/lib/Test/Harness/TAP.pod
deleted file mode 100644
index 6dd0a96cf2a..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Harness/TAP.pod
+++ /dev/null
@@ -1,366 +0,0 @@
-=head1 NAME
-
-Test::Harness::TAP - Documentation for the TAP format
-
-=head1 SYNOPSIS
-
-TAP, the Test Anything Protocol, is Perl's simple text-based interface
-between testing modules such as Test::More and the test harness
-Test::Harness.
-
-=head1 TODO
-
-Exit code of the process.
-
-=head1 THE TAP FORMAT
-
-TAP's general format is:
-
- 1..N
- ok 1 Description # Directive
- # Diagnostic
- ....
- ok 47 Description
- ok 48 Description
- more tests....
-
-For example, a test file's output might look like:
-
- 1..4
- ok 1 - Input file opened
- not ok 2 - First line of the input valid
- ok 3 - Read the rest of the file
- not ok 4 - Summarized correctly # TODO Not written yet
-
-=head1 HARNESS BEHAVIOR
-
-In this document, the "harness" is any program analyzing TAP output.
-Typically this will be Perl's I<prove> program, or the underlying
-C<Test::Harness::runtests> subroutine.
-
-A harness must only read TAP output from standard output and not
-from standard error. Lines written to standard output matching
-C</^(not )?ok\b/> must be interpreted as test lines. All other
-lines must not be considered test output.
-
-=head1 TESTS LINES AND THE PLAN
-
-=head2 The plan
-
-The plan tells how many tests will be run, or how many tests have
-run. It's a check that the test file hasn't stopped prematurely.
-It must appear once, whether at the beginning or end of the output.
-
-The plan is usually the first line of TAP output and it specifies how
-many test points are to follow. For example,
-
- 1..10
-
-means you plan on running 10 tests. This is a safeguard in case your test
-file dies silently in the middle of its run. The plan is optional but if
-there is a plan before the test points it must be the first non-diagnostic
-line output by the test file.
-
-In certain instances a test file may not know how many test points
-it will ultimately be running. In this case the plan can be the last
-non-diagnostic line in the output.
-
-The plan cannot appear in the middle of the output, nor can it appear more
-than once.
-
-=head2 The test line
-
-The core of TAP is the test line. A test file prints one test line test
-point executed. There must be at least one test line in TAP output. Each
-test line comprises the following elements:
-
-=over 4
-
-=item * C<ok> or C<not ok>
-
-This tells whether the test point passed or failed. It must be
-at the beginning of the line. C</^not ok/> indicates a failed test
-point. C</^ok/> is a successful test point. This is the only mandatory
-part of the line.
-
-Note that unlike the Directives below, C<ok> and C<not ok> are
-case-sensitive.
-
-=item * Test number
-
-TAP expects the C<ok> or C<not ok> to be followed by a test point
-number. If there is no number the harness must maintain
-its own counter until the script supplies test numbers again. So
-the following test output
-
- 1..6
- not ok
- ok
- not ok
- ok
- ok
-
-has five tests. The sixth is missing. Test::Harness will generate
-
- FAILED tests 1, 3, 6
- Failed 3/6 tests, 50.00% okay
-
-=item * Description
-
-Any text after the test number but before a C<#> is the description of
-the test point.
-
- ok 42 this is the description of the test
-
-Descriptions should not begin with a digit so that they are not confused
-with the test point number.
-
-The harness may do whatever it wants with the description.
-
-=item * Directive
-
-The test point may include a directive, following a hash on the
-test line. There are currently two directives allowed: C<TODO> and
-C<SKIP>. These are discussed below.
-
-=back
-
-To summarize:
-
-=over 4
-
-=item * ok/not ok (required)
-
-=item * Test number (recommended)
-
-=item * Description (recommended)
-
-=item * Directive (only when necessary)
-
-=back
-
-=head1 DIRECTIVES
-
-Directives are special notes that follow a C<#> on the test line.
-Only two are currently defined: C<TODO> and C<SKIP>. Note that
-these two keywords are not case-sensitive.
-
-=head2 TODO tests
-
-If the directive starts with C<# TODO>, the test is counted as a
-todo test, and the text after C<TODO> is the explanation.
-
- not ok 13 # TODO bend space and time
-
-Note that if the TODO has an explanation it must be separated from
-C<TODO> by a space.
-
-These tests represent a feature to be implemented or a bug to be fixed
-and act as something of an executable "things to do" list. They are
-B<not> expected to succeed. Should a todo test point begin succeeding,
-the harness should report it as a bonus. This indicates that whatever
-you were supposed to do has been done and you should promote this to a
-normal test point.
-
-=head2 Skipping tests
-
-If the directive starts with C<# SKIP>, the test is counted as having
-been skipped. If the whole test file succeeds, the count of skipped
-tests is included in the generated output. The harness should report
-the text after C< # SKIP\S*\s+> as a reason for skipping.
-
- ok 23 # skip Insufficient flogiston pressure.
-
-Similarly, one can include an explanation in a plan line,
-emitted if the test file is skipped completely:
-
- 1..0 # Skipped: WWW::Mechanize not installed
-
-=head1 OTHER LINES
-
-=head2 Bail out!
-
-As an emergency measure a test script can decide that further tests
-are useless (e.g. missing dependencies) and testing should stop
-immediately. In that case the test script prints the magic words
-
- Bail out!
-
-to standard output. Any message after these words must be displayed
-by the interpreter as the reason why testing must be stopped, as
-in
-
- Bail out! MySQL is not running.
-
-=head2 Diagnostics
-
-Additional information may be put into the testing output on separate
-lines. Diagnostic lines should begin with a C<#>, which the harness must
-ignore, at least as far as analyzing the test results. The harness is
-free, however, to display the diagnostics. Typically diagnostics are
-used to provide information about the environment in which test file is
-running, or to delineate a group of tests.
-
- ...
- ok 18 - Closed database connection
- # End of database section.
- # This starts the network part of the test.
- # Daemon started on port 2112
- ok 19 - Opened socket
- ...
- ok 47 - Closed socket
- # End of network tests
-
-=head2 Anything else
-
-Any output line that is not a plan, a test line or a diagnostic is
-incorrect. How a harness handles the incorrect line is undefined.
-Test::Harness silently ignores incorrect lines, but will become more
-stringent in the future.
-
-=head1 EXAMPLES
-
-All names, places, and events depicted in any example are wholly
-fictitious and bear no resemblance to, connection with, or relation to any
-real entity. Any such similarity is purely coincidental, unintentional,
-and unintended.
-
-=head2 Common with explanation
-
-The following TAP listing declares that six tests follow as well as
-provides handy feedback as to what the test is about to do. All six
-tests pass.
-
- 1..6
- #
- # Create a new Board and Tile, then place
- # the Tile onto the board.
- #
- ok 1 - The object isa Board
- ok 2 - Board size is zero
- ok 3 - The object isa Tile
- ok 4 - Get possible places to put the Tile
- ok 5 - Placing the tile produces no error
- ok 6 - Board size is 1
-
-=head2 Unknown amount and failures
-
-This hypothetical test program ensures that a handful of servers are
-online and network-accessible. Because it retrieves the hypothetical
-servers from a database, it doesn't know exactly how many servers it
-will need to ping. Thus, the test count is declared at the bottom after
-all the test points have run. Also, two of the tests fail.
-
- ok 1 - retrieving servers from the database
- # need to ping 6 servers
- ok 2 - pinged diamond
- ok 3 - pinged ruby
- not ok 4 - pinged saphire
- ok 5 - pinged onyx
- not ok 6 - pinged quartz
- ok 7 - pinged gold
- 1..7
-
-=head2 Giving up
-
-This listing reports that a pile of tests are going to be run. However,
-the first test fails, reportedly because a connection to the database
-could not be established. The program decided that continuing was
-pointless and exited.
-
- 1..573
- not ok 1 - database handle
- Bail out! Couldn't connect to database.
-
-=head2 Skipping a few
-
-The following listing plans on running 5 tests. However, our program
-decided to not run tests 2 thru 5 at all. To properly report this,
-the tests are marked as being skipped.
-
- 1..5
- ok 1 - approved operating system
- # $^0 is solaris
- ok 2 - # SKIP no /sys directory
- ok 3 - # SKIP no /sys directory
- ok 4 - # SKIP no /sys directory
- ok 5 - # SKIP no /sys directory
-
-=head2 Skipping everything
-
-This listing shows that the entire listing is a skip. No tests were run.
-
- 1..0 # skip because English-to-French translator isn't installed
-
-=head2 Got spare tuits?
-
-The following example reports that four tests are run and the last two
-tests failed. However, because the failing tests are marked as things
-to do later, they are considered successes. Thus, a harness should report
-this entire listing as a success.
-
- 1..4
- ok 1 - Creating test program
- ok 2 - Test program runs, no error
- not ok 3 - infinite loop # TODO halting problem unsolved
- not ok 4 - infinite loop 2 # TODO halting problem unsolved
-
-=head2 Creative liberties
-
-This listing shows an alternate output where the test numbers aren't
-provided. The test also reports the state of a ficticious board game in
-diagnostic form. Finally, the test count is reported at the end.
-
- ok - created Board
- ok
- ok
- ok
- ok
- ok
- ok
- ok
- # +------+------+------+------+
- # | |16G | |05C |
- # | |G N C | |C C G |
- # | | G | | C +|
- # +------+------+------+------+
- # |10C |01G | |03C |
- # |R N G |G A G | |C C C |
- # | R | G | | C +|
- # +------+------+------+------+
- # | |01G |17C |00C |
- # | |G A G |G N R |R N R |
- # | | G | R | G |
- # +------+------+------+------+
- ok - board has 7 tiles + starter tile
- 1..9
-
-=head1 AUTHORS
-
-Andy Lester, based on the original Test::Harness documentation by Michael Schwern.
-
-=head1 ACKNOWLEDGEMENTS
-
-Thanks to
-Pete Krawczyk,
-Paul Johnson,
-Ian Langworth
-and Nik Clayton
-for help and contributions on this document.
-
-The basis for the TAP format was created by Larry Wall in the
-original test script for Perl 1. Tim Bunce and Andreas Koenig
-developed it further with their modifications to Test::Harness.
-
-=head1 COPYRIGHT
-
-Copyright 2003-2005 by
-Michael G Schwern C<< <schwern@pobox.com> >>,
-Andy Lester C<< <andy@petdance.com> >>.
-
-This program is free software; you can redistribute it and/or
-modify it under the same terms as Perl itself.
-
-See L<http://www.perl.com/perl/misc/Artistic.html>.
-
-=cut
diff --git a/gnu/usr.bin/perl/lib/Test/Harness/Util.pm b/gnu/usr.bin/perl/lib/Test/Harness/Util.pm
deleted file mode 100644
index 0cda2fee6f6..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Harness/Util.pm
+++ /dev/null
@@ -1,133 +0,0 @@
-package Test::Harness::Util;
-
-use strict;
-use vars qw($VERSION);
-$VERSION = '0.01';
-
-use File::Spec;
-use Exporter;
-use vars qw( @ISA @EXPORT @EXPORT_OK );
-
-@ISA = qw( Exporter );
-@EXPORT = ();
-@EXPORT_OK = qw( all_in shuffle blibdirs );
-
-=head1 NAME
-
-Test::Harness::Util - Utility functions for Test::Harness::*
-
-=head1 SYNOPSIS
-
-Utility functions for Test::Harness::*
-
-=head1 PUBLIC FUNCTIONS
-
-The following are all available to be imported to your module. No symbols
-are exported by default.
-
-=head2 all_in( {parm => value, parm => value} )
-
-Finds all the F<*.t> in a directory. Knows to skip F<.svn> and F<CVS>
-directories.
-
-Valid parms are:
-
-=over
-
-=item start
-
-Starting point for the search. Defaults to ".".
-
-=item recurse
-
-Flag to say whether it should recurse. Default to true.
-
-=back
-
-=cut
-
-sub all_in {
- my $parms = shift;
- my %parms = (
- start => ".",
- recurse => 1,
- %$parms,
- );
-
- my @hits = ();
- my $start = $parms{start};
-
- local *DH;
- if ( opendir( DH, $start ) ) {
- my @files = sort readdir DH;
- closedir DH;
- for my $file ( @files ) {
- next if $file eq File::Spec->updir || $file eq File::Spec->curdir;
- next if $file eq ".svn";
- next if $file eq "CVS";
-
- my $currfile = File::Spec->catfile( $start, $file );
- if ( -d $currfile ) {
- push( @hits, all_in( { %parms, start => $currfile } ) ) if $parms{recurse};
- }
- else {
- push( @hits, $currfile ) if $currfile =~ /\.t$/;
- }
- }
- }
- else {
- warn "$start: $!\n";
- }
-
- return @hits;
-}
-
-=head1 shuffle( @list )
-
-Returns a shuffled copy of I<@list>.
-
-=cut
-
-sub shuffle {
- # Fisher-Yates shuffle
- my $i = @_;
- while ($i) {
- my $j = rand $i--;
- @_[$i, $j] = @_[$j, $i];
- }
-}
-
-
-=head2 blibdir()
-
-Finds all the blib directories. Stolen directly from blib.pm
-
-=cut
-
-sub blibdirs {
- my $dir = File::Spec->curdir;
- if ($^O eq 'VMS') {
- ($dir = VMS::Filespec::unixify($dir)) =~ s-/\z--;
- }
- my $archdir = "arch";
- if ( $^O eq "MacOS" ) {
- # Double up the MP::A so that it's not used only once.
- $archdir = $MacPerl::Architecture = $MacPerl::Architecture;
- }
-
- my $i = 5;
- while ($i--) {
- my $blib = File::Spec->catdir( $dir, "blib" );
- my $blib_lib = File::Spec->catdir( $blib, "lib" );
- my $blib_arch = File::Spec->catdir( $blib, $archdir );
-
- if ( -d $blib && -d $blib_arch && -d $blib_lib ) {
- return ($blib_arch,$blib_lib);
- }
- $dir = File::Spec->catdir($dir, File::Spec->updir);
- }
- warn "$0: Cannot find blib\n";
- return;
-}
-
-1;
diff --git a/gnu/usr.bin/perl/lib/Test/Harness/bin/prove b/gnu/usr.bin/perl/lib/Test/Harness/bin/prove
deleted file mode 100644
index 44a631b8473..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Harness/bin/prove
+++ /dev/null
@@ -1,330 +0,0 @@
-#!/usr/bin/perl -w
-
-use strict;
-
-use Test::Harness;
-use Getopt::Long;
-use Pod::Usage 1.12;
-use File::Spec;
-
-use vars qw( $VERSION );
-$VERSION = "1.04";
-
-my @ext = ();
-my $shuffle = 0;
-my $dry = 0;
-my $blib = 0;
-my $lib = 0;
-my $recurse = 0;
-my @includes = ();
-my @switches = ();
-
-# Allow cuddling the paths with the -I
-@ARGV = map { /^(-I)(.+)/ ? ($1,$2) : $_ } @ARGV;
-
-# Stick any default switches at the beginning, so they can be overridden
-# by the command line switches.
-unshift @ARGV, split( " ", $ENV{PROVE_SWITCHES} ) if defined $ENV{PROVE_SWITCHES};
-
-Getopt::Long::Configure( "no_ignore_case" );
-Getopt::Long::Configure( "bundling" );
-GetOptions(
- 'b|blib' => \$blib,
- 'd|debug' => \$Test::Harness::debug,
- 'D|dry' => \$dry,
- 'h|help|?' => sub {pod2usage({-verbose => 1, -input => \*DATA}); exit},
- 'H|man' => sub {pod2usage({-verbose => 2, -input => \*DATA}); exit},
- 'I=s@' => \@includes,
- 'l|lib' => \$lib,
- 'r|recurse' => \$recurse,
- 's|shuffle' => \$shuffle,
- 't' => sub { unshift @switches, "-t" }, # Always want -t up front
- 'T' => sub { unshift @switches, "-T" }, # Always want -T up front
- 'v|verbose' => \$Test::Harness::verbose,
- 'V|version' => sub { print_version(); exit; },
- 'ext=s@' => \@ext,
-) or exit 1;
-
-# Build up extensions regex
-@ext = map { split /,/ } @ext;
-s/^\.// foreach @ext;
-@ext = ("t") unless @ext;
-my $ext_regex = join( "|", map { quotemeta } @ext );
-$ext_regex = qr/\.($ext_regex)$/;
-
-# Handle blib includes
-if ( $blib ) {
- my @blibdirs = blibdirs();
- if ( @blibdirs ) {
- unshift @includes, @blibdirs;
- } else {
- warn "No blib directories found.\n";
- }
-}
-
-# Handle lib includes
-if ( $lib ) {
- unshift @includes, "lib";
-}
-
-# Build up TH switches
-push( @switches, map { /\s/ && !/^".*"$/ ? qq["-I$_"] : "-I$_" } @includes );
-$Test::Harness::Switches = join( " ", @switches );
-print "# \$Test::Harness::Switches: $Test::Harness::Switches\n" if $Test::Harness::debug;
-
-my @tests;
-@ARGV = File::Spec->curdir unless @ARGV;
-push( @tests, -d $_ ? all_in( $_ ) : $_ ) for @ARGV;
-
-if ( @tests ) {
- shuffle(@tests) if $shuffle;
- if ( $dry ) {
- print join( "\n", @tests, "" );
- } else {
- print "# ", scalar @tests, " tests to run\n" if $Test::Harness::debug;
- runtests(@tests);
- }
-}
-
-sub all_in {
- my $start = shift;
-
- my @hits = ();
-
- local *DH;
- if ( opendir( DH, $start ) ) {
- while ( my $file = readdir DH ) {
- next if $file eq File::Spec->updir || $file eq File::Spec->curdir;
- next if $file eq ".svn";
- next if $file eq "CVS";
-
- my $currfile = File::Spec->catfile( $start, $file );
- if ( -d $currfile ) {
- push( @hits, all_in( $currfile ) ) if $recurse;
- } else {
- push( @hits, $currfile ) if $currfile =~ $ext_regex;
- }
- }
- } else {
- warn "$start: $!\n";
- }
-
- return @hits;
-}
-
-sub shuffle {
- # Fisher-Yates shuffle
- my $i = @_;
- while ($i) {
- my $j = rand $i--;
- @_[$i, $j] = @_[$j, $i];
- }
-}
-
-sub print_version {
- printf( "prove v%s, using Test::Harness v%s and Perl v%vd\n",
- $VERSION, $Test::Harness::VERSION, $^V );
-}
-
-# Stolen directly from blib.pm
-sub blibdirs {
- my $dir = File::Spec->curdir;
- if ($^O eq 'VMS') {
- ($dir = VMS::Filespec::unixify($dir)) =~ s-/\z--;
- }
- my $archdir = "arch";
- if ( $^O eq "MacOS" ) {
- # Double up the MP::A so that it's not used only once.
- $archdir = $MacPerl::Architecture = $MacPerl::Architecture;
- }
-
- my $i = 5;
- while ($i--) {
- my $blib = File::Spec->catdir( $dir, "blib" );
- my $blib_lib = File::Spec->catdir( $blib, "lib" );
- my $blib_arch = File::Spec->catdir( $blib, $archdir );
-
- if ( -d $blib && -d $blib_arch && -d $blib_lib ) {
- return ($blib_arch,$blib_lib);
- }
- $dir = File::Spec->catdir($dir, File::Spec->updir);
- }
- warn "$0: Cannot find blib\n";
- return;
-}
-
-__END__
-
-=head1 NAME
-
-prove -- A command-line tool for running tests against Test::Harness
-
-=head1 SYNOPSIS
-
-prove [options] [files/directories]
-
-Options:
-
- -b, --blib Adds blib/lib to the path for your tests, a la "use blib".
- -d, --debug Includes extra debugging information.
- -D, --dry Dry run: Show the tests to run, but don't run them.
- --ext=x Extensions (defaults to .t)
- -h, --help Display this help
- -H, --man Longer manpage for prove
- -I Add libraries to @INC, as Perl's -I
- -l, --lib Add lib to the path for your tests.
- -r, --recurse Recursively descend into directories.
- -s, --shuffle Run the tests in a random order.
- -T Enable tainting checks
- -t Enable tainting warnings
- -v, --verbose Display standard output of test scripts while running them.
- -V, --version Display version info
-
-Single-character options may be stacked. Default options may be set by
-specifying the PROVE_SWITCHES environment variable.
-
-=head1 OVERVIEW
-
-F<prove> is a command-line interface to the test-running functionality
-of C<Test::Harness>. With no arguments, it will run all tests in the
-current directory.
-
-Shell metacharacters may be used with command lines options and will be exanded
-via C<glob>.
-
-=head1 PROVE VS. "MAKE TEST"
-
-F<prove> has a number of advantages over C<make test> when doing development.
-
-=over 4
-
-=item * F<prove> is designed as a development tool
-
-Perl users typically run the test harness through a makefile via
-C<make test>. That's fine for module distributions, but it's
-suboptimal for a test/code/debug development cycle.
-
-=item * F<prove> is granular
-
-F<prove> lets your run against only the files you want to check.
-Running C<prove t/live/ t/master.t> checks every F<*.t> in F<t/live>,
-plus F<t/master.t>.
-
-=item * F<prove> has an easy verbose mode
-
-F<prove> has a C<-v> option to see the raw output from the tests.
-To do this with C<make test>, you must set C<HARNESS_VERBOSE=1> in
-the environment.
-
-=item * F<prove> can run under taint mode
-
-F<prove>'s C<-T> runs your tests under C<perl -T>, and C<-t> runs them
-under C<perl -t>.
-
-=item * F<prove> can shuffle tests
-
-You can use F<prove>'s C<--shuffle> option to try to excite problems
-that don't show up when tests are run in the same order every time.
-
-=item * F<prove> doesn't rely on a make tool
-
-Not everyone wants to write a makefile, or use L<ExtUtils::MakeMaker>
-to do so. F<prove> has no external dependencies.
-
-=item * Not everything is a module
-
-More and more users are using Perl's testing tools outside the
-context of a module distribution, and may not even use a makefile
-at all.
-
-=back
-
-=head1 COMMAND LINE OPTIONS
-
-=head2 -b, --blib
-
-Adds blib/lib to the path for your tests, a la "use blib".
-
-=head2 -d, --debug
-
-Include debug information about how F<prove> is being run. This
-option doesn't show the output from the test scripts. That's handled
-by -v,--verbose.
-
-=head2 -D, --dry
-
-Dry run: Show the tests to run, but don't run them.
-
-=head2 --ext=extension
-
-Specify extensions of the test files to run. By default, these are .t,
-but you may have other non-.t test files, most likely .sh shell scripts.
-The --ext is repeatable.
-
-=head2 -I
-
-Add libraries to @INC, as Perl's -I.
-
-=head2 -l, --lib
-
-Add C<lib> to @INC. Equivalent to C<-Ilib>.
-
-=head2 -r, --recurse
-
-Descends into subdirectories of any directories specified, looking for tests.
-
-=head2 -s, --shuffle
-
-Sometimes tests are accidentally dependent on tests that have been
-run before. This switch will shuffle the tests to be run prior to
-running them, thus ensuring that hidden dependencies in the test
-order are likely to be revealed. The author hopes the run the
-algorithm on the preceding sentence to see if he can produce something
-slightly less awkward.
-
-=head2 -t
-
-Runs test programs under perl's -t taint warning mode.
-
-=head2 -T
-
-Runs test programs under perl's -T taint mode.
-
-=head2 -v, --verbose
-
-Display standard output of test scripts while running them.
-
-=head2 -V, --version
-
-Display version info.
-
-=head1 BUGS
-
-Please use the CPAN bug ticketing system at L<http://rt.cpan.org/>.
-You can also mail bugs, fixes and enhancements to
-C<< <bug-test-harness@rt.cpan.org> >>.
-
-=head1 TODO
-
-=over 4
-
-=item *
-
-Shuffled tests must be recreatable
-
-=back
-
-=head1 AUTHORS
-
-Andy Lester C<< <andy@petdance.com> >>
-
-=head1 COPYRIGHT
-
-Copyright 2003 by Andy Lester C<< <andy@petdance.com> >>.
-
-This program is free software; you can redistribute it and/or
-modify it under the same terms as Perl itself.
-
-See L<http://www.perl.com/perl/misc/Artistic.html>.
-
-=cut
diff --git a/gnu/usr.bin/perl/lib/Test/Harness/t/00compile.t b/gnu/usr.bin/perl/lib/Test/Harness/t/00compile.t
deleted file mode 100644
index 6ea2ce66b17..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Harness/t/00compile.t
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/usr/bin/perl -Tw
-
-BEGIN {
- if($ENV{PERL_CORE}) {
- chdir 't';
- @INC = '../lib';
- }
- else {
- unshift @INC, 't/lib';
- }
-}
-
-use Test::More tests => 5;
-
-BEGIN { use_ok 'Test::Harness' }
-
-BEGIN { use_ok 'Test::Harness::Straps' }
-
-BEGIN { use_ok 'Test::Harness::Iterator' }
-
-BEGIN { use_ok 'Test::Harness::Assert' }
-
-# If the $VERSION is set improperly, this will spew big warnings.
-use_ok 'Test::Harness', 1.1601;
diff --git a/gnu/usr.bin/perl/lib/Test/Harness/t/assert.t b/gnu/usr.bin/perl/lib/Test/Harness/t/assert.t
deleted file mode 100644
index 9ff7305b29b..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Harness/t/assert.t
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/usr/bin/perl -Tw
-
-BEGIN {
- if( $ENV{PERL_CORE} ) {
- chdir 't';
- @INC = ('../lib', 'lib');
- }
- else {
- unshift @INC, 't/lib';
- }
-}
-
-use strict;
-
-use Test::More tests => 6;
-
-use Test::Harness::Assert;
-
-
-ok( defined &assert, 'assert() exported' );
-
-ok( !eval { assert( 0 ); 1 }, 'assert( FALSE ) causes death' );
-like( $@, '/Assert failed/', ' with the right message' );
-
-ok( eval { assert( 1 ); 1 }, 'assert( TRUE ) does nothing' );
-
-ok( !eval { assert( 0, 'some name' ); 1 }, 'assert( FALSE, NAME )' );
-like( $@, '/some name/', ' has the name' );
diff --git a/gnu/usr.bin/perl/lib/Test/Harness/t/base.t b/gnu/usr.bin/perl/lib/Test/Harness/t/base.t
deleted file mode 100644
index 5ad05e90f7b..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Harness/t/base.t
+++ /dev/null
@@ -1,15 +0,0 @@
-BEGIN {
- if( $ENV{PERL_CORE} ) {
- chdir 't';
- @INC = '../lib';
- }
-}
-
-
-print "1..1\n";
-
-unless (eval 'require Test::Harness') {
- print "not ok 1\n";
-} else {
- print "ok 1\n";
-}
diff --git a/gnu/usr.bin/perl/lib/Test/Harness/t/callback.t b/gnu/usr.bin/perl/lib/Test/Harness/t/callback.t
deleted file mode 100644
index d77495887ce..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Harness/t/callback.t
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/usr/bin/perl -w
-
-BEGIN {
- if( $ENV{PERL_CORE} ) {
- chdir 't';
- @INC = ('../lib', 'lib');
- }
- else {
- unshift @INC, 't/lib';
- }
-}
-
-use Test::More;
-use File::Spec;
-
-my $Curdir = File::Spec->curdir;
-my $SAMPLE_TESTS = $ENV{PERL_CORE}
- ? File::Spec->catdir($Curdir, 'lib', 'sample-tests')
- : File::Spec->catdir($Curdir, 't', 'sample-tests');
-
-%samples = (
- bailout => [qw( header test test test bailout )],
- combined => ['header', ('test') x 10],
- descriptive => ['header', ('test') x 5 ],
- duplicates => ['header', ('test') x 11 ],
- head_end => [qw( other test test test test
- other header other other )],
- head_fail => [qw( other test test test test
- other header other other )],
- no_nums => ['header', ('test') x 5 ],
- out_of_order=> [('test') x 10, 'header', ('test') x 5],
- simple => [qw( header test test test test test )],
- simple_fail => [qw( header test test test test test )],
- 'skip' => [qw( header test test test test test )],
- skipall => [qw( header )],
- skipall_nomsg => [qw( header )],
- skip_nomsg => [qw( header test )],
- taint => [qw( header test )],
- 'todo' => [qw( header test test test test test )],
- todo_inline => [qw( header test test test )],
- vms_nit => [qw( header other test test )],
- with_comments => [qw( other header other test other test test
- test other other test other )],
- );
-
-plan tests => scalar keys %samples;
-
-use Test::Harness::Straps;
-my $strap = Test::Harness::Straps->new;
-$strap->{callback} = sub {
- my($self, $line, $type, $totals) = @_;
- push @out, $type;
-};
-
-while( my($test, $expect) = each %samples ) {
- local @out = ();
- $strap->analyze_file(File::Spec->catfile($SAMPLE_TESTS, $test));
-
- is_deeply(\@out, $expect, "$test callback");
-}
diff --git a/gnu/usr.bin/perl/lib/Test/Harness/t/failure.t b/gnu/usr.bin/perl/lib/Test/Harness/t/failure.t
deleted file mode 100644
index 76d8dc934fb..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Harness/t/failure.t
+++ /dev/null
@@ -1,53 +0,0 @@
-#!/usr/bin/perl -w
-
-BEGIN {
- if ($^O eq 'VMS') {
- print '1..0 # Child test output confuses parent test counter';
- exit;
- }
-}
-
-BEGIN {
- if ( $ENV{PERL_CORE} ) {
- chdir 't';
- @INC = ('../lib', 'lib');
- }
- else {
- unshift @INC, 't/lib';
- }
-}
-
-use strict;
-
-use Test::More tests => 6;
-use File::Spec;
-
-BEGIN {
- use_ok( 'Test::Harness' );
-}
-
-my $died;
-sub prepare_for_death { $died = 0; }
-sub signal_death { $died = 1; }
-
-my $Curdir = File::Spec->curdir;
-my $SAMPLE_TESTS = $ENV{PERL_CORE}
- ? File::Spec->catdir($Curdir, 'lib', 'sample-tests')
- : File::Spec->catdir($Curdir, 't', 'sample-tests');
-
-PASSING: {
- local $SIG{__DIE__} = \&signal_death;
- prepare_for_death();
- eval { runtests( File::Spec->catfile( $SAMPLE_TESTS, "simple" ) ) };
- ok( !$@, "simple lives" );
- is( $died, 0, "Death never happened" );
-}
-
-FAILING: {
- local $SIG{__DIE__} = \&signal_death;
- prepare_for_death();
- eval { runtests( File::Spec->catfile( $SAMPLE_TESTS, "too_many" ) ) };
- ok( $@, "$@" );
- ok( $@ =~ m[Failed 1/1], "too_many dies" );
- is( $died, 1, "Death happened" );
-}
diff --git a/gnu/usr.bin/perl/lib/Test/Harness/t/from_line.t b/gnu/usr.bin/perl/lib/Test/Harness/t/from_line.t
deleted file mode 100755
index b9e726449f1..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Harness/t/from_line.t
+++ /dev/null
@@ -1,64 +0,0 @@
-#!perl -Tw
-
-BEGIN {
- if ( $ENV{PERL_CORE} ) {
- chdir 't';
- @INC = '../lib';
- }
- else {
- unshift @INC, 't/lib';
- }
-}
-
-use strict;
-use Test::More tests => 23;
-
-BEGIN {
- use_ok( 'Test::Harness::Point' );
-}
-
-BASIC_OK: {
- my $line = "ok 14 - Blah blah";
- my $point = Test::Harness::Point->from_test_line( $line );
- isa_ok( $point, 'Test::Harness::Point', 'BASIC_OK' );
- is( $point->number, 14 );
- ok( $point->ok );
- is( $point->description, 'Blah blah' );
-}
-
-BASIC_NOT_OK: {
- my $line = "not ok 267 Yada";
- my $point = Test::Harness::Point->from_test_line( $line );
- isa_ok( $point, 'Test::Harness::Point', 'BASIC_NOT_OK' );
- is( $point->number, 267 );
- ok( !$point->ok );
- is( $point->description, 'Yada' );
-}
-
-CRAP: {
- my $point = Test::Harness::Point->from_test_line( 'ok14 - Blah' );
- ok( !defined $point, 'CRAP 1' );
-
- $point = Test::Harness::Point->from_test_line( 'notok 14' );
- ok( !defined $point, 'CRAP 2' );
-}
-
-PARSE_TODO: {
- my $point = Test::Harness::Point->from_test_line( 'not ok 14 - Calculate sqrt(-1) # TODO Still too rational' );
- isa_ok( $point, 'Test::Harness::Point', 'PARSE_TODO' );
- is( $point->description, 'Calculate sqrt(-1)' );
- is( $point->directive_type, 'todo' );
- is( $point->directive_reason, 'Still too rational' );
- ok( !$point->is_skip );
- ok( $point->is_todo );
-}
-
-PARSE_SKIP: {
- my $point = Test::Harness::Point->from_test_line( 'ok 14 # skip Not on bucket #6' );
- isa_ok( $point, 'Test::Harness::Point', 'PARSE_SKIP' );
- is( $point->description, '' );
- is( $point->directive_type, 'skip' );
- is( $point->directive_reason, 'Not on bucket #6' );
- ok( $point->is_skip );
- ok( !$point->is_todo );
-}
diff --git a/gnu/usr.bin/perl/lib/Test/Harness/t/harness.t b/gnu/usr.bin/perl/lib/Test/Harness/t/harness.t
deleted file mode 100755
index 33b8d247958..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Harness/t/harness.t
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/usr/bin/perl -Tw
-
-BEGIN {
- if ( $ENV{PERL_CORE} ) {
- chdir 't';
- @INC = ('../lib', 'lib');
- }
- else {
- unshift @INC, 't/lib';
- }
-}
-
-use strict;
-
-use Test::More tests => 2;
-
-BEGIN {
- use_ok( 'Test::Harness' );
-}
-
-my $strap = Test::Harness->strap;
-isa_ok( $strap, 'Test::Harness::Straps' );
diff --git a/gnu/usr.bin/perl/lib/Test/Harness/t/inc_taint.t b/gnu/usr.bin/perl/lib/Test/Harness/t/inc_taint.t
deleted file mode 100755
index f1c8145e957..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Harness/t/inc_taint.t
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/usr/bin/perl -w
-
-BEGIN {
- if( $ENV{PERL_CORE} ) {
- chdir 't';
- @INC = ('../lib', 'lib');
- }
- else {
- unshift @INC, 't/lib';
- }
-}
-
-use Test::Harness;
-use Test::More tests => 1;
-use Dev::Null;
-
-push @INC, 'we_added_this_lib';
-
-tie *NULL, 'Dev::Null' or die $!;
-select NULL;
-my($tot, $failed) = Test::Harness::_run_all_tests(
- $ENV{PERL_CORE}
- ? 'lib/sample-tests/inc_taint'
- : 't/sample-tests/inc_taint'
-);
-select STDOUT;
-
-ok( Test::Harness::_all_ok($tot), 'tests with taint on preserve @INC' );
diff --git a/gnu/usr.bin/perl/lib/Test/Harness/t/nonumbers.t b/gnu/usr.bin/perl/lib/Test/Harness/t/nonumbers.t
deleted file mode 100644
index a5dc4117356..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Harness/t/nonumbers.t
+++ /dev/null
@@ -1,14 +0,0 @@
-if( $ENV{PERL_CORE} && !$ENV{HARNESS_ACTIVE} ) {
- print "1..0 # Skip: t/TEST needs numbers\n";
- exit;
-}
-
-print <<END;
-1..6
-ok
-ok
-ok
-ok
-ok
-ok
-END
diff --git a/gnu/usr.bin/perl/lib/Test/Harness/t/ok.t b/gnu/usr.bin/perl/lib/Test/Harness/t/ok.t
deleted file mode 100644
index a10938f9f0c..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Harness/t/ok.t
+++ /dev/null
@@ -1,8 +0,0 @@
--f "core" and unlink "core";
-print <<END;
-1..4
-ok 1
-ok 2
-ok 3
-ok 4
-END
diff --git a/gnu/usr.bin/perl/lib/Test/Harness/t/point-parse.t b/gnu/usr.bin/perl/lib/Test/Harness/t/point-parse.t
deleted file mode 100755
index e4de491a77f..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Harness/t/point-parse.t
+++ /dev/null
@@ -1,106 +0,0 @@
-#!/usr/bin/perl -w
-
-BEGIN {
- if ( $ENV{PERL_CORE} ) {
- chdir 't';
- @INC = ('../lib', 'lib');
- }
- else {
- unshift @INC, 't/lib';
- }
-}
-
-use strict;
-
-use Test::More tests => 52;
-
-BEGIN {
- use_ok( 'Test::Harness::Point' );
- use_ok( 'Test::Harness::Straps' );
-}
-
-my $strap = Test::Harness::Straps->new;
-isa_ok( $strap, 'Test::Harness::Straps', 'new()' );
-
-
-my $testlines = {
- 'not ok' => {
- ok => 0
- },
- 'not ok # TODO' => {
- ok => 0,
- reason => '',
- type => 'todo'
- },
- 'not ok 1' => {
- number => 1,
- ok => 0
- },
- 'not ok 11 - this is \\# all the name # skip this is not' => {
- description => 'this is \\# all the name',
- number => 11,
- ok => 0,
- reason => 'this is not',
- type => 'skip'
- },
- 'not ok 23 # TODO world peace' => {
- number => 23,
- ok => 0,
- reason => 'world peace',
- type => 'todo'
- },
- 'not ok 42 - universal constant' => {
- description => 'universal constant',
- number => 42,
- ok => 0
- },
- ok => {
- ok => 1
- },
- 'ok # skip' => {
- ok => 1,
- type => 'skip'
- },
- 'ok 1' => {
- number => 1,
- ok => 1
- },
- 'ok 1066 - and all that' => {
- description => 'and all that',
- number => 1066,
- ok => 1
- },
- 'ok 11 - have life # TODO get a life' => {
- description => 'have life',
- number => 11,
- ok => 1,
- reason => 'get a life',
- type => 'todo'
- },
- 'ok 2938' => {
- number => 2938,
- ok => 1
- },
- 'ok 42 - _is_header() is a header \'1..192 todo 4 2 13 192 \\# Skip skip skip because' => {
- description => '_is_header() is a header \'1..192 todo 4 2 13 192 \\# Skip skip skip because',
- number => 42,
- ok => 1
- }
-};
-my @untests = (
- ' ok',
- 'not',
- 'okay 23',
- );
-
-for my $line ( sort keys %$testlines ) {
- my $point = Test::Harness::Point->from_test_line( $line );
- isa_ok( $point, 'Test::Harness::Point' );
-
- my $fields = $testlines->{$line};
- for my $property ( sort keys %$fields ) {
- my $value = $fields->{$property};
- is( eval "\$point->$property", $value, "$property on $line" );
- # Perls pre-5.6 can't handle $point->$property, and must be eval()d
- }
-}
diff --git a/gnu/usr.bin/perl/lib/Test/Harness/t/point.t b/gnu/usr.bin/perl/lib/Test/Harness/t/point.t
deleted file mode 100755
index 1c8cf9da737..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Harness/t/point.t
+++ /dev/null
@@ -1,58 +0,0 @@
-#!perl -Tw
-
-BEGIN {
- if ( $ENV{PERL_CORE} ) {
- chdir 't';
- @INC = ('../lib', 'lib');
- }
- else {
- unshift @INC, 't/lib';
- }
-}
-
-use strict;
-use Test::More tests => 11;
-
-BEGIN {
- use_ok( 'Test::Harness::Point' );
-}
-
-my $point = Test::Harness::Point->new;
-isa_ok( $point, 'Test::Harness::Point' );
-ok( !$point->ok, "Should start out not OK" );
-
-$point->set_ok( 1 );
-ok( $point->ok, "should have turned to true" );
-
-$point->set_ok( 0 );
-ok( !$point->ok, "should have turned false" );
-
-$point->set_number( 2112 );
-is( $point->number, 2112, "Number is set" );
-
-$point->set_description( "Blah blah" );
-is( $point->description, "Blah blah", "Description set" );
-
-$point->set_directive( "Go now" );
-is( $point->directive, "Go now", "Directive set" );
-
-$point->add_diagnostic( "# Line 1" );
-$point->add_diagnostic( "# Line two" );
-$point->add_diagnostic( "# Third line" );
-my @diags = $point->diagnostics;
-is( @diags, 3, "Three lines" );
-is_deeply(
- \@diags,
- [ "# Line 1", "# Line two", "# Third line" ],
- "Diagnostics in list context"
-);
-
-my $diagstr = <<EOF;
-# Line 1
-# Line two
-# Third line
-EOF
-
-chomp $diagstr;
-my $string_diagnostics = $point->diagnostics;
-is( $string_diagnostics, $diagstr, "Diagnostics in scalar context" );
diff --git a/gnu/usr.bin/perl/lib/Test/Harness/t/prove-globbing.t b/gnu/usr.bin/perl/lib/Test/Harness/t/prove-globbing.t
deleted file mode 100755
index e0f3c864a64..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Harness/t/prove-globbing.t
+++ /dev/null
@@ -1,31 +0,0 @@
-BEGIN {
- if( $ENV{PERL_CORE} ) {
- chdir 't';
- @INC = ('../lib', 'lib');
- }
- else {
- unshift @INC, 't/lib';
- }
-}
-
-use strict;
-use File::Spec;
-use Test::More;
-plan skip_all => "Not adapted to perl core" if $ENV{PERL_CORE};
-plan skip_all => "Not installing prove" if -e "t/SKIP-PROVE";
-
-plan tests => 1;
-
-my $prove = File::Spec->catfile( File::Spec->curdir, "blib", "script", "prove" );
-my $tests = File::Spec->catfile( 't', 'prove*.t' );
-
-GLOBBAGE: {
- my @actual = sort qx/$prove --dry $tests/;
- chomp @actual;
-
- my @expected = (
- File::Spec->catfile( "t", "prove-globbing.t" ),
- File::Spec->catfile( "t", "prove-switches.t" ),
- );
- is_deeply( \@actual, \@expected, "Expands the wildcards" );
-}
diff --git a/gnu/usr.bin/perl/lib/Test/Harness/t/prove-switches.t b/gnu/usr.bin/perl/lib/Test/Harness/t/prove-switches.t
deleted file mode 100755
index aa7ece97e0e..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Harness/t/prove-switches.t
+++ /dev/null
@@ -1,85 +0,0 @@
-BEGIN {
- if( $ENV{PERL_CORE} ) {
- chdir 't';
- @INC = ('../lib', 'lib');
- }
- else {
- unshift @INC, 't/lib';
- }
-}
-
-use strict;
-use File::Spec;
-use Test::More;
-plan skip_all => "Not adapted to perl core" if $ENV{PERL_CORE};
-plan skip_all => "Not installing prove" if -e "t/SKIP-PROVE";
-
-plan tests => 5;
-
-my $blib = File::Spec->catfile( File::Spec->curdir, "blib" );
-my $blib_lib = File::Spec->catfile( $blib, "lib" );
-my $blib_arch = File::Spec->catfile( $blib, "arch" );
-my $prove = File::Spec->catfile( $blib, "script", "prove" );
-
-CAPITAL_TAINT: {
- local $ENV{PROVE_SWITCHES};
- local $/ = undef;
-
- my @actual = qx/$prove -Ifirst -D -I second -Ithird -Tvdb/;
- my @expected = ( "# \$Test::Harness::Switches: -T -I$blib_arch -I$blib_lib -Ifirst -Isecond -Ithird\n" );
- array_match_ok( \@actual, \@expected, "Capital taint flags OK" );
-}
-
-LOWERCASE_TAINT: {
- local $ENV{PROVE_SWITCHES};
- local $/ = undef;
-
- my @actual = qx/$prove -dD -Ifirst -I second -t -Ithird -vb/;
- my @expected = ( "# \$Test::Harness::Switches: -t -I$blib_arch -I$blib_lib -Ifirst -Isecond -Ithird\n" );
- array_match_ok( \@actual, \@expected, "Lowercase taint OK" );
-}
-
-PROVE_SWITCHES: {
- local $ENV{PROVE_SWITCHES} = "-dvb -I fark";
- local $/ = undef;
-
- my @actual = qx/$prove -Ibork -Dd/;
- my @expected = ( "# \$Test::Harness::Switches: -I$blib_arch -I$blib_lib -Ifark -Ibork\n" );
- array_match_ok( \@actual, \@expected, "PROVE_SWITCHES OK" );
-}
-
-PROVE_SWITCHES_L: {
- local $/ = undef;
-
- my @actual = qx/$prove -l -Ibongo -Dd/;
- my @expected = ( "# \$Test::Harness::Switches: -Ilib -Ibongo\n" );
- array_match_ok( \@actual, \@expected, "PROVE_SWITCHES OK" );
-}
-
-PROVE_SWITCHES_LB: {
- local $/ = undef;
-
- my @actual = qx/$prove -lb -Dd/;
- my @expected = ( "# \$Test::Harness::Switches: -Ilib -I$blib_arch -I$blib_lib\n" );
- array_match_ok( \@actual, \@expected, "PROVE_SWITCHES OK" );
-}
-
-
-sub array_match_ok {
- my $actual = shift;
- my $expected = shift;
- my $message = shift;
- my $n = 0;
-
- my @actual = @$actual;
- my @expected = @$expected;
-
- while ( @actual && @expected ) {
- return ok( 0, "Differs at element $n: $message" ) if shift @actual ne shift @expected;
- ++$n;
- }
- return ok( 0, "Too many actual: $message" ) if @actual;
- return ok( 0, "Too many expected: $message" ) if @expected;
-
- return ok( 1, $message );
-}
diff --git a/gnu/usr.bin/perl/lib/Test/Harness/t/strap-analyze.t b/gnu/usr.bin/perl/lib/Test/Harness/t/strap-analyze.t
deleted file mode 100644
index 02fa1d63900..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Harness/t/strap-analyze.t
+++ /dev/null
@@ -1,493 +0,0 @@
-#!/usr/bin/perl -w
-
-BEGIN {
- if( $ENV{PERL_CORE} ) {
- chdir 't';
- @INC = ('../lib', 'lib');
- }
- else {
- unshift @INC, 't/lib';
- }
-}
-
-use strict;
-use Test::More;
-use File::Spec;
-
-my $Curdir = File::Spec->curdir;
-my $SAMPLE_TESTS = $ENV{PERL_CORE}
- ? File::Spec->catdir($Curdir, 'lib', 'sample-tests')
- : File::Spec->catdir($Curdir, 't', 'sample-tests');
-
-
-my $IsMacOS = $^O eq 'MacOS';
-my $IsVMS = $^O eq 'VMS';
-
-# VMS uses native, not POSIX, exit codes.
-my $die_exit = $IsVMS ? 44 : $IsMacOS ? 0 : 1;
-
-# We can only predict that the wait status should be zero or not.
-my $wait_non_zero = 1;
-
-my %samples = (
- combined => {
- passing => 0,
-
- 'exit' => 0,
- 'wait' => 0,
-
- max => 10,
- seen => 10,
-
- 'ok' => 8,
- 'todo' => 2,
- 'skip' => 1,
- bonus => 1,
-
- details => [ { 'ok' => 1, actual_ok => 1 },
- { 'ok' => 1, actual_ok => 1,
- name => 'basset hounds got long ears',
- },
- { 'ok' => 0, actual_ok => 0,
- name => 'all hell broke lose',
- },
- { 'ok' => 1, actual_ok => 1,
- type => 'todo'
- },
- { 'ok' => 1, actual_ok => 1 },
- { 'ok' => 1, actual_ok => 1 },
- { 'ok' => 1, actual_ok => 1,
- type => 'skip',
- reason => 'contract negociations'
- },
- { 'ok' => 1, actual_ok => 1 },
- { 'ok' => 0, actual_ok => 0 },
- { 'ok' => 1, actual_ok => 0,
- type => 'todo'
- },
- ]
- },
-
- descriptive => {
- passing => 1,
-
- 'wait' => 0,
- 'exit' => 0,
-
- max => 5,
- seen => 5,
-
- 'ok' => 5,
- 'todo' => 0,
- 'skip' => 0,
- bonus => 0,
-
- details => [ { 'ok' => 1, actual_ok => 1,
- name => 'Interlock activated'
- },
- { 'ok' => 1, actual_ok => 1,
- name => 'Megathrusters are go',
- },
- { 'ok' => 1, actual_ok => 1,
- name => 'Head formed',
- },
- { 'ok' => 1, actual_ok => 1,
- name => 'Blazing sword formed'
- },
- { 'ok' => 1, actual_ok => 1,
- name => 'Robeast destroyed'
- },
- ],
- },
-
- duplicates => {
- passing => 0,
-
- 'exit' => 0,
- 'wait' => 0,
-
- max => 10,
- seen => 11,
-
- 'ok' => 11,
- 'todo' => 0,
- 'skip' => 0,
- bonus => 0,
-
- details => [ ({ 'ok' => 1, actual_ok => 1 }) x 10
- ],
- },
-
- head_end => {
- passing => 1,
-
- 'exit' => 0,
- 'wait' => 0,
-
- max => 4,
- seen => 4,
-
- 'ok' => 4,
- 'todo' => 0,
- 'skip' => 0,
- bonus => 0,
-
- details => [ ({ 'ok' => 1, actual_ok => 1 }) x 4
- ],
- },
-
- lone_not_bug => {
- passing => 1,
-
- 'exit' => 0,
- 'wait' => 0,
-
- max => 4,
- seen => 4,
-
- 'ok' => 4,
- 'todo' => 0,
- 'skip' => 0,
- bonus => 0,
-
- details => [ ({ 'ok' => 1, actual_ok => 1 }) x 4
- ],
- },
-
- head_fail => {
- passing => 0,
-
- 'exit' => 0,
- 'wait' => 0,
-
- max => 4,
- seen => 4,
-
- 'ok' => 3,
- 'todo' => 0,
- 'skip' => 0,
- bonus => 0,
-
- details => [ { 'ok' => 1, actual_ok => 1 },
- { 'ok' => 0, actual_ok => 0 },
- ({ 'ok'=> 1, actual_ok => 1 }) x 2
- ],
- },
-
- simple => {
- passing => 1,
-
- 'exit' => 0,
- 'wait' => 0,
-
- max => 5,
- seen => 5,
-
- 'ok' => 5,
- 'todo' => 0,
- 'skip' => 0,
- bonus => 0,
-
- details => [ ({ 'ok' => 1, actual_ok => 1 }) x 5
- ]
- },
-
- simple_fail => {
- passing => 0,
-
- 'exit' => 0,
- 'wait' => 0,
-
- max => 5,
- seen => 5,
-
- 'ok' => 3,
- 'todo' => 0,
- 'skip' => 0,
- bonus => 0,
-
- details => [ { 'ok' => 1, actual_ok => 1 },
- { 'ok' => 0, actual_ok => 0 },
- { 'ok' => 1, actual_ok => 1 },
- { 'ok' => 1, actual_ok => 1 },
- { 'ok' => 0, actual_ok => 0 },
- ]
- },
-
- 'skip' => {
- passing => 1,
-
- 'exit' => 0,
- 'wait' => 0,
-
- max => 5,
- seen => 5,
-
- 'ok' => 5,
- 'todo' => 0,
- 'skip' => 1,
- bonus => 0,
-
- details => [ { 'ok' => 1, actual_ok => 1 },
- { 'ok' => 1, actual_ok => 1,
- type => 'skip',
- reason => 'rain delay',
- },
- ({ 'ok' => 1, actual_ok => 1 }) x 3
- ]
- },
-
- 'skip_nomsg' => {
- passing => 1,
-
- 'exit' => 0,
- 'wait' => 0,
-
- max => 1,
- seen => 1,
-
- 'ok' => 1,
- 'todo' => 0,
- 'skip' => 1,
- bonus => 0,
-
- details => [ { 'ok' => 1, actual_ok => 1,
- type => 'skip',
- reason => '',
- },
- ]
- },
-
- skipall => {
- passing => 1,
-
- 'exit' => 0,
- 'wait' => 0,
-
- max => 0,
- seen => 0,
- skip_all => 'rope',
-
- 'ok' => 0,
- 'todo' => 0,
- 'skip' => 0,
- bonus => 0,
-
- details => [],
- },
-
- skipall_nomsg => {
- passing => 1,
-
- 'exit' => 0,
- 'wait' => 0,
-
- max => 0,
- seen => 0,
-
- 'ok' => 0,
- 'todo' => 0,
- 'skip' => 0,
- bonus => 0,
-
- details => [],
- },
-
- 'todo' => {
- passing => 1,
-
- 'exit' => 0,
- 'wait' => 0,
-
- max => 5,
- seen => 5,
-
- 'ok' => 5,
- 'todo' => 2,
- 'skip' => 0,
- bonus => 1,
-
- details => [ { 'ok' => 1, actual_ok => 1 },
- { 'ok' => 1, actual_ok => 1,
- type => 'todo' },
- { 'ok' => 1, actual_ok => 0,
- type => 'todo' },
- ({ 'ok' => 1, actual_ok => 1 }) x 2
- ],
- },
- taint => {
- passing => 1,
-
- 'exit' => 0,
- 'wait' => 0,
-
- max => 1,
- seen => 1,
-
- 'ok' => 1,
- 'todo' => 0,
- 'skip' => 0,
- bonus => 0,
-
- details => [ { 'ok' => 1, actual_ok => 1,
- name => '- -T honored'
- },
- ],
- },
- vms_nit => {
- passing => 0,
-
- 'exit' => 0,
- 'wait' => 0,
-
- max => 2,
- seen => 2,
-
- 'ok' => 1,
- 'todo' => 0,
- 'skip' => 0,
- bonus => 0,
-
- details => [ { 'ok' => 0, actual_ok => 0 },
- { 'ok' => 1, actual_ok => 1 },
- ],
- },
- 'die' => {
- passing => 0,
-
- 'exit' => $die_exit,
- 'wait' => $wait_non_zero,
-
- max => 0,
- seen => 0,
-
- 'ok' => 0,
- 'todo' => 0,
- 'skip' => 0,
- bonus => 0,
-
- details => []
- },
-
- die_head_end => {
- passing => 0,
-
- 'exit' => $die_exit,
- 'wait' => $wait_non_zero,
-
- max => 0,
- seen => 4,
-
- 'ok' => 4,
- 'todo' => 0,
- 'skip' => 0,
- bonus => 0,
-
- details => [ ({ 'ok' => 1, actual_ok => 1 }) x 4
- ],
- },
-
- die_last_minute => {
- passing => 0,
-
- 'exit' => $die_exit,
- 'wait' => $wait_non_zero,
-
- max => 4,
- seen => 4,
-
- 'ok' => 4,
- 'todo' => 0,
- 'skip' => 0,
- bonus => 0,
-
- details => [ ({ 'ok' => 1, actual_ok => 1 }) x 4
- ],
- },
-
- bignum => {
- passing => 0,
-
- 'exit' => 0,
- 'wait' => 0,
-
- max => 2,
- seen => 4,
-
- 'ok' => 4,
- 'todo' => 0,
- 'skip' => 0,
- bonus => 0,
-
- details => [ { 'ok' => 1, actual_ok => 1 },
- { 'ok' => 1, actual_ok => 1 },
- ]
- },
-
- 'shbang_misparse' =>{
- passing => 1,
-
- 'exit' => 0,
- 'wait' => 0,
-
- max => 2,
- seen => 2,
-
- 'ok' => 2,
- 'todo' => 0,
- 'skip' => 0,
- bonus => 0,
-
- details => [ ({ 'ok' => 1, actual_ok => 1 }) x 2 ]
- },
-);
-
-plan tests => (keys(%samples) * 4) + 3;
-
-use_ok('Test::Harness::Straps');
-
-$SIG{__WARN__} = sub {
- warn @_ unless $_[0] =~ /^Enormous test number/ ||
- $_[0] =~ /^Can't detailize/
-};
-while( my($test, $expect) = each %samples ) {
- for (0..$#{$expect->{details}}) {
- $expect->{details}[$_]{type} = ''
- unless exists $expect->{details}[$_]{type};
- $expect->{details}[$_]{name} = ''
- unless exists $expect->{details}[$_]{name};
- $expect->{details}[$_]{reason} = ''
- unless exists $expect->{details}[$_]{reason};
- }
-
- my $test_path = File::Spec->catfile($SAMPLE_TESTS, $test);
- my $strap = Test::Harness::Straps->new;
- my %results = $strap->analyze_file($test_path);
-
- is_deeply($results{details}, $expect->{details}, "$test details" );
-
- delete $expect->{details};
- delete $results{details};
-
- SKIP: {
- skip '$? unreliable in MacPerl', 2 if $IsMacOS;
-
- # We can only check if it's zero or non-zero.
- is( !!$results{'wait'}, !!$expect->{'wait'}, 'wait status' );
- delete $results{'wait'};
- delete $expect->{'wait'};
-
- # Have to check the exit status seperately so we can skip it
- # in MacPerl.
- is( $results{'exit'}, $expect->{'exit'} );
- delete $results{'exit'};
- delete $expect->{'exit'};
- }
-
- is_deeply(\%results, $expect, " the rest $test" );
-}
-
-
-my $strap = Test::Harness::Straps->new;
-ok( !$strap->analyze_file('I_dont_exist') );
-is( $strap->{error}, "I_dont_exist does not exist" );
diff --git a/gnu/usr.bin/perl/lib/Test/Harness/t/strap.t b/gnu/usr.bin/perl/lib/Test/Harness/t/strap.t
deleted file mode 100644
index 26af9f30fb7..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Harness/t/strap.t
+++ /dev/null
@@ -1,224 +0,0 @@
-#!/usr/bin/perl -Tw
-
-BEGIN {
- if( $ENV{PERL_CORE} ) {
- chdir 't';
- @INC = ('../lib', 'lib');
- }
- else {
- unshift @INC, 't/lib';
- }
-}
-
-use strict;
-
-use Test::More tests => 146;
-
-
-use_ok('Test::Harness::Straps');
-
-my $strap = Test::Harness::Straps->new;
-ok( defined $strap && $strap->isa("Test::Harness::Straps"), 'new()' );
-
-
-### Testing _is_comment()
-
-my $comment;
-ok( !$strap->_is_comment("foo", \$comment), '_is_comment(), not a comment' );
-ok( !defined $comment, ' no comment set' );
-
-ok( !$strap->_is_comment("f # oo", \$comment), ' not a comment with #' );
-ok( !defined $comment, ' no comment set' );
-
-my %comments = (
- "# stuff and things # and stuff" =>
- ' stuff and things # and stuff',
- " # more things " => ' more things ',
- "#" => '',
- );
-
-while( my($line, $line_comment) = each %comments ) {
- my $strap = Test::Harness::Straps->new;
-
- my $name = substr($line, 0, 20);
- ok( $strap->_is_comment($line, \$comment), " comment '$name'" );
- is( $comment, $line_comment, ' right comment set' );
-}
-
-
-
-### Testing _is_header()
-
-my @not_headers = (' 1..2',
- '1..M',
- '1..-1',
- '2..2',
- '1..a',
- '',
- );
-
-foreach my $unheader (@not_headers) {
- my $strap = Test::Harness::Straps->new;
-
- ok( !$strap->_is_header($unheader),
- "_is_header(), not a header '$unheader'" );
-
- ok( (!grep { exists $strap->{$_} } qw(max todo skip_all)),
- " max, todo and skip_all are not set" );
-}
-
-
-my @attribs = qw(max skip_all todo);
-my %headers = (
- '1..2' => { max => 2 },
- '1..1' => { max => 1 },
- '1..0' => { max => 0 },
- '1..0 # Skipped: no leverage found' => { max => 0,
- skip_all => 'no leverage found',
- },
- '1..4 # Skipped: no leverage found' => { max => 4,
- skip_all => 'no leverage found',
- },
- '1..0 # skip skip skip because' => { max => 0,
- skip_all => 'skip skip because',
- },
- '1..10 todo 2 4 10' => { max => 10,
- 'todo' => { 2 => 1,
- 4 => 1,
- 10 => 1,
- },
- },
- '1..10 todo' => { max => 10 },
- '1..192 todo 4 2 13 192 # Skip skip skip because' =>
- { max => 192,
- 'todo' => { 4 => 1,
- 2 => 1,
- 13 => 1,
- 192 => 1,
- },
- skip_all => 'skip skip because'
- }
-);
-
-while( my($header, $expect) = each %headers ) {
- my $strap = Test::Harness::Straps->new;
-
- ok( $strap->_is_header($header), "_is_header() is a header '$header'" );
-
- is( $strap->{skip_all}, $expect->{skip_all}, ' skip_all set right' )
- if defined $expect->{skip_all};
-
- ok( eq_set( [map $strap->{$_}, grep defined $strap->{$_}, @attribs],
- [map $expect->{$_}, grep defined $expect->{$_}, @attribs] ),
- ' the right attributes are there' );
-}
-
-
-
-### Testing _is_test()
-
-my %tests = (
- 'ok' => { 'ok' => 1 },
- 'not ok' => { 'ok' => 0 },
-
- 'ok 1' => { 'ok' => 1, number => 1 },
- 'not ok 1' => { 'ok' => 0, number => 1 },
-
- 'ok 2938' => { 'ok' => 1, number => 2938 },
-
- 'ok 1066 - and all that' => { 'ok' => 1,
- number => 1066,
- name => "- and all that" },
- 'not ok 42 - universal constant' =>
- { 'ok' => 0,
- number => 42,
- name => '- universal constant',
- },
- 'not ok 23 # TODO world peace' => { 'ok' => 0,
- number => 23,
- type => 'todo',
- reason => 'world peace'
- },
- 'ok 11 - have life # TODO get a life' =>
- { 'ok' => 1,
- number => 11,
- name => '- have life',
- type => 'todo',
- reason => 'get a life'
- },
- 'not ok # TODO' => { 'ok' => 0,
- type => 'todo',
- reason => ''
- },
- 'ok # skip' => { 'ok' => 1,
- type => 'skip',
- },
- 'not ok 11 - this is \# all the name # skip this is not'
- => { 'ok' => 0,
- number => 11,
- name => '- this is \# all the name',
- type => 'skip',
- reason => 'this is not'
- },
- "ok 42 - _is_header() is a header '1..192 todo 4 2 13 192 \\# Skip skip skip because"
- => { 'ok' => 1,
- number => 42,
- name => "- _is_header() is a header '1..192 todo 4 2 13 192 \\# Skip skip skip because",
- },
- );
-
-while( my($line, $expect) = each %tests ) {
- my %test;
- ok( $strap->_is_test($line, \%test), "_is_test() spots '$line'" );
-
- foreach my $type (qw(ok number name type reason)) {
- cmp_ok( $test{$type}, 'eq', $expect->{$type}, " $type" );
- }
-}
-
-my @untests = (
- ' ok',
- 'not',
- 'okay 23',
- );
-foreach my $line (@untests) {
- my $strap = Test::Harness::Straps->new;
- my %test = ();
- ok( !$strap->_is_test($line, \%test), "_is_test() disregards '$line'" );
-
- # is( keys %test, 0 ) won't work in 5.004 because it's undef.
- ok( !keys %test, ' and produces no test info' );
-}
-
-
-### Test _is_bail_out()
-
-my %bails = (
- 'Bail out!' => undef,
- 'Bail out! Wing on fire.' => 'Wing on fire.',
- 'BAIL OUT!' => undef,
- 'bail out! - Out of coffee' => '- Out of coffee',
- );
-
-while( my($line, $expect) = each %bails ) {
- my $strap = Test::Harness::Straps->new;
- my $reason;
- ok( $strap->_is_bail_out($line, \$reason), "_is_bail_out() spots '$line'");
- is( $reason, $expect, ' with the right reason' );
-}
-
-my @unbails = (
- ' Bail out!',
- 'BAIL OUT',
- 'frobnitz',
- 'ok 23 - BAIL OUT!',
- );
-
-foreach my $line (@unbails) {
- my $strap = Test::Harness::Straps->new;
- my $reason;
-
- ok( !$strap->_is_bail_out($line, \$reason),
- "_is_bail_out() ignores '$line'" );
- is( $reason, undef, ' and gives no reason' );
-}
diff --git a/gnu/usr.bin/perl/lib/Test/Harness/t/test-harness.t b/gnu/usr.bin/perl/lib/Test/Harness/t/test-harness.t
deleted file mode 100644
index e9f99c8a960..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Harness/t/test-harness.t
+++ /dev/null
@@ -1,479 +0,0 @@
-#!/usr/bin/perl -w
-
-BEGIN {
- if( $ENV{PERL_CORE} ) {
- chdir 't';
- @INC = ('../lib', 'lib');
- }
- else {
- unshift @INC, 't/lib';
- }
-}
-
-use strict;
-use File::Spec;
-
-my $Curdir = File::Spec->curdir;
-my $SAMPLE_TESTS = $ENV{PERL_CORE}
- ? File::Spec->catdir($Curdir, 'lib', 'sample-tests')
- : File::Spec->catdir($Curdir, 't', 'sample-tests');
-
-
-# For shutting up Test::Harness.
-# Has to work on 5.004 which doesn't have Tie::StdHandle.
-package My::Dev::Null;
-
-sub WRITE {}
-sub PRINT {}
-sub PRINTF {}
-sub TIEHANDLE {
- my $class = shift;
- my $fh = do { local *HANDLE; \*HANDLE };
- return bless $fh, $class;
-}
-sub READ {}
-sub READLINE {}
-sub GETC {}
-
-
-package main;
-
-use Test::More;
-
-my $IsMacOS = $^O eq 'MacOS';
-my $IsVMS = $^O eq 'VMS';
-
-# VMS uses native, not POSIX, exit codes.
-my $die_estat = $IsVMS ? 44 : $IsMacOS ? 0 : 1;
-
-my %samples = (
- simple => {
- total => {
- bonus => 0,
- max => 5,
- 'ok' => 5,
- files => 1,
- bad => 0,
- good => 1,
- tests => 1,
- sub_skipped=> 0,
- 'todo' => 0,
- skipped => 0,
- },
- failed => { },
- all_ok => 1,
- },
- simple_fail => {
- total => {
- bonus => 0,
- max => 5,
- 'ok' => 3,
- files => 1,
- bad => 1,
- good => 0,
- tests => 1,
- sub_skipped => 0,
- 'todo' => 0,
- skipped => 0,
- },
- failed => {
- canon => '2 5',
- },
- all_ok => 0,
- },
- descriptive => {
- total => {
- bonus => 0,
- max => 5,
- 'ok' => 5,
- files => 1,
- bad => 0,
- good => 1,
- tests => 1,
- sub_skipped=> 0,
- 'todo' => 0,
- skipped => 0,
- },
- failed => { },
- all_ok => 1,
- },
- no_nums => {
- total => {
- bonus => 0,
- max => 5,
- 'ok' => 4,
- files => 1,
- bad => 1,
- good => 0,
- tests => 1,
- sub_skipped=> 0,
- 'todo' => 0,
- skipped => 0,
- },
- failed => {
- canon => '3',
- },
- all_ok => 0,
- },
- 'todo' => {
- total => {
- bonus => 1,
- max => 5,
- 'ok' => 5,
- files => 1,
- bad => 0,
- good => 1,
- tests => 1,
- sub_skipped=> 0,
- 'todo' => 2,
- skipped => 0,
- },
- failed => { },
- all_ok => 1,
- },
- todo_inline => {
- total => {
- bonus => 1,
- max => 3,
- 'ok' => 3,
- files => 1,
- bad => 0,
- good => 1,
- tests => 1,
- sub_skipped => 0,
- 'todo' => 2,
- skipped => 0,
- },
- failed => { },
- all_ok => 1,
- },
- 'skip' => {
- total => {
- bonus => 0,
- max => 5,
- 'ok' => 5,
- files => 1,
- bad => 0,
- good => 1,
- tests => 1,
- sub_skipped=> 1,
- 'todo' => 0,
- skipped => 0,
- },
- failed => { },
- all_ok => 1,
- },
- 'skip_nomsg' => {
- total => {
- bonus => 0,
- max => 1,
- 'ok' => 1,
- files => 1,
- bad => 0,
- good => 1,
- tests => 1,
- sub_skipped=> 1,
- 'todo' => 0,
- skipped => 0,
- },
- failed => { },
- all_ok => 1,
- },
- bailout => 0,
- combined => {
- total => {
- bonus => 1,
- max => 10,
- 'ok' => 8,
- files => 1,
- bad => 1,
- good => 0,
- tests => 1,
- sub_skipped=> 1,
- 'todo' => 2,
- skipped => 0
- },
- failed => {
- canon => '3 9',
- },
- all_ok => 0,
- },
- duplicates => {
- total => {
- bonus => 0,
- max => 10,
- 'ok' => 11,
- files => 1,
- bad => 1,
- good => 0,
- tests => 1,
- sub_skipped=> 0,
- 'todo' => 0,
- skipped => 0,
- },
- failed => {
- canon => '??',
- },
- all_ok => 0,
- },
- head_end => {
- total => {
- bonus => 0,
- max => 4,
- 'ok' => 4,
- files => 1,
- bad => 0,
- good => 1,
- tests => 1,
- sub_skipped=> 0,
- 'todo' => 0,
- skipped => 0,
- },
- failed => { },
- all_ok => 1,
- },
- head_fail => {
- total => {
- bonus => 0,
- max => 4,
- 'ok' => 3,
- files => 1,
- bad => 1,
- good => 0,
- tests => 1,
- sub_skipped=> 0,
- 'todo' => 0,
- skipped => 0,
- },
- failed => {
- canon => '2',
- },
- all_ok => 0,
- },
- skipall => {
- total => {
- bonus => 0,
- max => 0,
- 'ok' => 0,
- files => 1,
- bad => 0,
- good => 1,
- tests => 1,
- sub_skipped=> 0,
- 'todo' => 0,
- skipped => 1,
- },
- failed => { },
- all_ok => 1,
- },
- skipall_nomsg => {
- total => {
- bonus => 0,
- max => 0,
- 'ok' => 0,
- files => 1,
- bad => 0,
- good => 1,
- tests => 1,
- sub_skipped=> 0,
- 'todo' => 0,
- skipped => 1,
- },
- failed => { },
- all_ok => 1,
- },
- with_comments => {
- total => {
- bonus => 2,
- max => 5,
- 'ok' => 5,
- files => 1,
- bad => 0,
- good => 1,
- tests => 1,
- sub_skipped=> 0,
- 'todo' => 4,
- skipped => 0,
- },
- failed => { },
- all_ok => 1,
- },
- taint => {
- total => {
- bonus => 0,
- max => 1,
- 'ok' => 1,
- files => 1,
- bad => 0,
- good => 1,
- tests => 1,
- sub_skipped=> 0,
- 'todo' => 0,
- skipped => 0,
- },
- failed => { },
- all_ok => 1,
- },
-
- 'die' => {
- total => {
- bonus => 0,
- max => 0,
- 'ok' => 0,
- files => 1,
- bad => 1,
- good => 0,
- tests => 1,
- sub_skipped=> 0,
- 'todo' => 0,
- skipped => 0,
- },
- failed => {
- estat => $die_estat,
- max => '??',
- failed => '??',
- canon => '??',
- },
- all_ok => 0,
- },
-
- die_head_end => {
- total => {
- bonus => 0,
- max => 0,
- 'ok' => 4,
- files => 1,
- bad => 1,
- good => 0,
- tests => 1,
- sub_skipped=> 0,
- 'todo' => 0,
- skipped => 0,
- },
- failed => {
- estat => $die_estat,
- max => '??',
- failed => '??',
- canon => '??',
- },
- all_ok => 0,
- },
-
- die_last_minute => {
- total => {
- bonus => 0,
- max => 4,
- 'ok' => 4,
- files => 1,
- bad => 1,
- good => 0,
- tests => 1,
- sub_skipped=> 0,
- 'todo' => 0,
- skipped => 0,
- },
- failed => {
- estat => $die_estat,
- max => 4,
- failed => 0,
- canon => '??',
- },
- all_ok => 0,
- },
- bignum => {
- total => {
- bonus => 0,
- max => 2,
- 'ok' => 4,
- files => 1,
- bad => 1,
- good => 0,
- tests => 1,
- sub_skipped=> 0,
- 'todo' => 0,
- skipped => 0,
- },
- failed => {
- canon => '??',
- },
- all_ok => 0,
- },
- 'shbang_misparse' => {
- total => {
- bonus => 0,
- max => 2,
- 'ok' => 2,
- files => 1,
- bad => 0,
- good => 1,
- tests => 1,
- sub_skipped=> 0,
- 'todo' => 0,
- skipped => 0,
- },
- failed => { },
- all_ok => 1,
- },
- );
-
-plan tests => (keys(%samples) * 8) + 1;
-
-use Test::Harness;
-use_ok('Test::Harness');
-
-
-tie *NULL, 'My::Dev::Null' or die $!;
-
-while (my($test, $expect) = each %samples) {
- # _run_all_tests() runs the tests but skips the formatting.
- my($totals, $failed);
- my $warning = '';
- my $test_path = File::Spec->catfile($SAMPLE_TESTS, $test);
-
- eval {
- select NULL; # _run_all_tests() isn't as quiet as it should be.
- local $SIG{__WARN__} = sub { $warning .= join '', @_; };
- ($totals, $failed) =
- Test::Harness::_run_all_tests($test_path);
- };
- select STDOUT;
-
- # $? is unreliable in MacPerl, so we'll simply fudge it.
- $failed->{estat} = $die_estat if $IsMacOS and $failed;
-
- SKIP: {
- skip "special tests for bailout", 1 unless $test eq 'bailout';
- like( $@, '/Further testing stopped: GERONI/i' );
- }
-
- SKIP: {
- skip "don't apply to a bailout", 5 if $test eq 'bailout';
- is( $@, '' );
- is( Test::Harness::_all_ok($totals), $expect->{all_ok},
- "$test - all ok" );
- ok( defined $expect->{total}, "$test - has total" );
- is_deeply( {map { $_=>$totals->{$_} } keys %{$expect->{total}}},
- $expect->{total},
- "$test - totals" );
- is_deeply( {map { $_=>$failed->{$test_path}{$_} }
- keys %{$expect->{failed}}},
- $expect->{failed},
- "$test - failed" );
- }
-
- SKIP: {
- skip "special tests for bignum", 1 unless $test eq 'bignum';
- is( $warning, <<WARN );
-Enormous test number seen [test 100001]
-Can't detailize, too big.
-Enormous test number seen [test 136211425]
-Can't detailize, too big.
-WARN
-
- }
-
- SKIP: {
- skip "bignum has known warnings", 1 if $test eq 'bignum';
- is( $warning, '' );
- }
-}
diff --git a/gnu/usr.bin/perl/lib/Test/Harness/t/version.t b/gnu/usr.bin/perl/lib/Test/Harness/t/version.t
deleted file mode 100755
index c67bcedf27c..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Harness/t/version.t
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/usr/bin/perl -Tw
-
-BEGIN {
- if( $ENV{PERL_CORE} ) {
- chdir 't';
- @INC = ('../lib', 'lib');
- }
- else {
- unshift @INC, 't/lib';
- }
-}
-
-use strict;
-
-use Test::More tests => 3;
-
-BEGIN {
- use_ok('Test::Harness');
-}
-
-my $ver = $ENV{HARNESS_VERSION} or die "HARNESS_VERSION not set";
-like( $ver, qr/^2.\d\d(_\d\d)?$/, "Version is proper format" );
-is( $ver, $Test::Harness::VERSION );
diff --git a/gnu/usr.bin/perl/lib/Test/More.pm b/gnu/usr.bin/perl/lib/Test/More.pm
index 71611b88e89..aaf6d8721bb 100644
--- a/gnu/usr.bin/perl/lib/Test/More.pm
+++ b/gnu/usr.bin/perl/lib/Test/More.pm
@@ -17,7 +17,7 @@ sub _carp {
return warn @_, " at $file line $line\n";
}
-our $VERSION = '0.86';
+our $VERSION = '0.92';
$VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval)
use Test::Builder::Module;
@@ -30,6 +30,7 @@ our @EXPORT = qw(ok use_ok require_ok
eq_array eq_hash eq_set
$TODO
plan
+ done_testing
can_ok isa_ok new_ok
diag note explain
BAIL_OUT
@@ -43,9 +44,9 @@ Test::More - yet another framework for writing test scripts
use Test::More tests => 23;
# or
- use Test::More qw(no_plan);
- # or
use Test::More skip_all => $reason;
+ # or
+ use Test::More; # see done_testing()
BEGIN { use_ok( 'Some::Module' ); }
require_ok( 'Some::Module' );
@@ -95,7 +96,7 @@ Test::More - yet another framework for writing test scripts
=head1 DESCRIPTION
B<STOP!> If you're just getting started writing tests, have a look at
-Test::Simple first. This is a drop in replacement for Test::Simple
+L<Test::Simple> first. This is a drop in replacement for Test::Simple
which you can switch to once you get the hang of basic testing.
The purpose of this module is to provide a wide range of testing
@@ -115,14 +116,19 @@ The preferred way to do this is to declare a plan when you C<use Test::More>.
use Test::More tests => 23;
-There are rare cases when you will not know beforehand how many tests
-your script is going to run. In this case, you can declare that you
-have no plan. (Try to avoid using this as it weakens your test.)
+There are cases when you will not know beforehand how many tests your
+script is going to run. In this case, you can declare your tests at
+the end.
+
+ use Test::More;
+
+ ... run your tests ...
- use Test::More qw(no_plan);
+ done_testing( $number_of_tests_run );
-B<NOTE>: using no_plan requires a Test::Harness upgrade else it will
-think everything has failed. See L<CAVEATS and NOTES>).
+Sometimes you really don't know how many tests were run, or it's too
+difficult to calculate. In which case you can leave off
+$number_of_tests_run.
In some cases, you'll want to completely skip an entire testing script.
@@ -188,6 +194,32 @@ sub import_extra {
return;
}
+=over 4
+
+=item B<done_testing>
+
+ done_testing();
+ done_testing($number_of_tests);
+
+If you don't know how many tests you're going to run, you can issue
+the plan when you're done running tests.
+
+$number_of_tests is the same as plan(), it's the number of tests you
+expected to run. You can omit this, in which case the number of tests
+you ran doesn't matter, just the fact that your tests ran to
+conclusion.
+
+This is safer than and replaces the "no_plan" plan.
+
+=back
+
+=cut
+
+sub done_testing {
+ my $tb = Test::More->builder;
+ $tb->done_testing(@_);
+}
+
=head2 Test names
By convention, each test is assigned a number in order. This is
@@ -318,6 +350,17 @@ In these cases, use ok().
ok( exists $brooklyn{tree}, 'A tree grows in Brooklyn' );
+A simple call to isnt() usually does not provide a strong test but there
+are cases when you cannot say much more about a value than that it is
+different from some other value:
+
+ new_ok $obj, "Foo";
+
+ my $clone = $obj->clone;
+ isa_ok $obj, "Foo", "Foo->clone";
+
+ isnt $obj, $clone, "clone() produces a different object";
+
For those grammatical pedants out there, there's an C<isn't()>
function which is an alias of isnt().
@@ -419,6 +462,12 @@ is()'s use of C<eq> will interfere:
cmp_ok( $big_hairy_number, '==', $another_big_hairy_number );
+It's especially useful when comparing greater-than or smaller-than
+relation between values:
+
+ cmp_ok( $some_value, '<=', $upper_limit );
+
+
=cut
sub cmp_ok($$$;$) {
@@ -490,8 +539,9 @@ sub can_ok ($@) {
=item B<isa_ok>
- isa_ok($object, $class, $object_name);
- isa_ok($ref, $type, $ref_name);
+ isa_ok($object, $class, $object_name);
+ isa_ok($subclass, $class, $object_name);
+ isa_ok($ref, $type, $ref_name);
Checks to see if the given C<< $object->isa($class) >>. Also checks to make
sure the object was defined in the first place. Handy for this sort
@@ -507,6 +557,10 @@ where you'd otherwise have to write
to safeguard against your test script blowing up.
+You can also test a class, to make sure that it has the right ancestor:
+
+ isa_ok( 'Vole', 'Rodent' );
+
It works on references, too:
isa_ok( $array_ref, 'ARRAY' );
@@ -522,39 +576,46 @@ sub isa_ok ($$;$) {
my $tb = Test::More->builder;
my $diag;
- $obj_name = 'The object' unless defined $obj_name;
- my $name = "$obj_name isa $class";
+
if( !defined $object ) {
+ $obj_name = 'The thing' unless defined $obj_name;
$diag = "$obj_name isn't defined";
}
- elsif( !ref $object ) {
- $diag = "$obj_name isn't a reference";
- }
else {
+ my $whatami = ref $object ? 'object' : 'class';
# We can't use UNIVERSAL::isa because we want to honor isa() overrides
my( $rslt, $error ) = $tb->_try( sub { $object->isa($class) } );
if($error) {
if( $error =~ /^Can't call method "isa" on unblessed reference/ ) {
# Its an unblessed reference
+ $obj_name = 'The reference' unless defined $obj_name;
if( !UNIVERSAL::isa( $object, $class ) ) {
my $ref = ref $object;
$diag = "$obj_name isn't a '$class' it's a '$ref'";
}
}
+ elsif( $error =~ /Can't call method "isa" without a package/ ) {
+ # It's something that can't even be a class
+ $diag = "$obj_name isn't a class or reference";
+ }
else {
die <<WHOA;
-WHOA! I tried to call ->isa on your object and got some weird error.
+WHOA! I tried to call ->isa on your $whatami and got some weird error.
Here's the error.
$error
WHOA
}
}
- elsif( !$rslt ) {
- my $ref = ref $object;
- $diag = "$obj_name isn't a '$class' it's a '$ref'";
+ else {
+ $obj_name = "The $whatami" unless defined $obj_name;
+ if( !$rslt ) {
+ my $ref = ref $object;
+ $diag = "$obj_name isn't a '$class' it's a '$ref'";
+ }
}
}
+ my $name = "$obj_name isa $class";
my $ok;
if($diag) {
$ok = $tb->ok( 0, $name );
@@ -828,11 +889,11 @@ is_deeply() compares the dereferenced values of references, the
references themselves (except for their type) are ignored. This means
aspects such as blessing and ties are not considered "different".
-is_deeply() current has very limited handling of function reference
+is_deeply() currently has very limited handling of function reference
and globs. It merely checks if they have the same referent. This may
improve in the future.
-Test::Differences and Test::Deep provide more in-depth functionality
+L<Test::Differences> and L<Test::Deep> provide more in-depth functionality
along these lines.
=cut
@@ -1010,7 +1071,7 @@ sub note {
my @dump = explain @diagnostic_message;
Will dump the contents of any references in a human readable format.
-Usually you want to pass this into C<note> or C<dump>.
+Usually you want to pass this into C<note> or C<diag>.
Handy for things like...
@@ -1227,6 +1288,8 @@ available such as a database connection failing.
The test will exit with 255.
+For even better control look at L<Test::Most>.
+
=cut
sub BAIL_OUT {
@@ -1324,6 +1387,10 @@ sub _deep_check {
if( defined $e1 xor defined $e2 ) {
$ok = 0;
}
+ elsif( !defined $e1 and !defined $e2 ) {
+ # Shortcut if they're both defined.
+ $ok = 1;
+ }
elsif( _dne($e1) xor _dne($e2) ) {
$ok = 0;
}
@@ -1450,7 +1517,7 @@ level. The following is an example of a comparison which might not work:
eq_set([\1, \2], [\2, \1]);
-Test::Deep contains much better set comparison functions.
+L<Test::Deep> contains much better set comparison functions.
=cut
@@ -1534,6 +1601,24 @@ B<NOTE> This behavior may go away in future versions.
Test::More works with Perls as old as 5.6.0.
+=item utf8 / "Wide character in print"
+
+If you use utf8 or other non-ASCII characters with Test::More you
+might get a "Wide character in print" warning. Using C<binmode
+STDOUT, ":utf8"> will not fix it. Test::Builder (which powers
+Test::More) duplicates STDOUT and STDERR. So any changes to them,
+including changing their output disciplines, will not be seem by
+Test::More.
+
+The work around is to change the filehandles used by Test::Builder
+directly.
+
+ my $builder = Test::More->builder;
+ binmode $builder->output, ":utf8";
+ binmode $builder->failure_output, ":utf8";
+ binmode $builder->todo_output, ":utf8";
+
+
=item Overloaded objects
String overloaded objects are compared B<as strings> (or in cmp_ok()'s
@@ -1545,7 +1630,7 @@ difference. This is good.
However, it does mean that functions like is_deeply() cannot be used to
test the internals of string overloaded objects. In this case I would
-suggest Test::Deep which contains more flexible testing functions for
+suggest L<Test::Deep> which contains more flexible testing functions for
complex data structures.
@@ -1567,11 +1652,11 @@ This may cause problems:
=item Test::Harness upgrade
-no_plan and todo depend on new Test::Harness features and fixes. If
-you're going to distribute tests that use no_plan or todo your
-end-users will have to upgrade Test::Harness to the latest one on
-CPAN. If you avoid no_plan and TODO tests, the stock Test::Harness
-will work fine.
+no_plan, todo and done_testing() depend on new Test::Harness features
+and fixes. If you're going to distribute tests that use no_plan or
+todo your end-users will have to upgrade Test::Harness to the latest
+one on CPAN. If you avoid no_plan and TODO tests, the stock
+Test::Harness will work fine.
Installing Test::More should also upgrade Test::Harness.
@@ -1632,6 +1717,12 @@ the perl-qa gang.
See F<http://rt.cpan.org> to report and view bugs.
+=head1 SOURCE
+
+The source code repository for Test::More can be found at
+F<http://github.com/schwern/test-more/>.
+
+
=head1 COPYRIGHT
Copyright 2001-2008 by Michael G Schwern E<lt>schwern@pobox.comE<gt>.
diff --git a/gnu/usr.bin/perl/lib/Test/Simple.pm b/gnu/usr.bin/perl/lib/Test/Simple.pm
index 319c7b23b39..48c72e27fcc 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple.pm
+++ b/gnu/usr.bin/perl/lib/Test/Simple.pm
@@ -4,7 +4,7 @@ use 5.004;
use strict;
-our $VERSION = '0.86';
+our $VERSION = '0.92';
$VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval)
use Test::Builder::Module;
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/00test_harness_check.t b/gnu/usr.bin/perl/lib/Test/Simple/t/00test_harness_check.t
index 99c626d9d9d..3ff4a13c639 100755
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/00test_harness_check.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/00test_harness_check.t
@@ -1,5 +1,4 @@
#!/usr/bin/perl -w
-# $Id: 00test_harness_check.t,v 1.2 2009/05/16 21:42:57 simon Exp $
# A test to make sure the new Test::Harness was installed properly.
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/BEGIN_require_ok.t b/gnu/usr.bin/perl/lib/Test/Simple/t/BEGIN_require_ok.t
index c8566ab4afa..733d0bb861c 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/BEGIN_require_ok.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/BEGIN_require_ok.t
@@ -1,5 +1,9 @@
#!/usr/bin/perl -w
-# $Id: BEGIN_require_ok.t,v 1.1 2009/05/16 21:42:57 simon Exp $
+
+# Fixed a problem with BEGIN { use_ok or require_ok } silently failing when there's no
+# plan set. [rt.cpan.org 28345] Thanks Adriano Ferreira and Yitzchak.
+
+use strict;
BEGIN {
if( $ENV{PERL_CORE} ) {
@@ -15,11 +19,9 @@ use Test::More;
my $result;
BEGIN {
- eval {
- require_ok("Wibble");
- };
- $result = $@;
+ $result = require_ok("strict");
}
-plan tests => 1;
-like $result, '/^You tried to run a test without a plan/';
+ok $result, "require_ok ran";
+
+done_testing(2);
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/BEGIN_use_ok.t b/gnu/usr.bin/perl/lib/Test/Simple/t/BEGIN_use_ok.t
index c339138a82c..476badf7a29 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/BEGIN_use_ok.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/BEGIN_use_ok.t
@@ -1,5 +1,4 @@
#!/usr/bin/perl -w
-# $Id: BEGIN_use_ok.t,v 1.1 2009/05/16 21:42:57 simon Exp $
# [rt.cpan.org 28345]
#
@@ -19,11 +18,9 @@ use Test::More;
my $result;
BEGIN {
- eval {
- use_ok("Wibble");
- };
- $result = $@;
+ $result = use_ok("strict");
}
-plan tests => 1;
-like $result, '/^You tried to run a test without a plan/';
+ok( $result, "use_ok() ran" );
+done_testing(2);
+
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/Builder.t b/gnu/usr.bin/perl/lib/Test/Simple/t/Builder.t
deleted file mode 100644
index a5bfd155a62..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/Builder.t
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/usr/bin/perl -w
-
-BEGIN {
- if( $ENV{PERL_CORE} ) {
- chdir 't';
- @INC = '../lib';
- }
-}
-
-use Test::Builder;
-my $Test = Test::Builder->new;
-
-$Test->plan( tests => 7 );
-
-my $default_lvl = $Test->level;
-$Test->level(0);
-
-$Test->ok( 1, 'compiled and new()' );
-$Test->ok( $default_lvl == 1, 'level()' );
-
-$Test->is_eq('foo', 'foo', 'is_eq');
-$Test->is_num('23.0', '23', 'is_num');
-
-$Test->is_num( $Test->current_test, 4, 'current_test() get' );
-
-my $test_num = $Test->current_test + 1;
-$Test->current_test( $test_num );
-print "ok $test_num - current_test() set\n";
-
-$Test->ok( 1, 'counter still good' );
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/Builder.t b/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/Builder.t
index 0320212d83f..a5bfd155a62 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/Builder.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/Builder.t
@@ -1,5 +1,4 @@
#!/usr/bin/perl -w
-# $Id: Builder.t,v 1.1 2009/05/16 21:42:57 simon Exp $
BEGIN {
if( $ENV{PERL_CORE} ) {
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/carp.t b/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/carp.t
index 4b9fd1e631f..e89eeebfb9d 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/carp.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/carp.t
@@ -1,5 +1,4 @@
#!/usr/bin/perl
-# $Id: carp.t,v 1.1 2009/05/16 21:42:57 simon Exp $
BEGIN {
if( $ENV{PERL_CORE} ) {
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/create.t b/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/create.t
index 3ecf08f8751..d584b309553 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/create.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/create.t
@@ -1,5 +1,4 @@
#!/usr/bin/perl -w
-# $Id: create.t,v 1.1 2009/05/16 21:42:57 simon Exp $
#!perl -w
@@ -13,8 +12,9 @@ BEGIN {
}
}
-use Test::More tests => 8;
+use Test::More tests => 7;
use Test::Builder;
+use Test::Builder::NoOutput;
my $more_tb = Test::More->builder;
isa_ok $more_tb, 'Test::Builder';
@@ -23,24 +23,18 @@ is $more_tb, Test::More->builder, 'create does not interfere with ->builder';
is $more_tb, Test::Builder->new, ' does not interfere with ->new';
{
- my $new_tb = Test::Builder->create;
+ my $new_tb = Test::Builder::NoOutput->create;
isa_ok $new_tb, 'Test::Builder';
isnt $more_tb, $new_tb, 'Test::Builder->create makes a new object';
- $new_tb->output("some_file");
- END { 1 while unlink "some_file" }
-
$new_tb->plan(tests => 1);
- $new_tb->ok(1);
-}
-
-pass("Changing output() of new TB doesn't interfere with singleton");
+ $new_tb->ok(1, "a test");
-ok open FILE, "some_file";
-is join("", <FILE>), <<OUT;
+ is $new_tb->read, <<'OUT';
1..1
-ok 1
+ok 1 - a test
OUT
+}
-close FILE;
+pass("Changing output() of new TB doesn't interfere with singleton");
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/curr_test.t b/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/curr_test.t
deleted file mode 100644
index bd7b76a1fd1..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/curr_test.t
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/usr/bin/perl -w
-# $Id: curr_test.t,v 1.1 2009/05/16 21:42:57 simon Exp $
-
-# Dave Rolsky found a bug where if current_test() is used and no
-# tests are run via Test::Builder it will blow up.
-
-use Test::Builder;
-$TB = Test::Builder->new;
-$TB->plan(tests => 2);
-print "ok 1\n";
-print "ok 2\n";
-$TB->current_test(2);
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/details.t b/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/details.t
index de05361fa51..05d4828b4d9 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/details.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/details.t
@@ -1,5 +1,4 @@
#!/usr/bin/perl -w
-# $Id: details.t,v 1.1 2009/05/16 21:42:57 simon Exp $
BEGIN {
if( $ENV{PERL_CORE} ) {
@@ -30,13 +29,11 @@ push @Expected_Details, { 'ok' => 1,
# Inline TODO tests will confuse pre 1.20 Test::Harness, so we
# should just avoid the problem and not print it out.
-my $out_fh = $Test->output;
-my $todo_fh = $Test->todo_output;
my $start_test = $Test->current_test + 1;
-require TieOut;
-tie *FH, 'TieOut';
-$Test->output(\*FH);
-$Test->todo_output(\*FH);
+
+my $output = '';
+$Test->output(\$output);
+$Test->todo_output(\$output);
SKIP: {
$Test->skip( 'just testing skip' );
@@ -69,8 +66,7 @@ push @Expected_Details, { 'ok' => 1,
};
for ($start_test..$Test->current_test) { print "ok $_\n" }
-$Test->output($out_fh);
-$Test->todo_output($todo_fh);
+$Test->reset_outputs;
$Test->is_num( scalar $Test->summary(), 4, 'summary' );
push @Expected_Details, { 'ok' => 1,
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/has_plan.t b/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/has_plan.t
index bd21c5fbb47..d0be86a97aa 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/has_plan.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/has_plan.t
@@ -1,5 +1,4 @@
#!/usr/bin/perl -w
-# $Id: has_plan.t,v 1.1 2009/05/16 21:42:57 simon Exp $
BEGIN {
if( $ENV{PERL_CORE} ) {
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/has_plan2.t b/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/has_plan2.t
index ee760f17172..e13ea4af944 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/has_plan2.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/has_plan2.t
@@ -1,5 +1,4 @@
#!/usr/bin/perl -w
-# $Id: has_plan2.t,v 1.1 2009/05/16 21:42:57 simon Exp $
BEGIN {
if( $ENV{PERL_CORE} ) {
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/is_fh.t b/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/is_fh.t
index 7c6dd2e5e1e..0eb3ec0b159 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/is_fh.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/is_fh.t
@@ -1,5 +1,4 @@
#!/usr/bin/perl -w
-# $Id: is_fh.t,v 1.1 2009/05/16 21:42:57 simon Exp $
BEGIN {
if( $ENV{PERL_CORE} ) {
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/maybe_regex.t b/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/maybe_regex.t
index 97c2afae392..d1927a56e5b 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/maybe_regex.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/maybe_regex.t
@@ -1,5 +1,4 @@
#!/usr/bin/perl -w
-# $Id: maybe_regex.t,v 1.1 2009/05/16 21:42:57 simon Exp $
BEGIN {
if( $ENV{PERL_CORE} ) {
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/no_diag.t b/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/no_diag.t
index 76684398a42..6fa538a82ea 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/no_diag.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/no_diag.t
@@ -1,5 +1,4 @@
#!/usr/bin/perl -w
-# $Id: no_diag.t,v 1.1 2009/05/16 21:42:57 simon Exp $
use Test::More 'no_diag', tests => 2;
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/no_ending.t b/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/no_ending.t
index 9f2623e6343..97e968e289e 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/no_ending.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/no_ending.t
@@ -1,4 +1,3 @@
-# $Id: no_ending.t,v 1.1 2009/05/16 21:42:57 simon Exp $
use Test::Builder;
BEGIN {
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/no_header.t b/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/no_header.t
index cc39315bb55..93e6bec34c7 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/no_header.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/no_header.t
@@ -1,4 +1,3 @@
-# $Id: no_header.t,v 1.1 2009/05/16 21:42:57 simon Exp $
BEGIN {
if( $ENV{PERL_CORE} ) {
chdir 't';
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/ok_obj.t b/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/ok_obj.t
index d0bcfb9897d..8678dbff8d9 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/ok_obj.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/ok_obj.t
@@ -1,5 +1,4 @@
#!/usr/bin/perl -w
-# $Id: ok_obj.t,v 1.1 2009/05/16 21:42:58 simon Exp $
# Testing to make sure Test::Builder doesn't accidentally store objects
# passed in as test arguments.
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/output.t b/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/output.t
index 41748e5f1f6..77e0e0bbb38 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/output.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/output.t
@@ -1,5 +1,6 @@
#!perl -w
-# $Id: output.t,v 1.1 2009/05/16 21:42:58 simon Exp $
+
+use strict;
BEGIN {
if( $ENV{PERL_CORE} ) {
@@ -12,76 +13,91 @@ BEGIN {
}
chdir 't';
+use Test::Builder;
-# Can't use Test.pm, that's a 5.005 thing.
-print "1..4\n";
-
-my $test_num = 1;
-# Utility testing functions.
-sub ok ($;$) {
- my($test, $name) = @_;
- my $ok = '';
- $ok .= "not " unless $test;
- $ok .= "ok $test_num";
- $ok .= " - $name" if defined $name;
- $ok .= "\n";
- print $ok;
- $test_num++;
+# The real Test::Builder
+my $Test = Test::Builder->new;
+$Test->plan( tests => 6 );
- return $test;
-}
-use TieOut;
-use Test::Builder;
-my $Test = Test::Builder->new();
+# The one we're going to test.
+my $tb = Test::Builder->create();
-my $result;
my $tmpfile = 'foo.tmp';
-my $out = $Test->output($tmpfile);
END { 1 while unlink($tmpfile) }
-ok( defined $out );
+# Test output to a file
+{
+ my $out = $tb->output($tmpfile);
+ $Test->ok( defined $out );
+
+ print $out "hi!\n";
+ close *$out;
+
+ undef $out;
+ open(IN, $tmpfile) or die $!;
+ chomp(my $line = <IN>);
+ close IN;
+
+ $Test->is_eq($line, 'hi!');
+}
+
+
+# Test output to a filehandle
+{
+ open(FOO, ">>$tmpfile") or die $!;
+ my $out = $tb->output(\*FOO);
+ my $old = select *$out;
+ print "Hello!\n";
+ close *$out;
+ undef $out;
+ select $old;
+ open(IN, $tmpfile) or die $!;
+ my @lines = <IN>;
+ close IN;
+
+ $Test->like($lines[1], qr/Hello!/);
+}
-print $out "hi!\n";
-close *$out;
-undef $out;
-open(IN, $tmpfile) or die $!;
-chomp(my $line = <IN>);
-close IN;
+# Test output to a scalar ref
+{
+ my $scalar = '';
+ my $out = $tb->output(\$scalar);
+
+ print $out "Hey hey hey!\n";
+ $Test->is_eq($scalar, "Hey hey hey!\n");
+}
-ok($line eq 'hi!');
-open(FOO, ">>$tmpfile") or die $!;
-$out = $Test->output(\*FOO);
-$old = select *$out;
-print "Hello!\n";
-close *$out;
-undef $out;
-select $old;
-open(IN, $tmpfile) or die $!;
-my @lines = <IN>;
-close IN;
+# Test we can output to the same scalar ref
+{
+ my $scalar = '';
+ my $out = $tb->output(\$scalar);
+ my $err = $tb->failure_output(\$scalar);
-ok($lines[1] =~ /Hello!/);
+ print $out "To output ";
+ print $err "and beyond!";
+ $Test->is_eq($scalar, "To output and beyond!", "One scalar, two filehandles");
+}
# Ensure stray newline in name escaping works.
-$out = tie *FAKEOUT, 'TieOut';
-$Test->output(\*FAKEOUT);
-$Test->exported_to(__PACKAGE__);
-$Test->no_ending(1);
-$Test->plan(tests => 5);
-
-$Test->ok(1, "ok");
-$Test->ok(1, "ok\n");
-$Test->ok(1, "ok, like\nok");
-$Test->skip("wibble\nmoof");
-$Test->todo_skip("todo\nskip\n");
-
-my $output = $out->read;
-ok( $output eq <<OUTPUT ) || print STDERR $output;
+{
+ my $fakeout = '';
+ my $out = $tb->output(\$fakeout);
+ $tb->exported_to(__PACKAGE__);
+ $tb->no_ending(1);
+ $tb->plan(tests => 5);
+
+ $tb->ok(1, "ok");
+ $tb->ok(1, "ok\n");
+ $tb->ok(1, "ok, like\nok");
+ $tb->skip("wibble\nmoof");
+ $tb->todo_skip("todo\nskip\n");
+
+ $Test->is_eq( $fakeout, <<OUTPUT ) || print STDERR $fakeout;
1..5
ok 1 - ok
ok 2 - ok
@@ -94,3 +110,4 @@ not ok 5 # TODO & SKIP todo
# skip
#
OUTPUT
+}
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/reset.t b/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/reset.t
index f2bc9970a98..6bff7fcf275 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/reset.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/reset.t
@@ -1,5 +1,4 @@
#!/usr/bin/perl -w
-# $Id: reset.t,v 1.1 2009/05/16 21:42:58 simon Exp $
# Test Test::Builder->reset;
@@ -16,25 +15,24 @@ chdir 't';
use Test::Builder;
-my $tb = Test::Builder->new;
+my $Test = Test::Builder->new;
+my $tb = Test::Builder->create;
+# We'll need this later to know the outputs were reset
my %Original_Output;
$Original_Output{$_} = $tb->$_ for qw(output failure_output todo_output);
+# Alter the state of Test::Builder as much as possible.
+my $output = '';
+$tb->output(\$output);
+$tb->failure_output(\$output);
+$tb->todo_output(\$output);
$tb->plan(tests => 14);
$tb->level(0);
-# Alter the state of Test::Builder as much as possible.
$tb->ok(1, "Running a test to alter TB's state");
-my $tmpfile = 'foo.tmp';
-
-$tb->output($tmpfile);
-$tb->failure_output($tmpfile);
-$tb->todo_output($tmpfile);
-END { 1 while unlink $tmpfile }
-
# This won't print since we just sent output off to oblivion.
$tb->ok(0, "And a failure for fun");
@@ -50,41 +48,26 @@ $tb->no_ending(1);
# Now reset it.
$tb->reset;
-my $test_num = 2; # since we already printed 1
-# Utility testing functions.
-sub ok ($;$) {
- my($test, $name) = @_;
- my $ok = '';
- $ok .= "not " unless $test;
- $ok .= "ok $test_num";
- $ok .= " - $name" if defined $name;
- $ok .= "\n";
- print $ok;
- $test_num++;
-
- return $test;
-}
-
-ok( !defined $tb->exported_to, 'exported_to' );
-ok( $tb->expected_tests == 0, 'expected_tests' );
-ok( $tb->level == 1, 'level' );
-ok( $tb->use_numbers == 1, 'use_numbers' );
-ok( $tb->no_header == 0, 'no_header' );
-ok( $tb->no_ending == 0, 'no_ending' );
-ok( fileno $tb->output == fileno $Original_Output{output},
- 'output' );
-ok( fileno $tb->failure_output == fileno $Original_Output{failure_output},
- 'failure_output' );
-ok( fileno $tb->todo_output == fileno $Original_Output{todo_output},
- 'todo_output' );
-ok( $tb->current_test == 0, 'current_test' );
-ok( $tb->summary == 0, 'summary' );
-ok( $tb->details == 0, 'details' );
-
-$tb->no_ending(1);
-$tb->no_header(1);
-$tb->plan(tests => 14);
-$tb->current_test(13);
+$Test->ok( !defined $tb->exported_to, 'exported_to' );
+$Test->is_eq( $tb->expected_tests, 0, 'expected_tests' );
+$Test->is_eq( $tb->level, 1, 'level' );
+$Test->is_eq( $tb->use_numbers, 1, 'use_numbers' );
+$Test->is_eq( $tb->no_header, 0, 'no_header' );
+$Test->is_eq( $tb->no_ending, 0, 'no_ending' );
+$Test->is_eq( $tb->current_test, 0, 'current_test' );
+$Test->is_eq( scalar $tb->summary, 0, 'summary' );
+$Test->is_eq( scalar $tb->details, 0, 'details' );
+$Test->is_eq( fileno $tb->output,
+ fileno $Original_Output{output}, 'output' );
+$Test->is_eq( fileno $tb->failure_output,
+ fileno $Original_Output{failure_output}, 'failure_output' );
+$Test->is_eq( fileno $tb->todo_output,
+ fileno $Original_Output{todo_output}, 'todo_output' );
+
+$tb->current_test(12);
$tb->level(0);
$tb->ok(1, 'final test to make sure output was reset');
+
+$Test->current_test(13);
+$Test->done_testing(13);
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/reset_outputs.t b/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/reset_outputs.t
deleted file mode 100644
index 0622fe09f43..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/reset_outputs.t
+++ /dev/null
@@ -1,36 +0,0 @@
-#!perl -w
-# $Id: reset_outputs.t,v 1.1 2009/05/16 21:42:58 simon Exp $
-
-BEGIN {
- if( $ENV{PERL_CORE} ) {
- chdir 't';
- @INC = ('../lib', 'lib');
- }
- else {
- unshift @INC, 't/lib';
- }
-}
-
-use Test::Builder;
-use Test::More 'no_plan';
-
-{
- my $tb = Test::Builder->create();
-
- # Store the original output filehandles and change them all.
- my %original_outputs;
-
- open my $fh, ">", "dummy_file.tmp";
- END { 1 while unlink "dummy_file.tmp"; }
- for my $method (qw(output failure_output todo_output)) {
- $original_outputs{$method} = $tb->$method();
- $tb->$method($fh);
- is $tb->$method(), $fh;
- }
-
- $tb->reset_outputs;
-
- for my $method (qw(output failure_output todo_output)) {
- is $tb->$method(), $original_outputs{$method}, "reset_outputs() resets $method";
- }
-}
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/try.t b/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/try.t
index 658c4ed7d67..eeb3bcb1ab4 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/try.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/Builder/try.t
@@ -1,5 +1,4 @@
#!perl -w
-# $Id: try.t,v 1.1 2009/05/16 21:42:58 simon Exp $
BEGIN {
if( $ENV{PERL_CORE} ) {
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/More.t b/gnu/usr.bin/perl/lib/Test/Simple/t/More.t
index 73d71d84ac0..21958cf2b61 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/More.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/More.t
@@ -1,5 +1,4 @@
#!perl -w
-# $Id$
BEGIN {
if( $ENV{PERL_CORE} ) {
@@ -9,7 +8,7 @@ BEGIN {
}
use lib 't/lib';
-use Test::More tests => 52;
+use Test::More tests => 53;
# Make sure we don't mess with $@ or $!. Test at bottom.
my $Err = "this should not be touched";
@@ -48,6 +47,11 @@ can_ok(bless({}, "Test::More"), qw(require_ok use_ok ok is isnt like skip
isa_ok(bless([], "Foo"), "Foo");
isa_ok([], 'ARRAY');
isa_ok(\42, 'SCALAR');
+{
+ local %Bar::;
+ local @Foo::ISA = 'Bar';
+ isa_ok( "Foo", "Bar" );
+}
# can_ok() & isa_ok should call can() & isa() on the given object, not
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/Tester/tbt_01basic.t b/gnu/usr.bin/perl/lib/Test/Simple/t/Tester/tbt_01basic.t
index 174a4498af8..769a1c47299 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/Tester/tbt_01basic.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/Tester/tbt_01basic.t
@@ -1,5 +1,4 @@
#!/usr/bin/perl
-# $Id: tbt_01basic.t,v 1.1 2009/05/16 21:42:58 simon Exp $
use Test::Builder::Tester tests => 9;
use Test::More;
@@ -23,7 +22,7 @@ ok(2,"two");
test_test("multiple tests");
test_out("not ok 1 - should fail");
-test_err("# Failed test ($0 at line 29)");
+test_err("# Failed test ($0 at line 28)");
test_err("# got: 'foo'");
test_err("# expected: 'bar'");
is("foo","bar","should fail");
@@ -47,7 +46,7 @@ test_test("testing failing on the same line with the same name");
test_out("not ok 1 - name # TODO Something");
-test_err("# Failed (TODO) test ($0 at line 53)");
+test_err("# Failed (TODO) test ($0 at line 52)");
TODO: {
local $TODO = "Something";
fail("name");
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/Tester/tbt_02fhrestore.t b/gnu/usr.bin/perl/lib/Test/Simple/t/Tester/tbt_02fhrestore.t
index 360730aef95..e37357171b8 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/Tester/tbt_02fhrestore.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/Tester/tbt_02fhrestore.t
@@ -1,5 +1,4 @@
#!/usr/bin/perl
-# $Id: tbt_02fhrestore.t,v 1.1 2009/05/16 21:42:58 simon Exp $
use Test::Builder::Tester tests => 4;
use Test::More;
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/Tester/tbt_03die.t b/gnu/usr.bin/perl/lib/Test/Simple/t/Tester/tbt_03die.t
index e9c29cfeb13..b9dba801eb4 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/Tester/tbt_03die.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/Tester/tbt_03die.t
@@ -1,5 +1,4 @@
#!/usr/bin/perl
-# $Id: tbt_03die.t,v 1.1 2009/05/16 21:42:58 simon Exp $
use Test::Builder::Tester tests => 1;
use Test::More;
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/Tester/tbt_04line_num.t b/gnu/usr.bin/perl/lib/Test/Simple/t/Tester/tbt_04line_num.t
index 8713ac4a30d..9e8365acbf2 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/Tester/tbt_04line_num.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/Tester/tbt_04line_num.t
@@ -1,9 +1,8 @@
#!/usr/bin/perl
-# $Id: tbt_04line_num.t,v 1.1 2009/05/16 21:42:58 simon Exp $
use Test::More tests => 3;
use Test::Builder::Tester;
-is(line_num(),7,"normal line num");
-is(line_num(-1),7,"line number minus one");
-is(line_num(+2),11,"line number plus two");
+is(line_num(),6,"normal line num");
+is(line_num(-1),6,"line number minus one");
+is(line_num(+2),10,"line number plus two");
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/Tester/tbt_05faildiag.t b/gnu/usr.bin/perl/lib/Test/Simple/t/Tester/tbt_05faildiag.t
index a4887c0b4eb..59ad721240a 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/Tester/tbt_05faildiag.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/Tester/tbt_05faildiag.t
@@ -1,5 +1,4 @@
#!/usr/bin/perl
-# $Id: tbt_05faildiag.t,v 1.1 2009/05/16 21:42:58 simon Exp $
use Test::Builder::Tester tests => 5;
use Test::More;
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/Tester/tbt_06errormess.t b/gnu/usr.bin/perl/lib/Test/Simple/t/Tester/tbt_06errormess.t
index f8f20bdd53b..d8d8a0feadb 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/Tester/tbt_06errormess.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/Tester/tbt_06errormess.t
@@ -1,5 +1,4 @@
#!/usr/bin/perl -w
-# $Id: tbt_06errormess.t,v 1.1 2009/05/16 21:42:58 simon Exp $
use Test::More tests => 8;
use Symbol;
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/Tester/tbt_07args.t b/gnu/usr.bin/perl/lib/Test/Simple/t/Tester/tbt_07args.t
index 2fa02fa7504..1b9393bdf49 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/Tester/tbt_07args.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/Tester/tbt_07args.t
@@ -1,5 +1,4 @@
#!/usr/bin/perl -w
-# $Id: tbt_07args.t,v 1.1 2009/05/16 21:42:58 simon Exp $
use Test::More tests => 18;
use Symbol;
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/bad_plan.t b/gnu/usr.bin/perl/lib/Test/Simple/t/bad_plan.t
index 1d4e50d6f0e..80e0e65bcaa 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/bad_plan.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/bad_plan.t
@@ -1,5 +1,4 @@
#!/usr/bin/perl -w
-# $Id$
BEGIN {
if( $ENV{PERL_CORE} ) {
@@ -8,32 +7,17 @@ BEGIN {
}
}
-my $test_num = 1;
-# Utility testing functions.
-sub ok ($;$) {
- my($test, $name) = @_;
- my $ok = '';
- $ok .= "not " unless $test;
- $ok .= "ok $test_num";
- $ok .= " - $name" if defined $name;
- $ok .= "\n";
- print $ok;
- $test_num++;
-
- return $test;
-}
-
-
use Test::Builder;
my $Test = Test::Builder->new;
+$Test->plan( tests => 2 );
+$Test->level(0);
-print "1..2\n";
+my $tb = Test::Builder->create;
-eval { $Test->plan(7); };
-ok( $@ =~ /^plan\(\) doesn't understand 7/, 'bad plan()' ) ||
+eval { $tb->plan(7); };
+$Test->like( $@, qr/^plan\(\) doesn't understand 7/, 'bad plan()' ) ||
print STDERR "# $@";
-eval { $Test->plan(wibble => 7); };
-ok( $@ =~ /^plan\(\) doesn't understand wibble 7/, 'bad plan()' ) ||
+eval { $tb->plan(wibble => 7); };
+$Test->like( $@, qr/^plan\(\) doesn't understand wibble 7/, 'bad plan()' ) ||
print STDERR "# $@";
-
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/bail_out.t b/gnu/usr.bin/perl/lib/Test/Simple/t/bail_out.t
index 8a281ce6c02..5cdc1f9969f 100755
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/bail_out.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/bail_out.t
@@ -1,5 +1,4 @@
#!/usr/bin/perl -w
-# $Id: bail_out.t,v 1.2 2009/05/16 21:42:57 simon Exp $
BEGIN {
if( $ENV{PERL_CORE} ) {
@@ -19,30 +18,22 @@ BEGIN {
use Test::Builder;
use Test::More;
-use TieOut;
-my $output = tie *FAKEOUT, 'TieOut';
+my $output;
my $TB = Test::More->builder;
-$TB->output(\*FAKEOUT);
+$TB->output(\$output);
my $Test = Test::Builder->create;
$Test->level(0);
-if( $] >= 5.005 ) {
- $Test->plan(tests => 3);
-}
-else {
- $Test->plan(skip_all =>
- 'CORE::GLOBAL::exit, introduced in 5.005, is needed for testing');
-}
-
+$Test->plan(tests => 3);
plan tests => 4;
BAIL_OUT("ROCKS FALL! EVERYONE DIES!");
-$Test->is_eq( $output->read, <<'OUT' );
+$Test->is_eq( $output, <<'OUT' );
1..4
Bail out! ROCKS FALL! EVERYONE DIES!
OUT
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/buffer.t b/gnu/usr.bin/perl/lib/Test/Simple/t/buffer.t
index 04e92b92051..6039e4a6f72 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/buffer.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/buffer.t
@@ -1,5 +1,4 @@
#!/usr/bin/perl
-# $Id$
BEGIN {
if( $ENV{PERL_CORE} ) {
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/carp.t b/gnu/usr.bin/perl/lib/Test/Simple/t/carp.t
deleted file mode 100644
index e89eeebfb9d..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/carp.t
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/usr/bin/perl
-
-BEGIN {
- if( $ENV{PERL_CORE} ) {
- chdir 't';
- @INC = '../lib';
- }
-}
-
-
-use Test::More tests => 3;
-use Test::Builder;
-
-my $tb = Test::Builder->create;
-sub foo { $tb->croak("foo") }
-sub bar { $tb->carp("bar") }
-
-eval { foo() };
-is $@, sprintf "foo at %s line %s.\n", $0, __LINE__ - 1;
-
-eval { $tb->croak("this") };
-is $@, sprintf "this at %s line %s.\n", $0, __LINE__ - 1;
-
-{
- my $warning = '';
- local $SIG{__WARN__} = sub {
- $warning .= join '', @_;
- };
-
- bar();
- is $warning, sprintf "bar at %s line %s.\n", $0, __LINE__ - 1;
-}
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/circular_data.t b/gnu/usr.bin/perl/lib/Test/Simple/t/circular_data.t
index aee3a4b4c0b..2fd819e1f4a 100755
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/circular_data.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/circular_data.t
@@ -1,5 +1,4 @@
#!/usr/bin/perl -w
-# $Id: circular_data.t,v 1.2 2009/05/16 21:42:57 simon Exp $
# Test is_deeply and friends with circular data structures [rt.cpan.org 7289]
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/cmp_ok.t b/gnu/usr.bin/perl/lib/Test/Simple/t/cmp_ok.t
index 031940e49c1..de1a7e634d9 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/cmp_ok.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/cmp_ok.t
@@ -1,5 +1,4 @@
#!/usr/bin/perl -w
-# $Id$
BEGIN {
if( $ENV{PERL_CORE} ) {
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/create.t b/gnu/usr.bin/perl/lib/Test/Simple/t/create.t
deleted file mode 100755
index 5600d6830a5..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/create.t
+++ /dev/null
@@ -1,45 +0,0 @@
-#!/usr/bin/perl -w
-
-#!perl -w
-
-BEGIN {
- if( $ENV{PERL_CORE} ) {
- chdir 't';
- @INC = ('../lib', 'lib');
- }
- else {
- unshift @INC, 't/lib';
- }
-}
-
-use Test::More tests => 8;
-use Test::Builder;
-
-my $more_tb = Test::More->builder;
-isa_ok $more_tb, 'Test::Builder';
-
-is $more_tb, Test::More->builder, 'create does not interfere with ->builder';
-is $more_tb, Test::Builder->new, ' does not interfere with ->new';
-
-{
- my $new_tb = Test::Builder->create;
-
- isa_ok $new_tb, 'Test::Builder';
- isnt $more_tb, $new_tb, 'Test::Builder->create makes a new object';
-
- $new_tb->output("some_file");
- END { 1 while unlink "some_file" }
-
- $new_tb->plan(tests => 1);
- $new_tb->ok(1);
-}
-
-pass("Changing output() of new TB doesn't interfere with singleton");
-
-ok open FILE, "some_file";
-is join("", <FILE>), <<OUT;
-1..1
-ok 1
-OUT
-
-close FILE;
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/curr_test.t b/gnu/usr.bin/perl/lib/Test/Simple/t/curr_test.t
deleted file mode 100644
index edd201c0e9d..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/curr_test.t
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/usr/bin/perl -w
-
-# Dave Rolsky found a bug where if current_test() is used and no
-# tests are run via Test::Builder it will blow up.
-
-use Test::Builder;
-$TB = Test::Builder->new;
-$TB->plan(tests => 2);
-print "ok 1\n";
-print "ok 2\n";
-$TB->current_test(2);
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/details.t b/gnu/usr.bin/perl/lib/Test/Simple/t/details.t
deleted file mode 100644
index 65dcf8d1544..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/details.t
+++ /dev/null
@@ -1,93 +0,0 @@
-#!/usr/bin/perl -w
-
-BEGIN {
- if( $ENV{PERL_CORE} ) {
- chdir 't';
- @INC = ('../lib', 'lib');
- }
- else {
- unshift @INC, 't/lib';
- }
-}
-
-use Test::More;
-use Test::Builder;
-my $Test = Test::Builder->new;
-
-$Test->plan( tests => 8 );
-$Test->level(0);
-
-my @Expected_Details;
-
-$Test->is_num( scalar $Test->summary(), 0, 'no tests yet, no summary' );
-push @Expected_Details, { 'ok' => 1,
- actual_ok => 1,
- name => 'no tests yet, no summary',
- type => '',
- reason => ''
- };
-
-# Inline TODO tests will confuse pre 1.20 Test::Harness, so we
-# should just avoid the problem and not print it out.
-my $out_fh = $Test->output;
-my $start_test = $Test->current_test + 1;
-require TieOut;
-tie *FH, 'TieOut';
-$Test->output(\*FH);
-
-SKIP: {
- $Test->skip( 'just testing skip' );
-}
-push @Expected_Details, { 'ok' => 1,
- actual_ok => 1,
- name => '',
- type => 'skip',
- reason => 'just testing skip',
- };
-
-TODO: {
- local $TODO = 'i need a todo';
- $Test->ok( 0, 'a test to todo!' );
-
- push @Expected_Details, { 'ok' => 1,
- actual_ok => 0,
- name => 'a test to todo!',
- type => 'todo',
- reason => 'i need a todo',
- };
-
- $Test->todo_skip( 'i need both' );
-}
-push @Expected_Details, { 'ok' => 1,
- actual_ok => 0,
- name => '',
- type => 'todo_skip',
- reason => 'i need both'
- };
-
-for ($start_test..$Test->current_test) { print "ok $_\n" }
-$Test->output($out_fh);
-
-$Test->is_num( scalar $Test->summary(), 4, 'summary' );
-push @Expected_Details, { 'ok' => 1,
- actual_ok => 1,
- name => 'summary',
- type => '',
- reason => '',
- };
-
-$Test->current_test(6);
-print "ok 6 - current_test incremented\n";
-push @Expected_Details, { 'ok' => 1,
- actual_ok => undef,
- name => undef,
- type => 'unknown',
- reason => 'incrementing test number',
- };
-
-my @details = $Test->details();
-$Test->is_num( scalar @details, 6,
- 'details() should return a list of all test details');
-
-$Test->level(1);
-is_deeply( \@details, \@Expected_Details );
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/diag.t b/gnu/usr.bin/perl/lib/Test/Simple/t/diag.t
index 91ef58f5884..f5cb437d544 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/diag.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/diag.t
@@ -1,5 +1,4 @@
#!perl -w
-# $Id$
BEGIN {
if( $ENV{PERL_CORE} ) {
@@ -25,27 +24,22 @@ BEGIN {
use strict;
+use Test::Builder::NoOutput;
use Test::More tests => 7;
-my $test = Test::Builder->create;
-
-# now make a filehandle where we can send data
-use TieOut;
-my $output = tie *FAKEOUT, 'TieOut';
-
+my $test = Test::Builder::NoOutput->create;
# Test diag() goes to todo_output() in a todo test.
{
$test->todo_start();
- $test->todo_output(\*FAKEOUT);
$test->diag("a single line");
- is( $output->read, <<'DIAG', 'diag() with todo_output set' );
+ is( $test->read('todo'), <<'DIAG', 'diag() with todo_output set' );
# a single line
DIAG
my $ret = $test->diag("multiple\n", "lines");
- is( $output->read, <<'DIAG', ' multi line' );
+ is( $test->read('todo'), <<'DIAG', ' multi line' );
# multiple
# lines
DIAG
@@ -54,25 +48,21 @@ DIAG
$test->todo_end();
}
-$test->reset_outputs();
-
# Test diagnostic formatting
-$test->failure_output(\*FAKEOUT);
{
$test->diag("# foo");
- is( $output->read, "# # foo\n", "diag() adds # even if there's one already" );
+ is( $test->read('err'), "# # foo\n", "diag() adds # even if there's one already" );
$test->diag("foo\n\nbar");
- is( $output->read, <<'DIAG', " blank lines get escaped" );
+ is( $test->read('err'), <<'DIAG', " blank lines get escaped" );
# foo
#
# bar
DIAG
-
$test->diag("foo\n\nbar\n\n");
- is( $output->read, <<'DIAG', " even at the end" );
+ is( $test->read('err'), <<'DIAG', " even at the end" );
# foo
#
# bar
@@ -81,10 +71,11 @@ DIAG
}
-# [rt.cpan.org 8392]
+# [rt.cpan.org 8392] diag(@list) emulates print
{
$test->diag(qw(one two));
-}
-is( $output->read, <<'DIAG' );
+
+ is( $test->read('err'), <<'DIAG' );
# onetwo
DIAG
+}
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/died.t b/gnu/usr.bin/perl/lib/Test/Simple/t/died.t
index d8f317ddd95..b4ee2fbbffd 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/died.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/died.t
@@ -1,5 +1,4 @@
#!perl -w
-# $Id: died.t,v 1.1 2009/05/16 21:42:57 simon Exp $
BEGIN {
if( $ENV{PERL_CORE} ) {
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/dont_overwrite_die_handler.t b/gnu/usr.bin/perl/lib/Test/Simple/t/dont_overwrite_die_handler.t
index 356a8470323..0657a06ca33 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/dont_overwrite_die_handler.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/dont_overwrite_die_handler.t
@@ -1,5 +1,4 @@
#!/usr/bin/perl -w
-# $Id: dont_overwrite_die_handler.t,v 1.1 2009/05/16 21:42:57 simon Exp $
BEGIN {
if( $ENV{PERL_CORE} ) {
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/eq_set.t b/gnu/usr.bin/perl/lib/Test/Simple/t/eq_set.t
index 75738c6081e..fbdc52db1fa 100755
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/eq_set.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/eq_set.t
@@ -1,5 +1,4 @@
#!perl -w
-# $Id: eq_set.t,v 1.2 2009/05/16 21:42:57 simon Exp $
BEGIN {
if( $ENV{PERL_CORE} ) {
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/exit.t b/gnu/usr.bin/perl/lib/Test/Simple/t/exit.t
index 6c6945ca212..95661eef072 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/exit.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/exit.t
@@ -1,5 +1,4 @@
#!/usr/bin/perl -w
-# $Id$
# Can't use Test.pm, that's a 5.005 thing.
package My::Test;
@@ -11,21 +10,6 @@ BEGIN {
}
}
-unless( eval { require File::Spec } ) {
- print "1..0 # Skip Need File::Spec to run this test\n";
- exit 0;
-}
-
-if( $^O eq 'VMS' && $] <= 5.00503 ) {
- print "1..0 # Skip test will hang on older VMS perls\n";
- exit 0;
-}
-
-if( $^O eq 'MacOS' ) {
- print "1..0 # Skip exit status broken on Mac OS\n";
- exit 0;
-}
-
require Test::Builder;
my $TB = Test::Builder->create();
$TB->level(0);
@@ -33,29 +17,21 @@ $TB->level(0);
package main;
-my $IsVMS = $^O eq 'VMS';
+use Cwd;
+use File::Spec;
-print "# Ahh! I see you're running VMS.\n" if $IsVMS;
+my $Orig_Dir = cwd;
-my %Tests = (
- # Everyone Else VMS
- 'success.plx' => [0, 0],
- 'one_fail.plx' => [1, 4],
- 'two_fail.plx' => [2, 4],
- 'five_fail.plx' => [5, 4],
- 'extras.plx' => [2, 4],
- 'too_few.plx' => [255, 4],
- 'too_few_fail.plx' => [2, 4],
- 'death.plx' => [255, 4],
- 'last_minute_death.plx' => [255, 4],
- 'pre_plan_death.plx' => ['not zero', 'not zero'],
- 'death_in_eval.plx' => [0, 0],
- 'require.plx' => [0, 0],
- 'death_with_handler.plx' => [255, 4],
- 'exit.plx' => [1, 4],
- );
+my $Perl = File::Spec->rel2abs($^X);
+if( $^O eq 'VMS' ) {
+ # VMS can't use its own $^X in a system call until almost 5.8
+ $Perl = "MCR $^X" if $] < 5.007003;
+
+ # Quiet noisy 'SYS$ABORT'
+ $Perl .= q{ -"I../lib"} if $ENV{PERL_CORE};
+ $Perl .= q{ -"Mvmsish=hushed"};
+}
-$TB->plan( tests => scalar keys(%Tests) );
eval { require POSIX; &POSIX::WEXITSTATUS(0) };
if( $@ ) {
@@ -65,34 +41,74 @@ else {
*exitstatus = sub { POSIX::WEXITSTATUS($_[0]) }
}
-my $Perl = File::Spec->rel2abs($^X);
-chdir 't';
-my $lib = File::Spec->catdir(qw(lib Test Simple sample_tests));
-while( my($test_name, $exit_codes) = each %Tests ) {
- my($exit_code) = $exit_codes->[$IsVMS ? 1 : 0];
+# Some OS' will alter the exit code to their own native sense...
+# sometimes. Rather than deal with the exception we'll just
+# build up the mapping.
+print "# Building up a map of exit codes. May take a while.\n";
+my %Exit_Map;
+
+open my $fh, ">", "exit_map_test" or die $!;
+print $fh <<'DONE';
+if ($^O eq 'VMS') {
+ require vmsish;
+ import vmsish qw(hushed);
+}
+my $exit = shift;
+print "exit $exit\n";
+END { $? = $exit };
+DONE
+
+close $fh;
+END { 1 while unlink "exit_map_test" }
+
+for my $exit (0..255) {
+ # This correctly emulates Test::Builder's behavior.
+ my $out = qx[$Perl exit_map_test $exit];
+ $TB->like( $out, qr/^exit $exit\n/, "exit map test for $exit" );
+ $Exit_Map{$exit} = exitstatus($?);
+}
+print "# Done.\n";
- if( $^O eq 'VMS' ) {
- # VMS can't use its own $^X in a system call until almost 5.8
- $Perl = "MCR $^X" if $] < 5.007003;
- # Quiet noisy 'SYS$ABORT'. 'hushed' only exists in 5.6 and up,
- # but it doesn't do any harm on eariler perls.
- $Perl .= q{ -"Mvmsish=hushed"};
- }
+my %Tests = (
+ # File Exit Code
+ 'success.plx' => 0,
+ 'one_fail.plx' => 1,
+ 'two_fail.plx' => 2,
+ 'five_fail.plx' => 5,
+ 'extras.plx' => 2,
+ 'too_few.plx' => 255,
+ 'too_few_fail.plx' => 2,
+ 'death.plx' => 255,
+ 'last_minute_death.plx' => 255,
+ 'pre_plan_death.plx' => 'not zero',
+ 'death_in_eval.plx' => 0,
+ 'require.plx' => 0,
+ 'death_with_handler.plx' => 255,
+ 'exit.plx' => 1,
+ );
+chdir 't';
+my $lib = File::Spec->catdir(qw(lib Test Simple sample_tests));
+while( my($test_name, $exit_code) = each %Tests ) {
my $file = File::Spec->catfile($lib, $test_name);
my $wait_stat = system(qq{$Perl -"I../blib/lib" -"I../lib" -"I../t/lib" $file});
my $actual_exit = exitstatus($wait_stat);
if( $exit_code eq 'not zero' ) {
- $TB->isnt_num( $actual_exit, 0,
+ $TB->isnt_num( $actual_exit, $Exit_Map{0},
"$test_name exited with $actual_exit ".
- "(expected $exit_code)");
+ "(expected non-zero)");
}
else {
- $TB->is_num( $actual_exit, $exit_code,
+ $TB->is_num( $actual_exit, $Exit_Map{$exit_code},
"$test_name exited with $actual_exit ".
- "(expected $exit_code)");
+ "(expected $Exit_Map{$exit_code})");
}
}
+
+$TB->done_testing( scalar keys(%Tests) + 256 );
+
+# So any END block file cleanup works.
+chdir $Orig_Dir;
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/explain.t b/gnu/usr.bin/perl/lib/Test/Simple/t/explain.t
index 6be781ca28c..cf2f550e950 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/explain.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/explain.t
@@ -1,5 +1,4 @@
#!/usr/bin/perl -w
-# $Id: explain.t,v 1.1 2009/05/16 21:42:57 simon Exp $
BEGIN {
if( $ENV{PERL_CORE} ) {
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/extra.t b/gnu/usr.bin/perl/lib/Test/Simple/t/extra.t
index 778284da43e..57235be1956 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/extra.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/extra.t
@@ -1,5 +1,4 @@
#!perl -w
-# $Id$
BEGIN {
if( $ENV{PERL_CORE} ) {
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/extra_one.t b/gnu/usr.bin/perl/lib/Test/Simple/t/extra_one.t
index 3d8b248d5b7..d77404e15de 100755
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/extra_one.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/extra_one.t
@@ -1,5 +1,4 @@
#!/usr/bin/perl -w
-# $Id: extra_one.t,v 1.2 2009/05/16 21:42:57 simon Exp $
BEGIN {
if( $ENV{PERL_CORE} ) {
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/fail-like.t b/gnu/usr.bin/perl/lib/Test/Simple/t/fail-like.t
index d1a51d49e14..0ea5fab3dab 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/fail-like.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/fail-like.t
@@ -1,5 +1,4 @@
#!/usr/bin/perl -w
-# $Id$
BEGIN {
if( $ENV{PERL_CORE} ) {
@@ -56,14 +55,14 @@ ERR
}
{
- # line 60
+ # line 59
like("foo", "not a regex");
$TB->is_eq($out->read, <<OUT);
not ok 2
OUT
$TB->is_eq($err->read, <<OUT);
-# Failed test at $0 line 60.
+# Failed test at $0 line 59.
# 'not a regex' doesn't look much like a regex to me.
OUT
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/fail-more.t b/gnu/usr.bin/perl/lib/Test/Simple/t/fail-more.t
index 4e515c5fb85..423e2164882 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/fail-more.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/fail-more.t
@@ -1,5 +1,4 @@
#!perl -w
-# $Id$
BEGIN {
if( $ENV{PERL_CORE} ) {
@@ -25,7 +24,7 @@ package My::Test;
# Test::Builder's own and the ending diagnostics don't come out right.
require Test::Builder;
my $TB = Test::Builder->create;
-$TB->plan(tests => 23);
+$TB->plan(tests => 78);
sub like ($$;$) {
$TB->like(@_);
@@ -35,26 +34,26 @@ sub is ($$;$) {
$TB->is_eq(@_);
}
-sub main::err_ok ($) {
- my($expect) = @_;
- my $got = $err->read;
-
- return $TB->is_eq( $got, $expect );
+sub main::out_ok ($$) {
+ $TB->is_eq( $out->read, shift );
+ $TB->is_eq( $err->read, shift );
}
-sub main::err_like ($) {
- my($expect) = @_;
- my $got = $err->read;
+sub main::out_like ($$) {
+ my($output, $failure) = @_;
- return $TB->like( $got, qr/$expect/ );
+ $TB->like( $out->read, qr/$output/ );
+ $TB->like( $err->read, qr/$failure/ );
}
package main;
require Test::More;
-my $Total = 36;
+our $TODO;
+my $Total = 37;
Test::More->import(tests => $Total);
+$out->read; # clear the plan from $out
# This should all work in the presence of a __DIE__ handler.
local $SIG{__DIE__} = sub { $TB->ok(0, "DIE handler called: ".join "", @_); };
@@ -65,234 +64,387 @@ $tb->use_numbers(0);
my $Filename = quotemeta $0;
-# Preserve the line numbers.
+
#line 38
ok( 0, 'failing' );
-err_ok( <<ERR );
+out_ok( <<OUT, <<ERR );
+not ok - failing
+OUT
# Failed test 'failing'
# at $0 line 38.
ERR
+
#line 40
is( "foo", "bar", 'foo is bar?');
-is( undef, '', 'undef is empty string?');
-is( undef, 0, 'undef is 0?');
-is( '', 0, 'empty string is 0?' );
-err_ok( <<ERR );
+out_ok( <<OUT, <<ERR );
+not ok - foo is bar?
+OUT
# Failed test 'foo is bar?'
# at $0 line 40.
# got: 'foo'
# expected: 'bar'
+ERR
+
+#line 89
+is( undef, '', 'undef is empty string?');
+out_ok( <<OUT, <<ERR );
+not ok - undef is empty string?
+OUT
# Failed test 'undef is empty string?'
-# at $0 line 41.
+# at $0 line 89.
# got: undef
# expected: ''
+ERR
+
+#line 99
+is( undef, 0, 'undef is 0?');
+out_ok( <<OUT, <<ERR );
+not ok - undef is 0?
+OUT
# Failed test 'undef is 0?'
-# at $0 line 42.
+# at $0 line 99.
# got: undef
# expected: '0'
+ERR
+
+#line 110
+is( '', 0, 'empty string is 0?' );
+out_ok( <<OUT, <<ERR );
+not ok - empty string is 0?
+OUT
# Failed test 'empty string is 0?'
-# at $0 line 43.
+# at $0 line 110.
# got: ''
# expected: '0'
ERR
-#line 45
+#line 121
isnt("foo", "foo", 'foo isnt foo?' );
-isn't("foo", "foo",'foo isn\'t foo?' );
-isnt(undef, undef, 'undef isnt undef?');
-err_ok( <<ERR );
+out_ok( <<OUT, <<ERR );
+not ok - foo isnt foo?
+OUT
# Failed test 'foo isnt foo?'
-# at $0 line 45.
+# at $0 line 121.
# got: 'foo'
# expected: anything else
+ERR
+
+#line 132
+isn't("foo", "foo",'foo isn\'t foo?' );
+out_ok( <<OUT, <<ERR );
+not ok - foo isn't foo?
+OUT
# Failed test 'foo isn\'t foo?'
-# at $0 line 46.
+# at $0 line 132.
# got: 'foo'
# expected: anything else
+ERR
+
+#line 143
+isnt(undef, undef, 'undef isnt undef?');
+out_ok( <<OUT, <<ERR );
+not ok - undef isnt undef?
+OUT
# Failed test 'undef isnt undef?'
-# at $0 line 47.
+# at $0 line 143.
# got: undef
# expected: anything else
ERR
-#line 48
+#line 154
like( "foo", '/that/', 'is foo like that' );
-unlike( "foo", '/foo/', 'is foo unlike foo' );
-err_ok( <<ERR );
+out_ok( <<OUT, <<ERR );
+not ok - is foo like that
+OUT
# Failed test 'is foo like that'
-# at $0 line 48.
+# at $0 line 154.
# 'foo'
# doesn't match '/that/'
+ERR
+
+#line 165
+unlike( "foo", '/foo/', 'is foo unlike foo' );
+out_ok( <<OUT, <<ERR );
+not ok - is foo unlike foo
+OUT
# Failed test 'is foo unlike foo'
-# at $0 line 49.
+# at $0 line 165.
# 'foo'
# matches '/foo/'
ERR
# Nick Clark found this was a bug. Fixed in 0.40.
-# line 60
+# line 177
like( "bug", '/(%)/', 'regex with % in it' );
-err_ok( <<ERR );
+out_ok( <<OUT, <<ERR );
+not ok - regex with % in it
+OUT
# Failed test 'regex with % in it'
-# at $0 line 60.
+# at $0 line 177.
# 'bug'
# doesn't match '/(%)/'
ERR
-#line 67
+#line 188
fail('fail()');
-err_ok( <<ERR );
+out_ok( <<OUT, <<ERR );
+not ok - fail()
+OUT
# Failed test 'fail()'
-# at $0 line 67.
+# at $0 line 188.
ERR
-#line 52
+#line 197
can_ok('Mooble::Hooble::Yooble', qw(this that));
-can_ok('Mooble::Hooble::Yooble', ());
-can_ok(undef, undef);
-can_ok([], "foo");
-err_ok( <<ERR );
+out_ok( <<OUT, <<ERR );
+not ok - Mooble::Hooble::Yooble->can(...)
+OUT
# Failed test 'Mooble::Hooble::Yooble->can(...)'
-# at $0 line 52.
+# at $0 line 197.
# Mooble::Hooble::Yooble->can('this') failed
# Mooble::Hooble::Yooble->can('that') failed
+ERR
+
+#line 208
+can_ok('Mooble::Hooble::Yooble', ());
+out_ok( <<OUT, <<ERR );
+not ok - Mooble::Hooble::Yooble->can(...)
+OUT
# Failed test 'Mooble::Hooble::Yooble->can(...)'
-# at $0 line 53.
+# at $0 line 208.
# can_ok() called with no methods
+ERR
+
+#line 218
+can_ok(undef, undef);
+out_ok( <<OUT, <<ERR );
+not ok - ->can(...)
+OUT
# Failed test '->can(...)'
-# at $0 line 54.
+# at $0 line 218.
# can_ok() called with empty class or reference
+ERR
+
+#line 228
+can_ok([], "foo");
+out_ok( <<OUT, <<ERR );
+not ok - ARRAY->can('foo')
+OUT
# Failed test 'ARRAY->can('foo')'
-# at $0 line 55.
+# at $0 line 228.
# ARRAY->can('foo') failed
ERR
-#line 55
+#line 238
isa_ok(bless([], "Foo"), "Wibble");
-isa_ok(42, "Wibble", "My Wibble");
-isa_ok(undef, "Wibble", "Another Wibble");
-isa_ok([], "HASH");
-err_ok( <<ERR );
+out_ok( <<OUT, <<ERR );
+not ok - The object isa Wibble
+OUT
# Failed test 'The object isa Wibble'
-# at $0 line 55.
+# at $0 line 238.
# The object isn't a 'Wibble' it's a 'Foo'
+ERR
+
+#line 248
+isa_ok(42, "Wibble", "My Wibble");
+out_ok( <<OUT, <<ERR );
+not ok - My Wibble isa Wibble
+OUT
# Failed test 'My Wibble isa Wibble'
-# at $0 line 56.
-# My Wibble isn't a reference
+# at $0 line 248.
+# My Wibble isn't a class or reference
+ERR
+
+#line 258
+isa_ok(undef, "Wibble", "Another Wibble");
+out_ok( <<OUT, <<ERR );
+not ok - Another Wibble isa Wibble
+OUT
# Failed test 'Another Wibble isa Wibble'
-# at $0 line 57.
+# at $0 line 258.
# Another Wibble isn't defined
-# Failed test 'The object isa HASH'
-# at $0 line 58.
-# The object isn't a 'HASH' it's a 'ARRAY'
ERR
+#line 268
+isa_ok([], "HASH");
+out_ok( <<OUT, <<ERR );
+not ok - The reference isa HASH
+OUT
+# Failed test 'The reference isa HASH'
+# at $0 line 268.
+# The reference isn't a 'HASH' it's a 'ARRAY'
+ERR
-#line 188
+#line 278
new_ok(undef);
-err_like( <<ERR );
+out_like( <<OUT, <<ERR );
+not ok - new\\(\\) died
+OUT
# Failed test 'new\\(\\) died'
-# at $Filename line 188.
+# at $Filename line 278.
# Error was: Can't call method "new" on an undefined value at .*
ERR
-#line 211
+#line 288
new_ok( "Does::Not::Exist" );
-err_like( <<ERR );
+out_like( <<OUT, <<ERR );
+not ok - new\\(\\) died
+OUT
# Failed test 'new\\(\\) died'
-# at $Filename line 211.
+# at $Filename line 288.
# Error was: Can't locate object method "new" via package "Does::Not::Exist" .*
ERR
+
{ package Foo; sub new { } }
{ package Bar; sub new { {} } }
{ package Baz; sub new { bless {}, "Wibble" } }
-#line 219
+#line 303
new_ok( "Foo" );
-err_ok( <<ERR );
+out_ok( <<OUT, <<ERR );
+not ok - The object isa Foo
+OUT
# Failed test 'The object isa Foo'
-# at $0 line 219.
+# at $0 line 303.
# The object isn't defined
ERR
-# line 231
+# line 313
new_ok( "Bar" );
-err_ok( <<ERR );
+out_ok( <<OUT, <<ERR );
+not ok - The object isa Bar
+OUT
# Failed test 'The object isa Bar'
-# at $0 line 231.
+# at $0 line 313.
# The object isn't a 'Bar' it's a 'HASH'
ERR
-#line 239
+#line 323
new_ok( "Baz" );
-err_ok( <<ERR );
+out_ok( <<OUT, <<ERR );
+not ok - The object isa Baz
+OUT
# Failed test 'The object isa Baz'
-# at $0 line 239.
+# at $0 line 323.
# The object isn't a 'Baz' it's a 'Wibble'
ERR
-#line 247
+#line 333
new_ok( "Baz", [], "no args" );
-err_ok( <<ERR );
+out_ok( <<OUT, <<ERR );
+not ok - no args isa Baz
+OUT
# Failed test 'no args isa Baz'
-# at $0 line 247.
+# at $0 line 333.
# no args isn't a 'Baz' it's a 'Wibble'
ERR
-
-#line 68
+#line 343
cmp_ok( 'foo', 'eq', 'bar', 'cmp_ok eq' );
-cmp_ok( 42.1, '==', 23, , ' ==' );
-cmp_ok( 42, '!=', 42 , ' !=' );
-cmp_ok( 1, '&&', 0 , ' &&' );
-err_ok( <<ERR );
+out_ok( <<OUT, <<ERR );
+not ok - cmp_ok eq
+OUT
# Failed test 'cmp_ok eq'
-# at $0 line 68.
+# at $0 line 343.
# got: 'foo'
# expected: 'bar'
+ERR
+
+#line 354
+cmp_ok( 42.1, '==', 23, , ' ==' );
+out_ok( <<OUT, <<ERR );
+not ok - ==
+OUT
# Failed test ' =='
-# at $0 line 69.
+# at $0 line 354.
# got: 42.1
# expected: 23
+ERR
+
+#line 365
+cmp_ok( 42, '!=', 42 , ' !=' );
+out_ok( <<OUT, <<ERR );
+not ok - !=
+OUT
# Failed test ' !='
-# at $0 line 70.
+# at $0 line 365.
# got: 42
# expected: anything else
+ERR
+
+#line 376
+cmp_ok( 1, '&&', 0 , ' &&' );
+out_ok( <<OUT, <<ERR );
+not ok - &&
+OUT
# Failed test ' &&'
-# at $0 line 71.
+# at $0 line 376.
# '1'
# &&
# '0'
ERR
-
-# line 196
+# line 388
cmp_ok( 42, 'eq', "foo", ' eq with numbers' );
-err_ok( <<ERR );
+out_ok( <<OUT, <<ERR );
+not ok - eq with numbers
+OUT
# Failed test ' eq with numbers'
-# at $0 line 196.
+# at $0 line 388.
# got: '42'
# expected: 'foo'
ERR
-
{
- my $warnings;
+ my $warnings = '';
local $SIG{__WARN__} = sub { $warnings .= join '', @_ };
-# line 211
+# line 404
cmp_ok( 42, '==', "foo", ' == with strings' );
- err_ok( <<ERR );
+ out_ok( <<OUT, <<ERR );
+not ok - == with strings
+OUT
# Failed test ' == with strings'
-# at $0 line 211.
+# at $0 line 404.
# got: 42
# expected: foo
ERR
- My::Test::like $warnings,
- qr/^Argument "foo" isn't numeric in .* at cmp_ok \[from $Filename line 211\] line 1\.\n$/;
+ My::Test::like(
+ $warnings,
+ qr/^Argument "foo" isn't numeric in .* at cmp_ok \[from $Filename line 404\] line 1\.\n$/
+ );
+ $warnings = '';
+}
+
+{
+ my $warnings = '';
+ local $SIG{__WARN__} = sub { $warnings .= join '', @_ };
+
+#line 426
+ cmp_ok( undef, "ne", "", "undef ne empty string" );
+
+ $TB->is_eq( $out->read, <<OUT );
+not ok - undef ne empty string
+OUT
+
+ TODO: {
+ local $::TODO = 'cmp_ok() gives the wrong "expected" for undef';
+
+ $TB->is_eq( $err->read, <<ERR );
+# Failed test 'undef ne empty string'
+# at $0 line 426.
+# got: undef
+# expected: ''
+ERR
+ }
+
+ My::Test::like(
+ $warnings,
+ qr/^Use of uninitialized value.* in string ne at cmp_ok \[from $Filename line 426\] line 1\.\n\z/
+ );
}
@@ -300,88 +452,58 @@ ERR
-e "wibblehibble";
my $Errno_Number = $!+0;
my $Errno_String = $!.'';
-#line 80
+#line 425
cmp_ok( $!, 'eq', '', ' eq with stringified errno' );
-cmp_ok( $!, '==', -1, ' eq with numerified errno' );
-err_ok( <<ERR );
+out_ok( <<OUT, <<ERR );
+not ok - eq with stringified errno
+OUT
# Failed test ' eq with stringified errno'
-# at $0 line 80.
+# at $0 line 425.
# got: '$Errno_String'
# expected: ''
+ERR
+
+#line 436
+cmp_ok( $!, '==', -1, ' eq with numerified errno' );
+out_ok( <<OUT, <<ERR );
+not ok - eq with numerified errno
+OUT
# Failed test ' eq with numerified errno'
-# at $0 line 81.
+# at $0 line 436.
# got: $Errno_Number
# expected: -1
ERR
-#line 84
+#line 447
use_ok('Hooble::mooble::yooble');
-
my $more_err_re = <<ERR;
# Failed test 'use Hooble::mooble::yooble;'
-# at $Filename line 84\\.
+# at $Filename line 447\\.
# Tried to use 'Hooble::mooble::yooble'.
# Error: Can't locate Hooble.* in \\\@INC .*
ERR
+out_like(
+ qr/^\Qnot ok - use Hooble::mooble::yooble;\E\n\z/,
+ qr/^$more_err_re/
+);
-My::Test::like($err->read, "/^$more_err_re/");
-
-
-#line 85
+#line 460
require_ok('ALL::YOUR::BASE::ARE::BELONG::TO::US::wibble');
$more_err_re = <<ERR;
# Failed test 'require ALL::YOUR::BASE::ARE::BELONG::TO::US::wibble;'
-# at $Filename line 85\\.
+# at $Filename line 460\\.
# Tried to require 'ALL::YOUR::BASE::ARE::BELONG::TO::US::wibble'.
# Error: Can't locate ALL.* in \\\@INC .*
ERR
-
-My::Test::like($err->read, "/^$more_err_re/");
+out_like(
+ qr/^\Qnot ok - require ALL::YOUR::BASE::ARE::BELONG::TO::US::wibble;\E\n\z/,
+ qr/^$more_err_re/
+);
-#line 88
END {
- $TB->is_eq($$out, <<OUT, 'failing output');
-1..$Total
-not ok - failing
-not ok - foo is bar?
-not ok - undef is empty string?
-not ok - undef is 0?
-not ok - empty string is 0?
-not ok - foo isnt foo?
-not ok - foo isn't foo?
-not ok - undef isnt undef?
-not ok - is foo like that
-not ok - is foo unlike foo
-not ok - regex with % in it
-not ok - fail()
-not ok - Mooble::Hooble::Yooble->can(...)
-not ok - Mooble::Hooble::Yooble->can(...)
-not ok - ->can(...)
-not ok - ARRAY->can('foo')
-not ok - The object isa Wibble
-not ok - My Wibble isa Wibble
-not ok - Another Wibble isa Wibble
-not ok - The object isa HASH
-not ok - new() died
-not ok - new() died
-not ok - The object isa Foo
-not ok - The object isa Bar
-not ok - The object isa Baz
-not ok - no args isa Baz
-not ok - cmp_ok eq
-not ok - ==
-not ok - !=
-not ok - &&
-not ok - eq with numbers
-not ok - == with strings
-not ok - eq with stringified errno
-not ok - eq with numerified errno
-not ok - use Hooble::mooble::yooble;
-not ok - require ALL::YOUR::BASE::ARE::BELONG::TO::US::wibble;
+ out_like( <<OUT, <<ERR );
OUT
-
-err_ok( <<ERR );
# Looks like you failed $Total tests of $Total.
ERR
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/fail.t b/gnu/usr.bin/perl/lib/Test/Simple/t/fail.t
index fd272d17bf4..ccf0c748934 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/fail.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/fail.t
@@ -1,5 +1,6 @@
#!perl -w
-# $Id$
+
+# Simple test of what failure output looks like
BEGIN {
if( $ENV{PERL_CORE} ) {
@@ -13,45 +14,28 @@ BEGIN {
use strict;
-require Test::Simple::Catch;
-my($out, $err) = Test::Simple::Catch::caught();
+# Normalize the output whether we're running under Test::Harness or not.
local $ENV{HARNESS_ACTIVE} = 0;
+use Test::Builder;
+use Test::Builder::NoOutput;
-# Can't use Test.pm, that's a 5.005 thing.
-package My::Test;
-
-print "1..2\n";
-
-my $test_num = 1;
-# Utility testing functions.
-sub ok ($;$) {
- my($test, $name) = @_;
- my $ok = '';
- $ok .= "not " unless $test;
- $ok .= "ok $test_num";
- $ok .= " - $name" if defined $name;
- $ok .= "\n";
- print $ok;
- $test_num++;
-}
-
-
-package main;
-
-require Test::Simple;
-Test::Simple->import(tests => 5);
+my $Test = Test::Builder->new;
-#line 35
-ok( 1, 'passing' );
-ok( 2, 'passing still' );
-ok( 3, 'still passing' );
-ok( 0, 'oh no!' );
-ok( 0, 'damnit' );
+# Set up a builder to record some failing tests.
+{
+ my $tb = Test::Builder::NoOutput->create;
+ $tb->plan( tests => 5 );
+#line 28
+ $tb->ok( 1, 'passing' );
+ $tb->ok( 2, 'passing still' );
+ $tb->ok( 3, 'still passing' );
+ $tb->ok( 0, 'oh no!' );
+ $tb->ok( 0, 'damnit' );
+ $tb->_ending;
-END {
- My::Test::ok($$out eq <<OUT);
+ $Test->is_eq($tb->read('out'), <<OUT);
1..5
ok 1 - passing
ok 2 - passing still
@@ -60,14 +44,13 @@ not ok 4 - oh no!
not ok 5 - damnit
OUT
- My::Test::ok($$err eq <<ERR);
+ $Test->is_eq($tb->read('err'), <<ERR);
# Failed test 'oh no!'
-# at $0 line 38.
+# at $0 line 31.
# Failed test 'damnit'
-# at $0 line 39.
+# at $0 line 32.
# Looks like you failed 2 tests of 5.
ERR
- # Prevent Test::Simple from exiting with non zero
- exit 0;
+ $Test->done_testing(2);
}
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/fail_one.t b/gnu/usr.bin/perl/lib/Test/Simple/t/fail_one.t
index 91c671c6fd8..61d7c081ffe 100755
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/fail_one.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/fail_one.t
@@ -1,5 +1,4 @@
#!/usr/bin/perl -w
-# $Id: fail_one.t,v 1.2 2009/05/16 21:42:57 simon Exp $
BEGIN {
if( $ENV{PERL_CORE} ) {
@@ -13,51 +12,32 @@ BEGIN {
use strict;
-require Test::Simple::Catch;
-my($out, $err) = Test::Simple::Catch::caught();
+# Normalize the output whether we're running under Test::Harness or not.
local $ENV{HARNESS_ACTIVE} = 0;
+use Test::Builder;
+use Test::Builder::NoOutput;
-# Can't use Test.pm, that's a 5.005 thing.
-package My::Test;
+my $Test = Test::Builder->new;
-print "1..2\n";
+{
+ my $tb = Test::Builder::NoOutput->create;
-my $test_num = 1;
-# Utility testing functions.
-sub ok ($;$) {
- my($test, $name) = @_;
- my $ok = '';
- $ok .= "not " unless $test;
- $ok .= "ok $test_num";
- $ok .= " - $name" if defined $name;
- $ok .= "\n";
- print $ok;
- $test_num++;
+ $tb->plan( tests => 1 );
- return $test ? 1 : 0;
-}
-
-
-package main;
-
-require Test::Simple;
-Test::Simple->import(tests => 1);
-
-#line 45
-ok(0);
+#line 28
+ $tb->ok(0);
+ $tb->_ending;
-END {
- My::Test::ok($$out eq <<OUT);
+ $Test->is_eq($tb->read('out'), <<OUT);
1..1
not ok 1
OUT
- My::Test::ok($$err eq <<ERR) || print $$err;
-# Failed test at $0 line 45.
+ $Test->is_eq($tb->read('err'), <<ERR);
+# Failed test at $0 line 28.
# Looks like you failed 1 test of 1.
ERR
- # Prevent Test::Simple from existing with non-zero
- exit 0;
+ $Test->done_testing(2);
}
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/filehandles.t b/gnu/usr.bin/perl/lib/Test/Simple/t/filehandles.t
index 1e20470f277..f7dad5d7ea6 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/filehandles.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/filehandles.t
@@ -1,5 +1,4 @@
#!perl -w
-# $Id$
BEGIN {
if( $ENV{PERL_CORE} ) {
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/fork.t b/gnu/usr.bin/perl/lib/Test/Simple/t/fork.t
index 02cd73b44ce..55d7aec1f9a 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/fork.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/fork.t
@@ -1,5 +1,4 @@
#!/usr/bin/perl -w
-# $Id: fork.t,v 1.2 2009/05/16 21:42:57 simon Exp $
BEGIN {
if( $ENV{PERL_CORE} ) {
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/harness_active.t b/gnu/usr.bin/perl/lib/Test/Simple/t/harness_active.t
index 409fa4f6350..7b027a7b404 100755
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/harness_active.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/harness_active.t
@@ -1,5 +1,4 @@
#!perl -w
-# $Id: harness_active.t,v 1.2 2009/05/16 21:42:57 simon Exp $
BEGIN {
if( $ENV{PERL_CORE} ) {
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/has_plan.t b/gnu/usr.bin/perl/lib/Test/Simple/t/has_plan.t
deleted file mode 100644
index d3f888f2a59..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/has_plan.t
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/usr/bin/perl -w
-
-BEGIN {
- if( $ENV{PERL_CORE} ) {
- chdir 't';
- @INC = ('../lib');
- }
-}
-
-use strict;
-use Test::Builder;
-
-my $unplanned;
-
-BEGIN {
- $unplanned = 'oops';
- $unplanned = Test::Builder->has_plan;
-};
-
-use Test::More tests => 2;
-
-is($unplanned, undef, 'no plan yet defined');
-is(Test::Builder->has_plan, 2, 'has fixed plan');
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/has_plan2.t b/gnu/usr.bin/perl/lib/Test/Simple/t/has_plan2.t
deleted file mode 100644
index 2b9ac499da2..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/has_plan2.t
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/usr/bin/perl -w
-
-BEGIN {
- if( $ENV{PERL_CORE} ) {
- chdir 't';
- @INC = '../lib';
- }
-}
-
-use Test::More;
-
-BEGIN {
- if( !$ENV{HARNESS_ACTIVE} && $ENV{PERL_CORE} ) {
- plan skip_all => "Won't work with t/TEST";
- }
-}
-
-BEGIN {
- require Test::Harness;
-}
-
-if( $Test::Harness::VERSION < 1.20 ) {
- plan skip_all => 'Need Test::Harness 1.20 or up';
-}
-
-use strict;
-use Test::Builder;
-
-plan 'no_plan';
-is(Test::Builder->has_plan, 'no_plan', 'has no_plan');
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/import.t b/gnu/usr.bin/perl/lib/Test/Simple/t/import.t
index fd2aef40ba2..68a36138bc9 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/import.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/import.t
@@ -1,4 +1,3 @@
-# $Id$
BEGIN {
if( $ENV{PERL_CORE} ) {
chdir 't';
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/is_deeply_dne_bug.t b/gnu/usr.bin/perl/lib/Test/Simple/t/is_deeply_dne_bug.t
index 43cdce9786b..f4578a6460e 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/is_deeply_dne_bug.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/is_deeply_dne_bug.t
@@ -1,5 +1,4 @@
#!/usr/bin/perl -w
-# $Id$
# test for rt.cpan.org 20768
#
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/is_deeply_fail.t b/gnu/usr.bin/perl/lib/Test/Simple/t/is_deeply_fail.t
index 044a6595272..bd9b6342333 100755
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/is_deeply_fail.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/is_deeply_fail.t
@@ -1,5 +1,4 @@
#!/usr/bin/perl -w
-# $Id: is_deeply_fail.t,v 1.2 2009/05/16 21:42:57 simon Exp $
BEGIN {
if( $ENV{PERL_CORE} ) {
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/is_deeply_with_threads.t b/gnu/usr.bin/perl/lib/Test/Simple/t/is_deeply_with_threads.t
index 634bba30e97..9908ef66083 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/is_deeply_with_threads.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/is_deeply_with_threads.t
@@ -1,5 +1,4 @@
#!/usr/bin/perl -w
-# $Id$
# Test to see if is_deeply() plays well with threads.
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/is_fh.t b/gnu/usr.bin/perl/lib/Test/Simple/t/is_fh.t
deleted file mode 100755
index a1c201c2cc8..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/is_fh.t
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/usr/bin/perl -w
-
-BEGIN {
- if( $ENV{PERL_CORE} ) {
- chdir 't';
- @INC = ('../lib', 'lib');
- }
- else {
- unshift @INC, 't/lib';
- }
-}
-
-use strict;
-use Test::More tests => 8;
-use TieOut;
-
-ok( !Test::Builder::_is_fh("foo"), 'string is not a filehandle' );
-ok( !Test::Builder::_is_fh(''), 'empty string' );
-ok( !Test::Builder::_is_fh(undef), 'undef' );
-
-ok( open(FILE, '>foo') );
-END { close FILE; unlink 'foo' }
-
-ok( Test::Builder::_is_fh(*FILE) );
-ok( Test::Builder::_is_fh(\*FILE) );
-ok( Test::Builder::_is_fh(*FILE{IO}) );
-
-tie *OUT, 'TieOut';
-ok( Test::Builder::_is_fh(*OUT) );
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/lib/Dummy.pm b/gnu/usr.bin/perl/lib/Test/Simple/t/lib/Dummy.pm
index e0cf30abc95..cdff79d5404 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/lib/Dummy.pm
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/lib/Dummy.pm
@@ -1,6 +1,6 @@
package Dummy;
-# $Id$
-$VERSION = '0.01';
+use strict;
+our $VERSION = '0.01';
1;
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/lib/MyOverload.pm b/gnu/usr.bin/perl/lib/Test/Simple/t/lib/MyOverload.pm
index 6d78b937738..65f5ea5a7dc 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/lib/MyOverload.pm
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/lib/MyOverload.pm
@@ -1,5 +1,6 @@
-package Overloaded;
-# $Id$
+package Overloaded; ##no critic (Modules::RequireFilenameMatchesPackage)
+
+use strict;
sub new {
my $class = shift;
@@ -7,8 +8,9 @@ sub new {
}
package Overloaded::Compare;
-use vars qw(@ISA);
-@ISA = qw(Overloaded);
+
+use strict;
+our @ISA = qw(Overloaded);
# Sometimes objects have only comparison ops overloaded and nothing else.
# For example, DateTime objects.
@@ -17,8 +19,9 @@ use overload
q{==} => sub { $_[0]->{num} == $_[1] };
package Overloaded::Ify;
-use vars qw(@ISA);
-@ISA = qw(Overloaded);
+
+use strict;
+our @ISA = qw(Overloaded);
use overload
q{""} => sub { $_[0]->{string} },
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/lib/NoExporter.pm b/gnu/usr.bin/perl/lib/Test/Simple/t/lib/NoExporter.pm
index 5d60b315e72..6273e32d743 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/lib/NoExporter.pm
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/lib/NoExporter.pm
@@ -1,7 +1,7 @@
package NoExporter;
-# $Id: NoExporter.pm,v 1.1 2009/05/16 21:42:58 simon Exp $
-$VERSION = 1.02;
+use strict;
+our $VERSION = 1.02;
sub import {
shift;
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/lib/SigDie.pm b/gnu/usr.bin/perl/lib/Test/Simple/t/lib/SigDie.pm
index f954e2db785..0774728d4ed 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/lib/SigDie.pm
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/lib/SigDie.pm
@@ -1,6 +1,8 @@
package SigDie;
-use vars qw($DIE);
+use strict;
+
+our $DIE;
$SIG{__DIE__} = sub { $DIE = $@ };
1;
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/lib/TieOut.pm b/gnu/usr.bin/perl/lib/Test/Simple/t/lib/TieOut.pm
deleted file mode 100644
index e8d48261397..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/lib/TieOut.pm
+++ /dev/null
@@ -1,29 +0,0 @@
-package TieOut;
-# $Id: TieOut.pm,v 1.1 2009/05/16 21:42:58 simon Exp $
-
-sub TIEHANDLE {
- my $scalar = '';
- bless( \$scalar, $_[0] );
-}
-
-sub PRINT {
- my $self = shift;
- $$self .= join( '', @_ );
-}
-
-sub PRINTF {
- my $self = shift;
- my $fmt = shift;
- $$self .= sprintf $fmt, @_;
-}
-
-sub FILENO { }
-
-sub read {
- my $self = shift;
- my $data = $$self;
- $$self = '';
- return $data;
-}
-
-1;
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/maybe_regex.t b/gnu/usr.bin/perl/lib/Test/Simple/t/maybe_regex.t
deleted file mode 100644
index dcc84f41c20..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/maybe_regex.t
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/usr/bin/perl -w
-
-BEGIN {
- if( $ENV{PERL_CORE} ) {
- chdir 't';
- @INC = ('../lib', 'lib');
- }
- else {
- unshift @INC, 't/lib';
- }
-}
-
-use strict;
-use Test::More tests => 10;
-
-use Test::Builder;
-my $Test = Test::Builder->new;
-
-SKIP: {
- skip "qr// added in 5.005", 3 if $] < 5.005;
-
- # 5.004 can't even see qr// or it pukes in compile.
- eval q{
- my $r = $Test->maybe_regex(qr/^FOO$/i);
- ok(defined $r, 'qr// detected');
- ok(('foo' =~ /$r/), 'qr// good match');
- ok(('bar' !~ /$r/), 'qr// bad match');
- };
- die $@ if $@;
-}
-
-{
- my $r = $Test->maybe_regex('/^BAR$/i');
- ok(defined $r, '"//" detected');
- ok(('bar' =~ m/$r/), '"//" good match');
- ok(('foo' !~ m/$r/), '"//" bad match');
-};
-
-{
- my $r = $Test->maybe_regex('not a regex');
- ok(!defined $r, 'non-regex detected');
-};
-
-
-{
- my $r = $Test->maybe_regex('/0/');
- ok(defined $r, 'non-regex detected');
- ok(('f00' =~ m/$r/), '"//" good match');
- ok(('b4r' !~ m/$r/), '"//" bad match');
-};
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/missing.t b/gnu/usr.bin/perl/lib/Test/Simple/t/missing.t
index 11f2443e756..3996b6de4b4 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/missing.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/missing.t
@@ -1,4 +1,3 @@
-# $Id$
BEGIN {
if( $ENV{PERL_CORE} ) {
chdir 't';
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/no_diag.t b/gnu/usr.bin/perl/lib/Test/Simple/t/no_diag.t
deleted file mode 100755
index 6fa538a82ea..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/no_diag.t
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/usr/bin/perl -w
-
-use Test::More 'no_diag', tests => 2;
-
-pass('foo');
-diag('This should not be displayed');
-
-is(Test::More->builder->no_diag, 1);
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/no_ending.t b/gnu/usr.bin/perl/lib/Test/Simple/t/no_ending.t
deleted file mode 100644
index 97e968e289e..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/no_ending.t
+++ /dev/null
@@ -1,21 +0,0 @@
-use Test::Builder;
-
-BEGIN {
- if( $ENV{PERL_CORE} ) {
- chdir 't';
- @INC = '../lib';
- }
-}
-
-BEGIN {
- my $t = Test::Builder->new;
- $t->no_ending(1);
-}
-
-use Test::More tests => 3;
-
-# Normally, Test::More would yell that we ran too few tests, but we
-# supressed the ending diagnostics.
-pass;
-print "ok 2\n";
-print "ok 3\n";
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/no_header.t b/gnu/usr.bin/perl/lib/Test/Simple/t/no_header.t
deleted file mode 100644
index 93e6bec34c7..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/no_header.t
+++ /dev/null
@@ -1,21 +0,0 @@
-BEGIN {
- if( $ENV{PERL_CORE} ) {
- chdir 't';
- @INC = '../lib';
- }
-}
-
-use Test::Builder;
-
-# STDOUT must be unbuffered else our prints might come out after
-# Test::More's.
-$| = 1;
-
-BEGIN {
- Test::Builder->new->no_header(1);
-}
-
-use Test::More tests => 1;
-
-print "1..1\n";
-pass;
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/no_plan.t b/gnu/usr.bin/perl/lib/Test/Simple/t/no_plan.t
index 10e85abda9d..5f392e40e1f 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/no_plan.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/no_plan.t
@@ -1,5 +1,4 @@
#!/usr/bin/perl -w
-# $Id$
BEGIN {
if( $ENV{PERL_CORE} ) {
@@ -11,10 +10,9 @@ BEGIN {
}
}
-use Test::More tests => 9;
+use Test::More tests => 7;
my $tb = Test::Builder->create;
-$tb->level(0);
#line 20
ok !eval { $tb->plan(tests => undef) };
@@ -24,16 +22,12 @@ is($@, "Got an undefined number of tests at $0 line 20.\n");
ok !eval { $tb->plan(tests => 0) };
is($@, "You said to run 0 tests at $0 line 24.\n");
-#line 28
-ok !eval { $tb->ok(1) };
-is( $@, "You tried to run a test without a plan at $0 line 28.\n");
-
{
my $warning = '';
local $SIG{__WARN__} = sub { $warning .= join '', @_ };
-#line 36
+#line 31
ok $tb->plan(no_plan => 1);
- is( $warning, "no_plan takes no arguments at $0 line 36.\n" );
+ is( $warning, "no_plan takes no arguments at $0 line 31.\n" );
is $tb->has_plan, 'no_plan';
}
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/no_tests.t b/gnu/usr.bin/perl/lib/Test/Simple/t/no_tests.t
index 278ebc32189..eafa38cacc7 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/no_tests.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/no_tests.t
@@ -1,5 +1,4 @@
#!perl -w
-# $Id: no_tests.t,v 1.1 2009/05/16 21:42:57 simon Exp $
BEGIN {
if( $ENV{PERL_CORE} ) {
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/note.t b/gnu/usr.bin/perl/lib/Test/Simple/t/note.t
index 55646e2a6fb..fb98fb40295 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/note.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/note.t
@@ -1,5 +1,4 @@
#!/usr/bin/perl -w
-# $Id: note.t,v 1.1 2009/05/16 21:42:57 simon Exp $
BEGIN {
if( $ENV{PERL_CORE} ) {
@@ -14,23 +13,18 @@ BEGIN {
use strict;
use warnings;
-use TieOut;
+use Test::Builder::NoOutput;
use Test::More tests => 2;
{
- my $test = Test::More->builder;
+ my $tb = Test::Builder::NoOutput->create;
- my $output = tie *FAKEOUT, "TieOut";
- my $fail_output = tie *FAKEERR, "TieOut";
- $test->output (*FAKEOUT);
- $test->failure_output(*FAKEERR);
+ $tb->note("foo");
- note("foo");
+ $tb->reset_outputs;
- $test->reset_outputs;
-
- is $output->read, "# foo\n";
- is $fail_output->read, '';
+ is $tb->read('out'), "# foo\n";
+ is $tb->read('err'), '';
}
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/ok_obj.t b/gnu/usr.bin/perl/lib/Test/Simple/t/ok_obj.t
deleted file mode 100644
index 8678dbff8d9..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/ok_obj.t
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/usr/bin/perl -w
-
-# Testing to make sure Test::Builder doesn't accidentally store objects
-# passed in as test arguments.
-
-BEGIN {
- if( $ENV{PERL_CORE} ) {
- chdir 't';
- @INC = '../lib';
- }
-}
-
-use Test::More tests => 4;
-
-package Foo;
-my $destroyed = 0;
-sub new { bless {}, shift }
-
-sub DESTROY {
- $destroyed++;
-}
-
-package main;
-
-for (1..3) {
- ok(my $foo = Foo->new, 'created Foo object');
-}
-is $destroyed, 3, "DESTROY called 3 times";
-
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/output.t b/gnu/usr.bin/perl/lib/Test/Simple/t/output.t
deleted file mode 100644
index dd051c15a63..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/output.t
+++ /dev/null
@@ -1,92 +0,0 @@
-#!perl -w
-
-BEGIN {
- if( $ENV{PERL_CORE} ) {
- chdir 't';
- @INC = ('../lib', 'lib');
- }
- else {
- unshift @INC, 't/lib';
- }
-}
-
-# Can't use Test.pm, that's a 5.005 thing.
-print "1..4\n";
-
-my $test_num = 1;
-# Utility testing functions.
-sub ok ($;$) {
- my($test, $name) = @_;
- my $ok = '';
- $ok .= "not " unless $test;
- $ok .= "ok $test_num";
- $ok .= " - $name" if defined $name;
- $ok .= "\n";
- print $ok;
- $test_num++;
-
- return $test;
-}
-
-use TieOut;
-use Test::Builder;
-my $Test = Test::Builder->new();
-
-my $result;
-my $out = $Test->output('foo');
-
-ok( defined $out );
-
-print $out "hi!\n";
-close *$out;
-
-undef $out;
-open(IN, 'foo') or die $!;
-chomp(my $line = <IN>);
-close IN;
-
-ok($line eq 'hi!');
-
-open(FOO, ">>foo") or die $!;
-$out = $Test->output(\*FOO);
-$old = select *$out;
-print "Hello!\n";
-close *$out;
-undef $out;
-select $old;
-open(IN, 'foo') or die $!;
-my @lines = <IN>;
-close IN;
-
-ok($lines[1] =~ /Hello!/);
-
-unlink('foo');
-
-
-# Ensure stray newline in name escaping works.
-$out = tie *FAKEOUT, 'TieOut';
-$Test->output(\*FAKEOUT);
-$Test->exported_to(__PACKAGE__);
-$Test->no_ending(1);
-$Test->plan(tests => 5);
-
-$Test->ok(1, "ok");
-$Test->ok(1, "ok\n");
-$Test->ok(1, "ok, like\nok");
-$Test->skip("wibble\nmoof");
-$Test->todo_skip("todo\nskip\n");
-
-my $output = $out->read;
-ok( $output eq <<OUTPUT ) || print STDERR $output;
-1..5
-ok 1 - ok
-ok 2 - ok
-#
-ok 3 - ok, like
-# ok
-ok 4 # skip wibble
-# moof
-not ok 5 # TODO & SKIP todo
-# skip
-#
-OUTPUT
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/overload.t b/gnu/usr.bin/perl/lib/Test/Simple/t/overload.t
index fb74c59b078..a86103746b3 100755
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/overload.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/overload.t
@@ -1,5 +1,4 @@
#!/usr/bin/perl -w
-# $Id: overload.t,v 1.2 2009/05/16 21:42:57 simon Exp $
BEGIN {
if( $ENV{PERL_CORE} ) {
@@ -12,15 +11,15 @@ BEGIN {
}
use strict;
-use Test::More tests => 15;
+use Test::More tests => 19;
package Overloaded;
use overload
- q{eq} => sub { $_[0]->{string} },
- q{==} => sub { $_[0]->{num} },
- q{""} => sub { $_[0]->{stringfy}++; $_[0]->{string} },
+ q{eq} => sub { $_[0]->{string} eq $_[1] },
+ q{==} => sub { $_[0]->{num} == $_[1] },
+ q{""} => sub { $_[0]->{stringify}++; $_[0]->{string} },
q{0+} => sub { $_[0]->{numify}++; $_[0]->{num} }
;
@@ -46,11 +45,11 @@ local $SIG{__DIE__} = sub {
my $obj = Overloaded->new('foo', 42);
isa_ok $obj, 'Overloaded';
-is $obj, 'foo', 'is() with string overloading';
-cmp_ok $obj, 'eq', 'foo', 'cmp_ok() ...';
-is $obj->{stringify}, 0, 'cmp_ok() eq does not stringify';
-cmp_ok $obj, '==', 42, 'cmp_ok() with number overloading';
-is $obj->{numify}, 0, 'cmp_ok() == does not numify';
+cmp_ok $obj, 'eq', 'foo', 'cmp_ok() eq';
+is $obj->{stringify}, 0, ' does not stringify';
+is $obj, 'foo', 'is() with string overloading';
+cmp_ok $obj, '==', 42, 'cmp_ok() with number overloading';
+is $obj->{numify}, 0, ' does not numify';
is_deeply [$obj], ['foo'], 'is_deeply with string overloading';
ok eq_array([$obj], ['foo']), 'eq_array ...';
@@ -74,3 +73,14 @@ Test::More->builder->is_eq ($obj, "foo");
{'TestPackage' => 'TestPackage'});
::is_deeply('TestPackage', 'TestPackage');
}
+
+
+# Make sure 0 isn't a special case. [rt.cpan.org 41109]
+{
+ my $obj = Overloaded->new('0', 42);
+ isa_ok $obj, 'Overloaded';
+
+ cmp_ok $obj, 'eq', '0', 'cmp_ok() eq';
+ is $obj->{stringify}, 0, ' does not stringify';
+ is $obj, '0', 'is() with string overloading';
+}
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/overload_threads.t b/gnu/usr.bin/perl/lib/Test/Simple/t/overload_threads.t
index fb5e8e0cdaa..379e347baeb 100755
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/overload_threads.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/overload_threads.t
@@ -1,5 +1,4 @@
#!perl -w
-# $Id: overload_threads.t,v 1.2 2009/05/16 21:42:57 simon Exp $
BEGIN {
if( $ENV{PERL_CORE} ) {
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/plan.t b/gnu/usr.bin/perl/lib/Test/Simple/t/plan.t
index 3a55521fa8c..0d3ce89edb1 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/plan.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/plan.t
@@ -1,5 +1,4 @@
#!/usr/bin/perl -w
-# $Id$
BEGIN {
if( $ENV{PERL_CORE} ) {
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/plan_bad.t b/gnu/usr.bin/perl/lib/Test/Simple/t/plan_bad.t
index efeaeeb7807..179356dbc1d 100755
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/plan_bad.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/plan_bad.t
@@ -1,5 +1,4 @@
#!/usr/bin/perl -w
-# $Id: plan_bad.t,v 1.2 2009/05/16 21:42:57 simon Exp $
BEGIN {
if( $ENV{PERL_CORE} ) {
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/plan_is_noplan.t b/gnu/usr.bin/perl/lib/Test/Simple/t/plan_is_noplan.t
index 3ac7574e52c..1e696042eff 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/plan_is_noplan.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/plan_is_noplan.t
@@ -1,4 +1,5 @@
-# $Id$
+#!/usr/bin/perl -w
+
BEGIN {
if( $ENV{PERL_CORE} ) {
chdir 't';
@@ -9,47 +10,23 @@ BEGIN {
}
}
-# Can't use Test.pm, that's a 5.005 thing.
-package My::Test;
-
-print "1..2\n";
-
-my $test_num = 1;
-# Utility testing functions.
-sub ok ($;$) {
- my($test, $name) = @_;
- my $ok = '';
- $ok .= "not " unless $test;
- $ok .= "ok $test_num";
- $ok .= " - $name" if defined $name;
- $ok .= "\n";
- print $ok;
- $test_num++;
-}
-
-
-package main;
+use strict;
-require Test::Simple;
+use Test::More tests => 1;
-require Test::Simple::Catch;
-my($out, $err) = Test::Simple::Catch::caught();
+use Test::Builder::NoOutput;
+{
+ my $tb = Test::Builder::NoOutput->create;
-Test::Simple->import('no_plan');
+ $tb->plan('no_plan');
-ok(1, 'foo');
+ $tb->ok(1, 'foo');
+ $tb->_ending;
-
-END {
- My::Test::ok($$out eq <<OUT);
+ is($tb->read, <<OUT);
ok 1 - foo
1..1
OUT
-
- My::Test::ok($$err eq <<ERR);
-ERR
-
- # Prevent Test::Simple from exiting with non zero
- exit 0;
}
+
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/plan_no_plan.t b/gnu/usr.bin/perl/lib/Test/Simple/t/plan_no_plan.t
index fbe2408c4bb..3111592e97f 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/plan_no_plan.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/plan_no_plan.t
@@ -1,4 +1,3 @@
-# $Id$
BEGIN {
if( $ENV{PERL_CORE} ) {
chdir 't';
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/plan_shouldnt_import.t b/gnu/usr.bin/perl/lib/Test/Simple/t/plan_shouldnt_import.t
index c4aa49b2d5a..b6eb0642446 100755
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/plan_shouldnt_import.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/plan_shouldnt_import.t
@@ -1,5 +1,4 @@
#!/usr/bin/perl -w
-# $Id: plan_shouldnt_import.t,v 1.2 2009/05/16 21:42:57 simon Exp $
# plan() used to export functions by mistake [rt.cpan.org 8385]
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/plan_skip_all.t b/gnu/usr.bin/perl/lib/Test/Simple/t/plan_skip_all.t
index 13335a4927a..528df5f50d4 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/plan_skip_all.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/plan_skip_all.t
@@ -1,4 +1,3 @@
-# $Id$
BEGIN {
if( $ENV{PERL_CORE} ) {
chdir 't';
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/pod-coverage.t b/gnu/usr.bin/perl/lib/Test/Simple/t/pod-coverage.t
deleted file mode 100644
index c95f81ac0bb..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/pod-coverage.t
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/usr/bin/perl -w
-# $Id: pod-coverage.t,v 1.1 2009/05/16 21:42:57 simon Exp $
-
-use Test::More;
-
-# 1.08 added the coverage_class option.
-eval "use Test::Pod::Coverage 1.08";
-plan skip_all => "Test::Pod::Coverage 1.08 required for testing POD coverage" if $@;
-eval "use Pod::Coverage::CountParents";
-plan skip_all => "Pod::Coverage::CountParents required for testing POD coverage" if $@;
-
-my @modules = Test::Pod::Coverage::all_modules();
-plan tests => scalar @modules;
-
-my %coverage_params = (
- "Test::Builder" => {
- also_private => [ '^(share|lock|BAILOUT)$' ]
- },
- "Test::More" => {
- trustme => [ '^(skip|todo)$' ]
- },
-);
-
-for my $module (@modules) {
- pod_coverage_ok( $module, { coverage_class => 'Pod::Coverage::CountParents',
- %{$coverage_params{$module} || {}} }
- );
-}
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/pod.t b/gnu/usr.bin/perl/lib/Test/Simple/t/pod.t
deleted file mode 100644
index ba543f14bd8..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/pod.t
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/usr/bin/perl -w
-# $Id: pod.t,v 1.1 2009/05/16 21:42:57 simon Exp $
-
-use Test::More;
-eval "use Test::Pod 1.00";
-plan skip_all => "Test::Pod 1.00 required for testing POD" if $@;
-all_pod_files_ok();
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/require_ok.t b/gnu/usr.bin/perl/lib/Test/Simple/t/require_ok.t
index 6cbfd1005c1..463a007599c 100755
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/require_ok.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/require_ok.t
@@ -1,5 +1,4 @@
#!/usr/bin/perl -w
-# $Id: require_ok.t,v 1.2 2009/05/16 21:42:57 simon Exp $
BEGIN {
if( $ENV{PERL_CORE} ) {
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/reset.t b/gnu/usr.bin/perl/lib/Test/Simple/t/reset.t
deleted file mode 100755
index 253e0c47669..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/reset.t
+++ /dev/null
@@ -1,88 +0,0 @@
-#!/usr/bin/perl -w
-
-# Test Test::Builder->reset;
-
-BEGIN {
- if( $ENV{PERL_CORE} ) {
- chdir 't';
- @INC = ('../lib', 'lib');
- }
- else {
- unshift @INC, 't/lib';
- }
-}
-chdir 't';
-
-
-use Test::Builder;
-my $tb = Test::Builder->new;
-
-my %Original_Output;
-$Original_Output{$_} = $tb->$_ for qw(output failure_output todo_output);
-
-$tb->plan(tests => 14);
-$tb->level(0);
-
-# Alter the state of Test::Builder as much as possible.
-$tb->ok(1, "Running a test to alter TB's state");
-
-my $tmpfile = 'foo.tmp';
-
-$tb->output($tmpfile);
-$tb->failure_output($tmpfile);
-$tb->todo_output($tmpfile);
-END { 1 while unlink $tmpfile }
-
-# This won't print since we just sent output off to oblivion.
-$tb->ok(0, "And a failure for fun");
-
-$Test::Builder::Level = 3;
-
-$tb->exported_to('Foofer');
-
-$tb->use_numbers(0);
-$tb->no_header(1);
-$tb->no_ending(1);
-
-
-# Now reset it.
-$tb->reset;
-
-my $test_num = 2; # since we already printed 1
-# Utility testing functions.
-sub ok ($;$) {
- my($test, $name) = @_;
- my $ok = '';
- $ok .= "not " unless $test;
- $ok .= "ok $test_num";
- $ok .= " - $name" if defined $name;
- $ok .= "\n";
- print $ok;
- $test_num++;
-
- return $test;
-}
-
-
-ok( !defined $tb->exported_to, 'exported_to' );
-ok( $tb->expected_tests == 0, 'expected_tests' );
-ok( $tb->level == 1, 'level' );
-ok( $tb->use_numbers == 1, 'use_numbers' );
-ok( $tb->no_header == 0, 'no_header' );
-ok( $tb->no_ending == 0, 'no_ending' );
-ok( fileno $tb->output == fileno $Original_Output{output},
- 'output' );
-ok( fileno $tb->failure_output == fileno $Original_Output{failure_output},
- 'failure_output' );
-ok( fileno $tb->todo_output == fileno $Original_Output{todo_output},
- 'todo_output' );
-ok( $tb->current_test == 0, 'current_test' );
-ok( $tb->summary == 0, 'summary' );
-ok( $tb->details == 0, 'details' );
-
-$tb->no_ending(1);
-$tb->no_header(1);
-$tb->plan(tests => 14);
-$tb->current_test(13);
-$tb->level(0);
-$tb->ok(1, 'final test to make sure output was reset');
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/simple.t b/gnu/usr.bin/perl/lib/Test/Simple/t/simple.t
index 67bc6f3a1bd..7297e9d6dd1 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/simple.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/simple.t
@@ -1,4 +1,3 @@
-# $Id$
BEGIN {
if( $ENV{PERL_CORE} ) {
chdir 't';
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/skip.t b/gnu/usr.bin/perl/lib/Test/Simple/t/skip.t
index a8a7cb9b33a..f2ea9fbf201 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/skip.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/skip.t
@@ -1,5 +1,4 @@
#!perl -w
-# $Id$
BEGIN {
if( $ENV{PERL_CORE} ) {
@@ -95,5 +94,5 @@ SKIP: {
pass "This does not run";
}
- like $warning, '/^skip\(\) was passed a non-numeric number of tests/';
+ like $warning, qr/^skip\(\) was passed a non-numeric number of tests/;
}
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/skipall.t b/gnu/usr.bin/perl/lib/Test/Simple/t/skipall.t
index 1bc170b2ea9..5491be126e8 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/skipall.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/skipall.t
@@ -1,4 +1,5 @@
-# $Id$
+#!/usr/bin/perl -w
+
BEGIN {
if( $ENV{PERL_CORE} ) {
chdir 't';
@@ -11,35 +12,22 @@ BEGIN {
use strict;
-# Can't use Test.pm, that's a 5.005 thing.
-package My::Test;
-
-print "1..2\n";
-
-my $test_num = 1;
-# Utility testing functions.
-sub ok ($;$) {
- my($test, $name) = @_;
- my $ok = '';
- $ok .= "not " unless $test;
- $ok .= "ok $test_num";
- $ok .= " - $name" if defined $name;
- $ok .= "\n";
- print $ok;
- $test_num++;
-}
+use Test::More;
+my $Test = Test::Builder->create;
+$Test->plan(tests => 2);
-package main;
-require Test::More;
-
-require Test::Simple::Catch;
-my($out, $err) = Test::Simple::Catch::caught();
-
-Test::More->import('skip_all');
+my $out = '';
+my $err = '';
+{
+ my $tb = Test::More->builder;
+ $tb->output(\$out);
+ $tb->failure_output(\$err);
+ plan 'skip_all';
+}
END {
- My::Test::ok($$out eq "1..0\n");
- My::Test::ok($$err eq "");
+ $Test->is_eq($out, "1..0 # SKIP\n");
+ $Test->is_eq($err, "");
}
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/tbm_doesnt_set_exported_to.t b/gnu/usr.bin/perl/lib/Test/Simple/t/tbm_doesnt_set_exported_to.t
index 94ee4e0bd33..8bdd17753b1 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/tbm_doesnt_set_exported_to.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/tbm_doesnt_set_exported_to.t
@@ -1,5 +1,4 @@
#!/usr/bin/perl -w
-# $Id: tbm_doesnt_set_exported_to.t,v 1.1 2009/05/16 21:42:57 simon Exp $
BEGIN {
if( $ENV{PERL_CORE} ) {
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/tbt_01basic.t b/gnu/usr.bin/perl/lib/Test/Simple/t/tbt_01basic.t
deleted file mode 100755
index 77d10814b79..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/tbt_01basic.t
+++ /dev/null
@@ -1,62 +0,0 @@
-#!/usr/bin/perl
-
-BEGIN {
- if( $ENV{PERL_CORE} ) {
- chdir 't';
- @INC = '../lib';
- }
-}
-
-use Test::Builder::Tester tests => 9;
-use Test::More;
-
-ok(1,"This is a basic test");
-
-test_out("ok 1 - tested");
-ok(1,"tested");
-test_test("captured okay on basic");
-
-test_out("ok 1 - tested");
-ok(1,"tested");
-test_test("captured okay again without changing number");
-
-ok(1,"test unrelated to Test::Builder::Tester");
-
-test_out("ok 1 - one");
-test_out("ok 2 - two");
-ok(1,"one");
-ok(2,"two");
-test_test("multiple tests");
-
-test_out("not ok 1 - should fail");
-test_err("# Failed test ($0 at line 35)");
-test_err("# got: 'foo'");
-test_err("# expected: 'bar'");
-is("foo","bar","should fail");
-test_test("testing failing");
-
-
-test_out("not ok 1");
-test_out("not ok 2");
-test_fail(+2);
-test_fail(+1);
-fail(); fail();
-test_test("testing failing on the same line with no name");
-
-
-test_out("not ok 1 - name");
-test_out("not ok 2 - name");
-test_fail(+2);
-test_fail(+1);
-fail("name"); fail("name");
-test_test("testing failing on the same line with the same name");
-
-
-test_out("not ok 1 - name # TODO Something");
-test_err("# Failed (TODO) test ($0 at line 59)");
-TODO: {
- local $TODO = "Something";
- fail("name");
-}
-test_test("testing failing with todo");
-
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/tbt_02fhrestore.t b/gnu/usr.bin/perl/lib/Test/Simple/t/tbt_02fhrestore.t
deleted file mode 100755
index a9cf36edf2a..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/tbt_02fhrestore.t
+++ /dev/null
@@ -1,65 +0,0 @@
-#!/usr/bin/perl
-
-BEGIN {
- if( $ENV{PERL_CORE} ) {
- chdir 't';
- @INC = '../lib';
- }
-}
-
-use Test::Builder::Tester tests => 4;
-use Test::More;
-use Symbol;
-
-# create temporary file handles that still point indirectly
-# to the right place
-
-my $orig_o = gensym;
-my $orig_t = gensym;
-my $orig_f = gensym;
-
-tie *$orig_o, "My::Passthru", \*STDOUT;
-tie *$orig_t, "My::Passthru", \*STDERR;
-tie *$orig_f, "My::Passthru", \*STDERR;
-
-# redirect the file handles to somewhere else for a mo
-
-use Test::Builder;
-my $t = Test::Builder->new();
-
-$t->output($orig_o);
-$t->failure_output($orig_f);
-$t->todo_output($orig_t);
-
-# run a test
-
-test_out("ok 1 - tested");
-ok(1,"tested");
-test_test("standard test okay");
-
-# now check that they were restored okay
-
-ok($orig_o == $t->output(), "output file reconnected");
-ok($orig_t == $t->todo_output(), "todo output file reconnected");
-ok($orig_f == $t->failure_output(), "failure output file reconnected");
-
-#####################################################################
-
-package My::Passthru;
-
-sub PRINT {
- my $self = shift;
- my $handle = $self->[0];
- print $handle @_;
-}
-
-sub TIEHANDLE {
- my $class = shift;
- my $self = [shift()];
- return bless $self, $class;
-}
-
-sub READ {}
-sub READLINE {}
-sub GETC {}
-sub FILENO {}
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/tbt_03die.t b/gnu/usr.bin/perl/lib/Test/Simple/t/tbt_03die.t
deleted file mode 100755
index ad40ac49fe8..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/tbt_03die.t
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/usr/bin/perl
-
-BEGIN {
- if( $ENV{PERL_CORE} ) {
- chdir 't';
- @INC = '../lib';
- }
-}
-
-use Test::Builder::Tester tests => 1;
-use Test::More;
-
-eval {
- test_test("foo");
-};
-like($@,
- "/Not testing\. You must declare output with a test function first\./",
- "dies correctly on error");
-
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/tbt_04line_num.t b/gnu/usr.bin/perl/lib/Test/Simple/t/tbt_04line_num.t
deleted file mode 100755
index 0155cda661b..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/tbt_04line_num.t
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/usr/bin/perl
-
-BEGIN {
- if( $ENV{PERL_CORE} ) {
- chdir 't';
- @INC = '../lib';
- }
-}
-
-use Test::More tests => 3;
-use Test::Builder::Tester;
-
-is(line_num(),13,"normal line num");
-is(line_num(-1),13,"line number minus one");
-is(line_num(+2),17,"line number plus two");
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/tbt_05faildiag.t b/gnu/usr.bin/perl/lib/Test/Simple/t/tbt_05faildiag.t
deleted file mode 100755
index 0ae875a3211..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/tbt_05faildiag.t
+++ /dev/null
@@ -1,51 +0,0 @@
-#!/usr/bin/perl
-
-BEGIN {
- if( $ENV{PERL_CORE} ) {
- chdir 't';
- @INC = '../lib';
- }
-}
-
-use Test::Builder::Tester tests => 5;
-use Test::More;
-
-# test_fail
-
-test_out("not ok 1 - one");
-test_fail(+1);
-ok(0,"one");
-
-test_out("not ok 2 - two");
-test_fail(+2);
-
-ok(0,"two");
-
-test_test("test fail");
-
-test_fail(+2);
-test_out("not ok 1 - one");
-ok(0,"one");
-test_test("test_fail first");
-
-# test_diag
-
-use Test::Builder;
-my $test = new Test::Builder;
-
-test_diag("this is a test string","so is this");
-$test->diag("this is a test string\n", "so is this\n");
-test_test("test diag");
-
-test_diag("this is a test string","so is this");
-$test->diag("this is a test string\n");
-$test->diag("so is this\n");
-test_test("test diag multi line");
-
-test_diag("this is a test string");
-test_diag("so is this");
-$test->diag("this is a test string\n");
-$test->diag("so is this\n");
-test_test("test diag multiple");
-
-
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/tbt_06errormess.t b/gnu/usr.bin/perl/lib/Test/Simple/t/tbt_06errormess.t
deleted file mode 100755
index e7625ea8184..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/tbt_06errormess.t
+++ /dev/null
@@ -1,127 +0,0 @@
-#!/usr/bin/perl -w
-
-BEGIN {
- if( $ENV{PERL_CORE} ) {
- chdir 't';
- @INC = '../lib';
- }
-}
-
-use Test::More tests => 8;
-use Symbol;
-use Test::Builder;
-use Test::Builder::Tester;
-
-use strict;
-
-# argh! now we need to test the thing we're testing. Basically we need
-# to pretty much reimplement the whole code again. This is very
-# annoying but can't be avoided. And onwards with the cut and paste
-
-# My brain is melting. My brain is melting. ETOOMANYLAYERSOFTESTING
-
-# create some private file handles
-my $output_handle = gensym;
-my $error_handle = gensym;
-
-# and tie them to this package
-my $out = tie *$output_handle, "Test::Tester::Tie", "STDOUT";
-my $err = tie *$error_handle, "Test::Tester::Tie", "STDERR";
-
-# ooooh, use the test suite
-my $t = Test::Builder->new;
-
-# remember the testing outputs
-my $original_output_handle;
-my $original_failure_handle;
-my $original_todo_handle;
-my $original_harness_env;
-my $testing_num;
-
-sub start_testing
-{
- # remember what the handles were set to
- $original_output_handle = $t->output();
- $original_failure_handle = $t->failure_output();
- $original_todo_handle = $t->todo_output();
- $original_harness_env = $ENV{HARNESS_ACTIVE};
-
- # switch out to our own handles
- $t->output($output_handle);
- $t->failure_output($error_handle);
- $t->todo_output($error_handle);
-
- $ENV{HARNESS_ACTIVE} = 0;
-
- # clear the expected list
- $out->reset();
- $err->reset();
-
- # remeber that we're testing
- $testing_num = $t->current_test;
- $t->current_test(0);
-}
-
-# each test test is actually two tests. This is bad and wrong
-# but makes blood come out of my ears if I don't at least simplify
-# it a little this way
-
-sub my_test_test
-{
- my $text = shift;
- local $^W = 0;
-
- # reset the outputs
- $t->output($original_output_handle);
- $t->failure_output($original_failure_handle);
- $t->todo_output($original_todo_handle);
- $ENV{HARNESS_ACTIVE} = $original_harness_env;
-
- # reset the number of tests
- $t->current_test($testing_num);
-
- # check we got the same values
- my $got;
- my $wanted;
-
- # stdout
- $t->ok($out->check, "STDOUT $text");
-
- # stderr
- $t->ok($err->check, "STDERR $text");
-}
-
-####################################################################
-# Meta meta tests
-####################################################################
-
-# this is a quick test to check the hack that I've just implemented
-# actually does a cut down version of Test::Builder::Tester
-
-start_testing();
-$out->expect("ok 1 - foo");
-pass("foo");
-my_test_test("basic meta meta test");
-
-start_testing();
-$out->expect("not ok 1 - foo");
-$err->expect("# Failed test ($0 at line ".line_num(+1).")");
-fail("foo");
-my_test_test("basic meta meta test 2");
-
-start_testing();
-$out->expect("ok 1 - bar");
-test_out("ok 1 - foo");
-pass("foo");
-test_test("bar");
-my_test_test("meta meta test with tbt");
-
-start_testing();
-$out->expect("ok 1 - bar");
-test_out("not ok 1 - foo");
-test_err("# Failed test ($0 at line ".line_num(+1).")");
-fail("foo");
-test_test("bar");
-my_test_test("meta meta test with tbt2 ");
-
-####################################################################
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/tbt_07args.t b/gnu/usr.bin/perl/lib/Test/Simple/t/tbt_07args.t
deleted file mode 100755
index 8e802348b03..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/tbt_07args.t
+++ /dev/null
@@ -1,222 +0,0 @@
-#!/usr/bin/perl -w
-
-BEGIN {
- if( $ENV{PERL_CORE} ) {
- chdir 't';
- @INC = '../lib';
- }
-}
-
-use Test::More tests => 18;
-use Symbol;
-use Test::Builder;
-use Test::Builder::Tester;
-
-use strict;
-
-# argh! now we need to test the thing we're testing. Basically we need
-# to pretty much reimplement the whole code again. This is very
-# annoying but can't be avoided. And onwards with the cut and paste
-
-# My brain is melting. My brain is melting. ETOOMANYLAYERSOFTESTING
-
-# create some private file handles
-my $output_handle = gensym;
-my $error_handle = gensym;
-
-# and tie them to this package
-my $out = tie *$output_handle, "Test::Tester::Tie", "STDOUT";
-my $err = tie *$error_handle, "Test::Tester::Tie", "STDERR";
-
-# ooooh, use the test suite
-my $t = Test::Builder->new;
-
-# remember the testing outputs
-my $original_output_handle;
-my $original_failure_handle;
-my $original_todo_handle;
-my $testing_num;
-my $original_harness_env;
-
-sub start_testing
-{
- # remember what the handles were set to
- $original_output_handle = $t->output();
- $original_failure_handle = $t->failure_output();
- $original_todo_handle = $t->todo_output();
- $original_harness_env = $ENV{HARNESS_ACTIVE};
-
- # switch out to our own handles
- $t->output($output_handle);
- $t->failure_output($error_handle);
- $t->todo_output($error_handle);
-
- $ENV{HARNESS_ACTIVE} = 0;
-
- # clear the expected list
- $out->reset();
- $err->reset();
-
- # remeber that we're testing
- $testing_num = $t->current_test;
- $t->current_test(0);
-}
-
-# each test test is actually two tests. This is bad and wrong
-# but makes blood come out of my ears if I don't at least simplify
-# it a little this way
-
-sub my_test_test
-{
- my $text = shift;
- local $^W = 0;
-
- # reset the outputs
- $t->output($original_output_handle);
- $t->failure_output($original_failure_handle);
- $t->todo_output($original_todo_handle);
- $ENV{HARNESS_ACTIVE} = $original_harness_env;
-
- # reset the number of tests
- $t->current_test($testing_num);
-
- # check we got the same values
- my $got;
- my $wanted;
-
- # stdout
- $t->ok($out->check, "STDOUT $text");
-
- # stderr
- $t->ok($err->check, "STDERR $text");
-}
-
-####################################################################
-# Meta meta tests
-####################################################################
-
-# this is a quick test to check the hack that I've just implemented
-# actually does a cut down version of Test::Builder::Tester
-
-start_testing();
-$out->expect("ok 1 - foo");
-pass("foo");
-my_test_test("basic meta meta test");
-
-start_testing();
-$out->expect("not ok 1 - foo");
-$err->expect("# Failed test ($0 at line ".line_num(+1).")");
-fail("foo");
-my_test_test("basic meta meta test 2");
-
-start_testing();
-$out->expect("ok 1 - bar");
-test_out("ok 1 - foo");
-pass("foo");
-test_test("bar");
-my_test_test("meta meta test with tbt");
-
-start_testing();
-$out->expect("ok 1 - bar");
-test_out("not ok 1 - foo");
-test_err("# Failed test ($0 at line ".line_num(+1).")");
-fail("foo");
-test_test("bar");
-my_test_test("meta meta test with tbt2 ");
-
-####################################################################
-# Actual meta tests
-####################################################################
-
-# set up the outer wrapper again
-start_testing();
-$out->expect("ok 1 - bar");
-
-# set up what the inner wrapper expects
-test_out("ok 1 - foo");
-
-# the actual test function that we are testing
-ok("1","foo");
-
-# test the name
-test_test(name => "bar");
-
-# check that passed
-my_test_test("meta test name");
-
-####################################################################
-
-# set up the outer wrapper again
-start_testing();
-$out->expect("ok 1 - bar");
-
-# set up what the inner wrapper expects
-test_out("ok 1 - foo");
-
-# the actual test function that we are testing
-ok("1","foo");
-
-# test the name
-test_test(title => "bar");
-
-# check that passed
-my_test_test("meta test title");
-
-####################################################################
-
-# set up the outer wrapper again
-start_testing();
-$out->expect("ok 1 - bar");
-
-# set up what the inner wrapper expects
-test_out("ok 1 - foo");
-
-# the actual test function that we are testing
-ok("1","foo");
-
-# test the name
-test_test(label => "bar");
-
-# check that passed
-my_test_test("meta test title");
-
-####################################################################
-
-# set up the outer wrapper again
-start_testing();
-$out->expect("ok 1 - bar");
-
-# set up what the inner wrapper expects
-test_out("not ok 1 - foo this is wrong");
-test_fail(+3);
-
-# the actual test function that we are testing
-ok("0","foo");
-
-# test that we got what we expect, ignoring our is wrong
-test_test(skip_out => 1, name => "bar");
-
-# check that that passed
-my_test_test("meta test skip_out");
-
-####################################################################
-
-# set up the outer wrapper again
-start_testing();
-$out->expect("ok 1 - bar");
-
-# set up what the inner wrapper expects
-test_out("not ok 1 - foo");
-test_err("this is wrong");
-
-# the actual test function that we are testing
-ok("0","foo");
-
-# test that we got what we expect, ignoring err is wrong
-test_test(skip_err => 1, name => "bar");
-
-# diagnostics failing out
-# check that that passed
-my_test_test("meta test skip_err");
-
-####################################################################
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/thread_taint.t b/gnu/usr.bin/perl/lib/Test/Simple/t/thread_taint.t
index e22e03b2e1b..ef7b89daeff 100755
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/thread_taint.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/thread_taint.t
@@ -1,5 +1,4 @@
#!/usr/bin/perl -w
-# $Id: thread_taint.t,v 1.2 2009/05/16 21:42:57 simon Exp $
use Test::More tests => 1;
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/threads.t b/gnu/usr.bin/perl/lib/Test/Simple/t/threads.t
index 65b7bb360ee..42ba8c269c7 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/threads.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/threads.t
@@ -1,5 +1,4 @@
#!/usr/bin/perl -w
-# $Id$
BEGIN {
if( $ENV{PERL_CORE} ) {
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/todo.t b/gnu/usr.bin/perl/lib/Test/Simple/t/todo.t
index 259a6616081..91861be3cb8 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/todo.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/todo.t
@@ -1,5 +1,4 @@
#!perl -w
-# $Id$
BEGIN {
if( $ENV{PERL_CORE} ) {
@@ -43,7 +42,7 @@ TODO: {
ok( 'this' eq 'that', 'ok' );
- like( 'this', '/that/', 'like' );
+ like( 'this', qr/that/, 'like' );
is( 'this', 'that', 'is' );
isnt( 'this', 'this', 'isnt' );
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/try.t b/gnu/usr.bin/perl/lib/Test/Simple/t/try.t
deleted file mode 100644
index 6e753a44da3..00000000000
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/try.t
+++ /dev/null
@@ -1,35 +0,0 @@
-#!perl -w
-
-BEGIN {
- if( $ENV{PERL_CORE} ) {
- chdir 't';
- @INC = ('../lib', 'lib');
- }
- else {
- unshift @INC, 't/lib';
- }
-}
-
-use strict;
-
-use Test::More 'no_plan';
-
-require Test::Builder;
-my $tb = Test::Builder->new;
-
-local $SIG{__DIE__} = sub { fail("DIE handler called: @_") };
-
-# These should not change;
-local $@ = 42;
-local $! = 23;
-
-is $tb->_try(sub { 2 }), 2;
-is $tb->_try(sub { return '' }), '';
-
-is $tb->_try(sub { die; }), undef;
-
-is_deeply [$tb->_try(sub { die "Foo\n" }, undef)],
- [undef, "Foo\n"];
-
-is $@, 42;
-cmp_ok $!, '==', 23; \ No newline at end of file
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/undef.t b/gnu/usr.bin/perl/lib/Test/Simple/t/undef.t
index b7f1f2cd90b..2e9201c3b47 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/undef.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/undef.t
@@ -1,5 +1,4 @@
#!/usr/bin/perl -w
-# $Id$
BEGIN {
if( $ENV{PERL_CORE} ) {
@@ -12,8 +11,7 @@ BEGIN {
}
use strict;
-use Test::More tests => 20;
-use TieOut;
+use Test::More tests => 21;
BEGIN { $^W = 1; }
@@ -53,7 +51,7 @@ Test::More->builder->is_num(undef, undef, 'is_num()');
Test::More->builder->isnt_num(23, undef, 'isnt_num()');
#line 45
-like( undef, '/.*/', 'undef is like anything' );
+like( undef, qr/.*/, 'undef is like anything' );
warnings_like(qr/Use of uninitialized value.* at $Filename line 45\.\n/);
eq_array( [undef, undef], [undef, 23] );
@@ -80,17 +78,21 @@ warnings_like(qr/Use of uninitialized value.* at cmp_ok \[from $Filename line 64
my $tb = Test::More->builder;
-use TieOut;
-my $caught = tie *CATCH, 'TieOut';
-my $old_fail = $tb->failure_output;
-$tb->failure_output(\*CATCH);
+my $err;
+$tb->failure_output(\$err);
diag(undef);
-$tb->failure_output($old_fail);
+$tb->reset_outputs;
-is( $caught->read, "# undef\n" );
+is( $err, "# undef\n" );
no_warnings;
$tb->maybe_regex(undef);
-is( $caught->read, '' );
no_warnings;
+
+
+# test-more.googlecode.com #42
+{
+ is_deeply([ undef ], [ undef ]);
+ no_warnings;
+}
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/use_ok.t b/gnu/usr.bin/perl/lib/Test/Simple/t/use_ok.t
index a53fe25fe49..4a62f3557e8 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/use_ok.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/use_ok.t
@@ -1,5 +1,4 @@
#!/usr/bin/perl -w
-# $Id$
BEGIN {
if( $ENV{PERL_CORE} ) {
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/useing.t b/gnu/usr.bin/perl/lib/Test/Simple/t/useing.t
index 19dde01b262..c4ce5071270 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/useing.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/useing.t
@@ -1,4 +1,3 @@
-# $Id$
BEGIN {
if( $ENV{PERL_CORE} ) {
chdir 't';
diff --git a/gnu/usr.bin/perl/lib/Test/Simple/t/utf8.t b/gnu/usr.bin/perl/lib/Test/Simple/t/utf8.t
index 8c205ef029f..c7e93c3ac2d 100644
--- a/gnu/usr.bin/perl/lib/Test/Simple/t/utf8.t
+++ b/gnu/usr.bin/perl/lib/Test/Simple/t/utf8.t
@@ -1,5 +1,4 @@
#!/usr/bin/perl -w
-# $Id: utf8.t,v 1.1 2009/05/16 21:42:57 simon Exp $
BEGIN {
if( $ENV{PERL_CORE} ) {
diff --git a/gnu/usr.bin/perl/lib/Test/t/fail.t b/gnu/usr.bin/perl/lib/Test/t/fail.t
index 6be111893d5..9051a1f481e 100644
--- a/gnu/usr.bin/perl/lib/Test/t/fail.t
+++ b/gnu/usr.bin/perl/lib/Test/t/fail.t
@@ -1,72 +1,104 @@
-#!perl -w
+# -*-perl-*-
+use strict;
+use vars qw($Expect);
+use Test qw($TESTOUT $TESTERR $ntest ok skip plan);
+plan tests => 14;
-BEGIN {
- if( $ENV{PERL_CORE} ) {
- chdir 't';
- @INC = ('../lib', 'lib');
- }
- else {
- unshift @INC, 't/lib';
- }
+open F, ">fails";
+$TESTOUT = *F{IO};
+$TESTERR = *F{IO};
+
+my $r=0;
+{
+ # Shut up deprecated usage warning.
+ local $^W = 0;
+ $r |= skip(0,0);
}
+$r |= ok(0);
+$r |= ok(0,1);
+$r |= ok(sub { 1+1 }, 3);
+$r |= ok(sub { 1+1 }, sub { 2 * 0});
-use strict;
+my @list = (0,0);
+$r |= ok @list, 1, "\@list=".join(',',@list);
+$r |= ok @list, 1, sub { "\@list=".join ',',@list };
+$r |= ok 'segmentation fault', '/bongo/';
+
+for (1..2) { $r |= ok(0); }
+
+$r |= ok(1, undef);
+$r |= ok(undef, 1);
+
+ok($r); # (failure==success :-)
+
+close F;
+$TESTOUT = *STDOUT{IO};
+$TESTERR = *STDERR{IO};
+$ntest = 1;
+
+open F, "fails";
+my $O;
+while (<F>) { $O .= $_; }
+close F;
+unlink "fails";
+
+ok join(' ', map { m/(\d+)/; $1 } grep /^not ok/, split /\n+/, $O),
+ join(' ', 1..13);
-require Test::Simple::Catch;
-my($out, $err) = Test::Simple::Catch::caught();
-local $ENV{HARNESS_ACTIVE} = 0;
+my @got = split /not ok \d+\n/, $O;
+shift @got;
+$Expect =~ s/\n+$//;
+my @expect = split /\n\n/, $Expect;
-# Can't use Test.pm, that's a 5.005 thing.
-package My::Test;
-print "1..2\n";
+sub commentless {
+ my $in = $_[0];
+ $in =~ s/^#[^\n]*\n//mg;
+ $in =~ s/\n#[^\n]*$//mg;
+ return $in;
+}
+
-my $test_num = 1;
-# Utility testing functions.
-sub ok ($;$) {
- my($test, $name) = @_;
- my $ok = '';
- $ok .= "not " unless $test;
- $ok .= "ok $test_num";
- $ok .= " - $name" if defined $name;
- $ok .= "\n";
- print $ok;
- $test_num++;
+for (my $x=0; $x < @got; $x++) {
+ ok commentless($got[$x]), commentless($expect[$x]."\n");
}
-package main;
+BEGIN {
+ $Expect = <<"EXPECT";
+# Failed test 1 in $0 at line 15
+
+# Failed test 2 in $0 at line 17
+
+# Test 3 got: '0' ($0 at line 18)
+# Expected: '1'
+
+# Test 4 got: '2' ($0 at line 19)
+# Expected: '3'
+
+# Test 5 got: '2' ($0 at line 20)
+# Expected: '0'
+
+# Test 6 got: '2' ($0 at line 23)
+# Expected: '1' (\@list=0,0)
+
+# Test 7 got: '2' ($0 at line 24)
+# Expected: '1' (\@list=0,0)
+
+# Test 8 got: 'segmentation fault' ($0 at line 25)
+# Expected: qr{bongo}
-require Test::Simple;
-Test::Simple->import(tests => 5);
+# Failed test 9 in $0 at line 27
-#line 35
-ok( 1, 'passing' );
-ok( 2, 'passing still' );
-ok( 3, 'still passing' );
-ok( 0, 'oh no!' );
-ok( 0, 'damnit' );
+# Failed test 10 in $0 at line 27 fail #2
+# Failed test 11 in $0 at line 29
-END {
- My::Test::ok($$out eq <<OUT);
-1..5
-ok 1 - passing
-ok 2 - passing still
-ok 3 - still passing
-not ok 4 - oh no!
-not ok 5 - damnit
-OUT
+# Test 12 got: <UNDEF> ($0 at line 30)
+# Expected: '1'
- My::Test::ok($$err eq <<ERR);
-# Failed test 'oh no!'
-# at $0 line 38.
-# Failed test 'damnit'
-# at $0 line 39.
-# Looks like you failed 2 tests of 5.
-ERR
+# Failed test 13 in $0 at line 32
+EXPECT
- # Prevent Test::Simple from exiting with non zero
- exit 0;
}
diff --git a/gnu/usr.bin/perl/lib/Test/t/skip.t b/gnu/usr.bin/perl/lib/Test/t/skip.t
index b7ec32adbea..a6d1cf4c3cf 100644
--- a/gnu/usr.bin/perl/lib/Test/t/skip.t
+++ b/gnu/usr.bin/perl/lib/Test/t/skip.t
@@ -1,98 +1,43 @@
-#!perl -w
+# -*-perl-*-
+use strict;
+use Test qw($TESTOUT $TESTERR $ntest plan ok skip);
+plan tests => 6;
-BEGIN {
- if( $ENV{PERL_CORE} ) {
- chdir 't';
- @INC = '../lib';
- }
-}
-
-use Test::More tests => 17;
-
-# If we skip with the same name, Test::Harness will report it back and
-# we won't get lots of false bug reports.
-my $Why = "Just testing the skip interface.";
+open F, ">skips" or die "open skips: $!";
+$TESTOUT = *F{IO};
+$TESTERR = *F{IO};
-SKIP: {
- skip $Why, 2
- unless Pigs->can('fly');
+skip(1, 0); #should skip
- my $pig = Pigs->new;
- $pig->takeoff;
+my $skipped=1;
+skip('hop', sub { $skipped = 0 });
+skip(sub {'jump'}, sub { $skipped = 0 });
+skip('skipping stones is more fun', sub { $skipped = 0 });
- ok( $pig->altitude > 0, 'Pig is airborne' );
- ok( $pig->airspeed > 0, ' and moving' );
-}
+close F;
+$TESTOUT = *STDOUT{IO};
+$TESTERR = *STDERR{IO};
+$ntest = 1;
+open F, "skips" or die "open skips: $!";
-SKIP: {
- skip "We're not skipping", 2 if 0;
+ok $skipped, 1, 'not skipped?';
- pass("Inside skip block");
- pass("Another inside");
+my @T = <F>;
+chop @T;
+my @expect = split /\n+/, join('',<DATA>);
+ok @T, 4;
+for (my $x=0; $x < @T; $x++) {
+ ok $T[$x], $expect[$x];
}
+END { close F; unlink "skips" }
-SKIP: {
- skip "Again, not skipping", 2 if 0;
-
- my($pack, $file, $line) = caller;
- is( $pack || '', '', 'calling package not interfered with' );
- is( $file || '', '', ' or file' );
- is( $line || '', '', ' or line' );
-}
+__DATA__
+ok 1 # skip
+ok 2 # skip hop
-SKIP: {
- skip $Why, 2 if 1;
-
- die "A horrible death";
- fail("Deliberate failure");
- fail("And again");
-}
-
-
-{
- my $warning;
- local $SIG{__WARN__} = sub { $warning = join "", @_ };
- SKIP: {
- # perl gets the line number a little wrong on the first
- # statement inside a block.
- 1 == 1;
-#line 56
- skip $Why;
- fail("So very failed");
- }
- is( $warning, "skip() needs to know \$how_many tests are in the ".
- "block at $0 line 56\n",
- 'skip without $how_many warning' );
-}
+ok 3 # skip jump
-
-SKIP: {
- skip "Not skipping here.", 4 if 0;
-
- pass("This is supposed to run");
-
- # Testing out nested skips.
- SKIP: {
- skip $Why, 2;
- fail("AHHH!");
- fail("You're a failure");
- }
-
- pass("This is supposed to run, too");
-}
-
-{
- my $warning = '';
- local $SIG{__WARN__} = sub { $warning .= join "", @_ };
-
- SKIP: {
- skip 1, "This is backwards" if 1;
-
- pass "This does not run";
- }
-
- like $warning, '/^skip\(\) was passed a non-numeric number of tests/';
-}
+ok 4 # skip skipping stones is more fun
diff --git a/gnu/usr.bin/perl/lib/Test/t/todo.t b/gnu/usr.bin/perl/lib/Test/t/todo.t
index 626b63d5221..74f9aefb8b9 100644
--- a/gnu/usr.bin/perl/lib/Test/t/todo.t
+++ b/gnu/usr.bin/perl/lib/Test/t/todo.t
@@ -1,157 +1,55 @@
-#!perl -w
-
-BEGIN {
- if( $ENV{PERL_CORE} ) {
- chdir 't';
- @INC = '../lib';
- }
-}
-
-use Test::More;
-
-plan tests => 36;
-
-
-$Why = 'Just testing the todo interface.';
-
-my $is_todo;
-TODO: {
- local $TODO = $Why;
-
- fail("Expected failure");
- fail("Another expected failure");
-
- $is_todo = Test::More->builder->todo;
-}
-
-pass("This is not todo");
-ok( $is_todo, 'TB->todo' );
-
-
-TODO: {
- local $TODO = $Why;
-
- fail("Yet another failure");
-}
-
-pass("This is still not todo");
-
-
-TODO: {
- local $TODO = "testing that error messages don't leak out of todo";
-
- ok( 'this' eq 'that', 'ok' );
-
- like( 'this', '/that/', 'like' );
- is( 'this', 'that', 'is' );
- isnt( 'this', 'this', 'isnt' );
-
- can_ok('Fooble', 'yarble');
- isa_ok('Fooble', 'yarble');
- use_ok('Fooble');
- require_ok('Fooble');
-}
-
-
-TODO: {
- todo_skip "Just testing todo_skip", 2;
-
- fail("Just testing todo");
- die "todo_skip should prevent this";
- pass("Again");
-}
-
-
-{
- my $warning;
- local $SIG{__WARN__} = sub { $warning = join "", @_ };
- TODO: {
- # perl gets the line number a little wrong on the first
- # statement inside a block.
- 1 == 1;
-#line 74
- todo_skip "Just testing todo_skip";
- fail("So very failed");
- }
- is( $warning, "todo_skip() needs to know \$how_many tests are in the ".
- "block at $0 line 74\n",
- 'todo_skip without $how_many warning' );
-}
-
-my $builder = Test::More->builder;
-my $exported_to = $builder->exported_to;
-TODO: {
- $builder->exported_to("Wibble");
-
- local $TODO = "testing \$TODO with an incorrect exported_to()";
-
- fail("Just testing todo");
-}
-
-$builder->exported_to($exported_to);
-
-$builder->todo_start('Expected failures');
-fail('Testing todo_start()');
-ok 0, 'Testing todo_start() with more than one failure';
-$is_todo = $builder->todo;
-$builder->todo_end;
-is $is_todo, 'Expected failures',
- 'todo_start should have the correct TODO message';
-ok 1, 'todo_end() should not leak TODO behavior';
-
-my @nested_todo;
-my ( $level1, $level2 ) = ( 'failure level 1', 'failure_level 2' );
-TODO: {
- local $TODO = 'Nesting TODO';
- fail('fail 1');
-
- $builder->todo_start($level1);
- fail('fail 2');
-
- push @nested_todo => $builder->todo;
- $builder->todo_start($level2);
- fail('fail 3');
-
- push @nested_todo => $builder->todo;
- $builder->todo_end;
- fail('fail 4');
-
- push @nested_todo => $builder->todo;
- $builder->todo_end;
- $is_todo = $builder->todo;
- fail('fail 4');
-}
-is_deeply \@nested_todo, [ $level1, $level2, $level1 ],
- 'Nested TODO message should be correct';
-is $is_todo, 'Nesting TODO',
- '... and original TODO message should be correct';
-
-{
- $builder->todo_start;
- fail("testing todo_start() with no message");
- my $reason = $builder->todo;
- my $in_todo = $builder->in_todo;
- $builder->todo_end;
-
- is $reason, '', " todo() reports no reason";
- ok $in_todo, " but we're in_todo()";
-}
-
-eval {
- $builder->todo_end;
-};
-is $@, sprintf "todo_end() called without todo_start() at %s line %d.\n", $0, __LINE__ - 2;
-
-
-{
- my($reason, $in_todo);
-
- TODO: {
- local $TODO = '';
- $reason = $builder->todo;
- $in_todo = $builder->in_todo;
- }
-
- is $reason, '';
- ok !$in_todo, '$TODO = "" is not considered TODO';
-}
+# -*-perl-*-
+use strict;
+use Test qw(:DEFAULT $TESTOUT $TESTERR $ntest);
+
+### This test is crafted in such a way as to prevent Test::Harness from
+### seeing the todo tests, otherwise you get people sending in bug reports
+### about Test.pm having "UNEXPECTEDLY SUCCEEDED" tests.
+
+open F, ">todo";
+$TESTOUT = *F{IO};
+$TESTERR = *F{IO};
+my $tests = 5;
+plan tests => $tests, todo => [2..$tests];
+
+
+# tests to go to the output file
+ok(1);
+ok(1);
+ok(0,1);
+ok(0,1,"need more tuits");
+ok(1,1);
+
+close F;
+$TESTOUT = *STDOUT{IO};
+$TESTERR = *STDERR{IO};
+$ntest = 1;
+
+open F, "todo";
+my $out = join '', <F>;
+close F;
+unlink "todo";
+
+my $expect = <<"EXPECT";
+1..5 todo 2 3 4 5;
+ok 1
+ok 2 # ($0 at line 18 TODO?!)
+not ok 3
+# Test 3 got: '0' ($0 at line 19 *TODO*)
+# Expected: '1'
+not ok 4
+# Test 4 got: '0' ($0 at line 20 *TODO*)
+# Expected: '1' (need more tuits)
+ok 5 # ($0 at line 21 TODO?!)
+EXPECT
+
+
+sub commentless {
+ my $in = $_[0];
+ $in =~ s/^#[^\n]*\n//mg;
+ $in =~ s/\n#[^\n]*$//mg;
+ return $in;
+}
+
+print "1..1\n";
+ok( commentless($out), commentless($expect) );