From: Michael G. Schwern Date: Fri, 20 Jul 2001 20:22:35 +0000 (-0400) Subject: Getting rid of the expected "UNEXPECTEDLY SUCCEEDED" X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=edd5bad5e1e973c1d7eba87bcecdd2cea187918e;p=p5sagit%2Fp5-mst-13.2.git Getting rid of the expected "UNEXPECTEDLY SUCCEEDED" Message-ID: <20010720202235.O4498@blackrider> p4raw-id: //depot/perl@11441 --- diff --git a/lib/Test.pm b/lib/Test.pm index 77728bc..dcc5f68 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 If you are writing a new test, we I you use +the new Test::Simple and Test::More modules instead. + L 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, L, L, L L is an interesting alternative testing library. +L and L let you embed tests in code. + =head1 AUTHOR diff --git a/lib/Test/t/mix.t b/lib/Test/t/mix.t index d911689..d2dd491 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 '', ; +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 a580f0a..6a090bc 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 ae02a04..510e80d 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 '', ; +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 );