Front page | perl.perl5.porters |
Postings from July 2001
[PATCH Test.pm] Getting rid of the expected "UNEXPECTEDLY SUCCEEDED"
From:
Michael G Schwern
Date:
July 20, 2001 17:22
Subject:
[PATCH Test.pm] Getting rid of the expected "UNEXPECTEDLY SUCCEEDED"
Message ID:
20010720202235.O4498@blackrider
Yay! This patch syncs up bleadperl's Test.pm with the newly released
version 1.18. The important thing is the modification to the tests
which FINALLY shut up the "3 tests UNEXPECTEDLY SUCCEEDED" output.
The cool thing is this makes todo tests useful again, so we can start
adding them for bug reports. Test::More will be upgraded shortly to
support skip and todo tests.
2001-07-20 Michael G Schwern <schwern@pobox.com>
* Release 1.18
* Now recommending Test::Simple/More in the docs
* Removed warning about skip interface, it was a mistake
- added mention of Pod::Tests and SelfTest
- Test's tests no longer report "UNEXPECTEDLY SUCCEEDED"
--- lib/Test.pm Sat Jun 30 13:04:41 2001
+++ /home/schwern/src/devel/Test/lib/Test.pm Fri Jul 20 19:49:02 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 :-).
@@ -435,6 +438,8 @@
L<Test::Simple>, L<Test::More>, L<Test::Harness>, L<Devel::Cover>
L<Test::Unit> is an interesting alternative testing library.
+
+L<Pod::Tests> and L<SelfTest> let you embed tests in code.
=head1 AUTHOR
Only in /home/schwern/src/devel/Test/t/: CVS
diff -u lib/Test/t/mix.t /home/schwern/src/devel/Test/t/mix.t
--- lib/Test/t/mix.t Mon Jun 18 01:21:16 2001
+++ /home/schwern/src/devel/Test/t/mix.t Fri Jul 20 19:46:35 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 );
diff -u lib/Test/t/todo.t /home/schwern/src/devel/Test/t/todo.t
--- lib/Test/t/todo.t Mon Jun 18 01:21:16 2001
+++ /home/schwern/src/devel/Test/t/todo.t Fri Jul 20 17:01:44 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);
-ok(0);
+### 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];
+
+# 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 );
--- lib/Test/t/success.t 2 Mar 2001 04:58:57 -0000 1.1.1.1
+++ lib/Test/t/success.t 21 Jul 2001 00:15:51 -0000
@@ -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,');
--
Michael G. Schwern <schwern@pobox.com> http://www.pobox.com/~schwern/
Perl6 Quality Assurance <perl-qa@perl.org> Kwalitee Is Job One
"what am I supposed
to be doing at this page?"
bend over, sonny.
-- stimps
-
[PATCH Test.pm] Getting rid of the expected "UNEXPECTEDLY SUCCEEDED"
by Michael G Schwern