summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael G. Schwern <schwern@pobox.com>2001-07-20 16:22:35 -0400
committerJarkko Hietaniemi <jhi@iki.fi>2001-07-22 14:54:29 +0000
commitedd5bad5e1e973c1d7eba87bcecdd2cea187918e (patch)
treef3461f752b9e250b8f2646a41c635421ad2e1941
parente378c047dd913f3f75f4b040edf9593573737085 (diff)
downloadperl-edd5bad5e1e973c1d7eba87bcecdd2cea187918e.tar.gz
Getting rid of the expected "UNEXPECTEDLY SUCCEEDED"
Message-ID: <20010720202235.O4498@blackrider> p4raw-id: //depot/perl@11441
-rw-r--r--lib/Test.pm7
-rw-r--r--lib/Test/t/mix.t35
-rw-r--r--lib/Test/t/success.t2
-rw-r--r--lib/Test/t/todo.t45
4 files changed, 79 insertions, 10 deletions
diff --git a/lib/Test.pm b/lib/Test.pm
index 77728bc323..dcc5f68698 100644
--- a/lib/Test.pm
+++ b/lib/Test.pm
@@ -9,7 +9,7 @@ use vars (qw($VERSION @ISA @EXPORT @EXPORT_OK $ntest $TestLevel), #public-ish
qw($TESTOUT $ONFAIL %todo %history $planned @FAILDETAIL)#private-ish
);
-$VERSION = '1.17_00';
+$VERSION = '1.18';
require Exporter;
@ISA=('Exporter');
@@ -64,6 +64,9 @@ Test - provides a simple framework for writing test scripts
=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::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
diff --git a/lib/Test/t/mix.t b/lib/Test/t/mix.t
index d911689845..d2dd491330 100644
--- a/lib/Test/t/mix.t
+++ b/lib/Test/t/mix.t
@@ -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(0);
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 --git a/lib/Test/t/success.t b/lib/Test/t/success.t
index a580f0a567..6a090bc59a 100644
--- a/lib/Test/t/success.t
+++ b/lib/Test/t/success.t
@@ -5,7 +5,7 @@ BEGIN { plan tests => 11 }
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,');
diff --git a/lib/Test/t/todo.t b/lib/Test/t/todo.t
index ae02a04f6b..510e80dbd3 100644
--- a/lib/Test/t/todo.t
+++ b/lib/Test/t/todo.t
@@ -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 );