develooper Front page | perl.perl5.porters | Postings from January 2001

Re: [PATCH Test.pm 1.14] (was Re: Unifying 'skip' and 'todo' test output)

Thread Previous | Thread Next
From:
Michael G Schwern
Date:
January 18, 2001 13:49
Subject:
Re: [PATCH Test.pm 1.14] (was Re: Unifying 'skip' and 'todo' test output)
Message ID:
20010118164847.E14460@blackrider.aocn.com
On Thu, Jan 18, 2001 at 11:24:32AM +0100, H.Merijn Brand wrote:
> On Thu, 18 Jan 2001 00:16:03 -0600, Michael G Schwern <schwern@pobox.com> wrote:
> > +        $whyskip =~ s/^skip//i;  # backwards compatibility, old versions
> 
>            $whyskip =~ s/^skip\s*//i;

Actually, that should be:

        $whyskip =~ s/^[Ss]kip(?:\s+|$)//;

(Thanks for the catch, though.)

So

        # ok 23 # skip because its Tuesday
        skip('skip because its Tuesday');

        # ok 23 # skip skipping stones is more fun
        skip('skipping stones is more fun');

        # ok 23 # skip
        skip('skip');

Let me resubmit that patch, along with a test for it.


--- lib/Test.pm	2001/01/18 01:27:22
+++ lib/Test.pm	2001/01/18 21:43:24
@@ -122,8 +122,13 @@
 sub skip ($$;$$) {
     my $whyskip = to_value(shift);
     if ($whyskip) {
-	$whyskip = 'skip' if $whyskip =~ m/^\d+$/;
-	print $TESTOUT "ok $ntest # $whyskip\n";
+	$whyskip = '' if $whyskip =~ m/^\d+$/;
+        $whyskip =~ s/^[Ss]kip(?:\s+|$)//;  # backwards compatibility, old 
+                                            # versions required the reason to 
+                                            # start with 'skip'
+	print $TESTOUT "ok $ntest # skip";
+        print $TESTOUT " $whyskip" if length $whyskip;
+        print $TESTOUT "\n";
 	++ $ntest;
 	1;
     } else {
--- t/skip.t	2001/01/18 06:11:52	1.1
+++ t/skip.t	2001/01/18 21:46:57
@@ -1,6 +1,6 @@
 # -*-perl-*-
 use strict;
-use Test qw($TESTOUT $ntest plan ok skip); plan tests => 5;
+use Test qw($TESTOUT $ntest plan ok skip); plan tests => 6;
 
 open F, ">skips" or die "open skips: $!";
 $TESTOUT = *F{IO};
@@ -10,6 +10,7 @@
 my $skipped=1;
 skip('hop', sub { $skipped = 0 });
 skip(sub {'jump'}, sub { $skipped = 0 });
+skip('skipping stones is more fun', sub { $skipped = 0 });
 
 close F;
 
@@ -22,7 +23,7 @@
 my @T = <F>;
 chop @T;
 my @expect = split /\n+/, join('',<DATA>);
-ok @T, 3;
+ok @T, 4;
 for (my $x=0; $x < @T; $x++) {
     ok $T[$x], $expect[$x];
 }
@@ -32,6 +33,8 @@
 __DATA__
 ok 1 # skip
 
-ok 2 # hop
+ok 2 # skip hop
 
-ok 3 # jump
+ok 3 # skip jump
+
+ok 4 # skip skipping stones is more fun


-- 

Michael G. Schwern   <schwern@pobox.com>    http://www.pobox.com/~schwern/
"what am I supposed
 to be doing at this page?"
 bend over, sonny.
	 -- stimps

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About