Change 11441 by jhi@alpha on 2001/07/22 14:54:29
Subject: [PATCH Test.pm] Getting rid of the expected "UNEXPECTEDLY SUCCEEDED"
From: Michael G Schwern <[EMAIL PROTECTED]>
Date: Fri, 20 Jul 2001 20:22:35 -0400
Message-ID: <20010720202235.O4498@blackrider>
Affected files ...
... //depot/perl/lib/Test.pm#18 edit
... //depot/perl/lib/Test/t/mix.t#2 edit
... //depot/perl/lib/Test/t/success.t#2 edit
... //depot/perl/lib/Test/t/todo.t#2 edit
Differences ...
==== //depot/perl/lib/Test.pm#18 (text) ====
Index: perl/lib/Test.pm
--- perl/lib/Test.pm.~1~ Sun Jul 22 09:00:06 2001
+++ perl/lib/Test.pm Sun Jul 22 09:00:06 2001
@@ -9,7 +9,7 @@
qw($TESTOUT $ONFAIL %todo %history $planned @FAILDETAIL)#private-ish
);
-$VERSION = '1.17_00';
+$VERSION = '1.18';
require Exporter;
@ISA=('Exporter');
@@ -64,6 +64,9 @@
=head1 DESCRIPTION
+B<STOP!> If you are writing a new test, we I<highly suggest> you use
+the new Test::Simple and Test::More modules instead.
+
L<Test::Harness|Test::Harness> expects to see particular output when it
executes tests. This module aims to make writing proper test scripts just
a little bit easier (and less error prone :-).
@@ -436,6 +439,8 @@
L<Test::Unit> is an interesting alternative testing library.
+L<Pod::Tests> and L<SelfTest> let you embed tests in code.
+
=head1 AUTHOR
==== //depot/perl/lib/Test/t/mix.t#2 (text) ====
Index: perl/lib/Test/t/mix.t
--- perl/lib/Test/t/mix.t.~1~ Sun Jul 22 09:00:06 2001
+++ perl/lib/Test/t/mix.t Sun Jul 22 09:00:06 2001
@@ -1,8 +1,17 @@
# -*-perl-*-
use strict;
-use Test;
-BEGIN { plan tests => 4, todo => [2,3] }
+use Test qw(:DEFAULT $TESTOUT $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, ">mix";
+$TESTOUT = *F{IO};
+
+plan tests => 4, todo => [2,3];
+# line 15
ok(sub {
my $r = 0;
for (my $x=0; $x < 10; $x++) {
@@ -15,3 +24,25 @@
ok(1);
skip(1,0);
+
+close F;
+$TESTOUT = *STDOUT{IO};
+$ntest = 1;
+
+open F, "mix";
+my $out = join '', <F>;
+close F;
+unlink "mix";
+
+my $expect = <<"EXPECT";
+1..4 todo 2 3;
+ok 1
+not ok 2
+# Failed test 2 in $0 at line 23 *TODO*
+ok 3 # ($0 at line 24 TODO?!)
+ok 4 # skip
+EXPECT
+
+
+print "1..1\n";
+ok( $out, $expect );
==== //depot/perl/lib/Test/t/success.t#2 (text) ====
Index: perl/lib/Test/t/success.t
--- perl/lib/Test/t/success.t.~1~ Sun Jul 22 09:00:06 2001
+++ perl/lib/Test/t/success.t Sun Jul 22 09:00:06 2001
@@ -5,7 +5,7 @@
ok(ok(1));
ok(ok('fixed', 'fixed'));
-ok(skip(1,0));
+ok(skip("just testing skip()",0));
ok(undef, undef);
ok(ok 'the brown fox jumped over the lazy dog', '/lazy/');
ok(ok 'the brown fox jumped over the lazy dog', 'm,fox,');
==== //depot/perl/lib/Test/t/todo.t#2 (text) ====
Index: perl/lib/Test/t/todo.t
--- perl/lib/Test/t/todo.t.~1~ Sun Jul 22 09:00:06 2001
+++ perl/lib/Test/t/todo.t Sun Jul 22 09:00:06 2001
@@ -1,13 +1,46 @@
# -*-perl-*-
use strict;
-use Test;
-BEGIN {
- my $tests = 5;
- plan tests => $tests, todo => [1..$tests];
-}
+use Test qw(:DEFAULT $TESTOUT $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};
+
+my $tests = 5;
+plan tests => $tests, todo => [2..$tests];
-ok(0);
+# line 11
+ok(1);
ok(1);
ok(0,1);
ok(0,1,"need more tuits");
ok(1,1);
+
+close F;
+$TESTOUT = *STDOUT{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 12 TODO?!)
+not ok 3
+# Test 3 got: '0' ($0 at line 13 *TODO*)
+# Expected: '1'
+not ok 4
+# Test 4 got: '0' ($0 at line 14 *TODO*)
+# Expected: '1' (need more tuits)
+ok 5 # ($0 at line 15 TODO?!)
+EXPECT
+
+
+print "1..1\n";
+ok( $out, $expect );
End of Patch.