Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[perl #41478] [PATCH] add Test::More::skip()

6 views
Skip to first unread message

Sam Vilain

unread,
Feb 10, 2007, 2:54:41 AM2/10/07
to bugs-bi...@rt.perl.org
# New Ticket Created by Sam Vilain
# Please include the string: [perl #41478]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=41478 >


Test::More.skip() was missing; add it
---
runtime/parrot/library/Test/More.pir | 27 +++++++++++++++++++++++++++
t/library/test_more.t | 12 +++++++++++-
2 files changed, 38 insertions(+), 1 deletions(-)

diff --git a/runtime/parrot/library/Test/More.pir b/runtime/parrot/library/Test/More.pir
index ac5f440..b972d0e 100644
--- a/runtime/parrot/library/Test/More.pir
+++ b/runtime/parrot/library/Test/More.pir
@@ -737,6 +737,33 @@ optional test description in C<description>.
done:
.end

+=item C<skip( why, how_many )>
+
+Pass a number of tests, but with a comment that marks the test was
+actually skipped. Arguments are are optional.
+
+Note that the arguments are in reverse compared to
+C<Test::Builder.test>. They are in the order of the Perl5 Test::More
+module.
+
+=cut
+
+.sub skip
+ .param string description :optional
+ .param int has_description :opt_flag
+ .param int how_many :optional
+ .param int has_how_many :opt_flag
+
+ $I0 = how_many
+ if has_how_many goto just_say_it
+ $I0 = 1
+just_say_it:
+
+ .local pmc test
+ find_global test, 'Test::More', '_test'
+ test.'skip'($I0, description)
+.end
+
.sub _make_diagnostic
.param string received
.param string expected
diff --git a/t/library/test_more.t b/t/library/test_more.t
index 9f548e0..f9a6044 100644
--- a/t/library/test_more.t
+++ b/t/library/test_more.t
@@ -23,6 +23,7 @@
.IMPORT( 'Test::More', 'is' )
.IMPORT( 'Test::More', 'diag' )
.IMPORT( 'Test::More', 'like' )
+ .IMPORT( 'Test::More', 'skip' )
.IMPORT( 'Test::More', 'is_deeply' )
.IMPORT( 'Test::Builder::Tester', 'plan' )
.IMPORT( 'Test::Builder::Tester', 'test_out' )
@@ -31,7 +32,7 @@
.IMPORT( 'Test::Builder::Tester', 'test_pass' )
.IMPORT( 'Test::Builder::Tester', 'test_test' )

- plan( 43 )
+ plan( 45 )
test_ok()
test_is()
test_like()
@@ -341,4 +342,13 @@
test_out( 'ok 44 #skip skipping' )
test.'skip'( 2, 'skipping' )
test_test( 'skip test should pass' )
+
+ test_out( 'ok 45 #skip jumping' )
+ skip( "jumping" )
+ test_test( 'skip(string)' )
+
+ test_out( 'ok 46 #skip lunch' )
+ test_out( 'ok 47 #skip lunch' )
+ skip( "lunch", 2 )
+ test_test( 'skip(string, int)' )
.end
--
1.4.4.1.gc070

Allison Randal

unread,
Feb 13, 2007, 4:44:01 AM2/13/07
to perl6-i...@perl.org
Why the reversed order of arguments from Test::Builder.skip? It seems that:

skip(5, 'lengthy message about reasoning')

is more readable than:

skip('lengthy message about reasoning', 5)

Is the assumption that skipping a single test with a message is more
common than skipping a number of tests without a message?

skip('lengthy message about reasoning')
vs.
skip(5)

Could you tweak your git options to produce patches as attached files?
(Is there a .gitrc file or something to set defaults for a particular
repository?)

Allison

Nicholas Clark

unread,
Feb 13, 2007, 5:22:49 AM2/13/07
to Allison Randal, perl6-i...@perl.org
On Tue, Feb 13, 2007 at 11:44:01AM +0200, Allison Randal wrote:
> Why the reversed order of arguments from Test::Builder.skip?

Well, it's not reversed from Perl 5's Test::Builder

=item B<SKIP: BLOCK>

SKIP: {
skip $why, $how_many if $condition;

...normal testing code goes here...
}


> It seems that:
> skip(5, 'lengthy message about reasoning')
>
> is more readable than:
>
> skip('lengthy message about reasoning', 5)

I agree. I believe that I've made this mistake before in writing tests in
Perl 5.

> Is the assumption that skipping a single test with a message is more
> common than skipping a number of tests without a message?

This is my guess too. Probably need to as Schwern to find out the original
(Perl 5) reason.

Nicholas Clark

Sam Vilain

unread,
Feb 13, 2007, 9:25:40 AM2/13/07
to parrotbug...@parrotcode.org
multi-sub?

skip string
skip int, string

Sam.


> Nicholas Clark
>
>
>

0001-t-pmc-convert-multisub-test-to-PIR.patch
0002-t-pmc-add-a-multisub-test.patch

Chromatic

unread,
Feb 13, 2007, 12:28:41 PM2/13/07
to perl6-i...@perl.org, Sam Vilain, parrotbug...@parrotcode.org
On Tuesday 13 February 2007 06:25, Sam Vilain wrote:

> >> Why the reversed order of arguments from Test::Builder.skip?

> multi-sub?
>
> skip string
> skip int, string

Seems appropriate to me. Now if the former were a curried version of the
latter, installed as a multi....

-- c

Allison Randal

unread,
Feb 15, 2007, 9:32:44 AM2/15/07
to Sam Vilain, parrotbug...@parrotcode.org
Sam Vilain wrote:
> multi-sub?
>
> skip string
> skip int, string

I just committed (r17010) a version of the original patch, shifted over
to a multisub.

Allison

0 new messages