Nicholas Clark via RT wrote: > 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. > > multi-sub?
skip string skip int, string Sam. > Nicholas Clark > > >
>From fe91f8e4469a56285254424e7c408dfc7e13241e Mon Sep 17 00:00:00 2001 From: Sam Vilain <[EMAIL PROTECTED]> Date: Wed, 14 Feb 2007 01:27:23 +1300 Subject: [PATCH] [t/pmc] convert multisub test to PIR --- t/pmc/multisub.pir.t | 47 +++++++++++++++++++++++++++++++++++++++++++++++ t/pmc/multisub.t | 42 ------------------------------------------ 2 files changed, 47 insertions(+), 42 deletions(-) create mode 100644 t/pmc/multisub.pir.t delete mode 100644 t/pmc/multisub.t diff --git a/t/pmc/multisub.pir.t b/t/pmc/multisub.pir.t new file mode 100644 index 0000000..3c73408 --- /dev/null +++ b/t/pmc/multisub.pir.t @@ -0,0 +1,47 @@ +#! parrot +# Copyright (C) 2001-2007, The Perl Foundation. +# $Id$ + +.macro IMPORT ( lib, subname, TEMP ) + .TEMP = find_global .lib, .subname + store_global .subname, .TEMP +.endm + +.sub main + load_bytecode 'library/Test/More.pir' + + .local pmc _ + .IMPORT( 'Test::More', 'plan', _ ) + .IMPORT( 'Test::More', 'ok', _ ) + .IMPORT( 'Test::More', 'is', _ ) + + plan( 2 ) + +=head1 NAME + +t/pmc/multisub.t - Multi Sub PMCs + +=head1 SYNOPSIS + + % prove t/pmc/multisub.t + +=head1 DESCRIPTION + +Tests the creation and invocation of Perl6 multi subs. + +=cut + + new P0, .MultiSub + I0 = defined P0 + ok(I0, "create PMC") + + elements I0, P0 + is(I0, 0, "multisubs start empty") + +.end + +# Local Variables: +# mode: pir +# fill-column: 70 +# End: +# vim: expandtab shiftwidth=4: diff --git a/t/pmc/multisub.t b/t/pmc/multisub.t deleted file mode 100644 index 24a9844..0000000 --- a/t/pmc/multisub.t +++ /dev/null @@ -1,42 +0,0 @@ -#! perl -# Copyright (C) 2001-2005, The Perl Foundation. -# $Id$ - -use strict; -use warnings; -use lib qw( . lib ../lib ../../lib ); -use Test::More; -use Parrot::Test tests => 1; - -=head1 NAME - -t/pmc/multisub.t - Multi Sub PMCs - -=head1 SYNOPSIS - - % prove t/pmc/multisub.t - -=head1 DESCRIPTION - -Tests the creation and invocation of Perl6 multi subs. - -=cut - -pasm_output_is( <<'CODE', <<'OUTPUT', "create PMC" ); - new P0, .MultiSub - print "ok 1\n" - elements I0, P0 - print I0 - print "\n" - end -CODE -ok 1 -0 -OUTPUT - -# Local Variables: -# mode: cperl -# cperl-indent-level: 4 -# fill-column: 100 -# End: -# vim: expandtab shiftwidth=4: -- 1.5.0.rc3.g3e023
>From 271801a9d4a3cbe7bd66418dd09be934d4b6f7ef Mon Sep 17 00:00:00 2001 From: Sam Vilain <[EMAIL PROTECTED]> Date: Wed, 14 Feb 2007 02:54:09 +1300 Subject: [PATCH] [t/pmc] add a multisub test Guessing from the code, it looks like it is designed to have Sub objects pushed onto it. --- t/pmc/multisub.pir.t | 67 ++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 60 insertions(+), 7 deletions(-) diff --git a/t/pmc/multisub.pir.t b/t/pmc/multisub.pir.t index 3c73408..7b42410 100644 --- a/t/pmc/multisub.pir.t +++ b/t/pmc/multisub.pir.t @@ -7,15 +7,33 @@ store_global .subname, .TEMP .endm -.sub main +.sub skipone + .param string why + $S0 = "mmd - S - " . why + .return($S0) +.end + +.sub skipn + .param int i + .param string why + $S1 = i + $S0 = "mmd - IS - x" . $S1 + $S0 = $S0 . " - " + $S0 = $S0 . why + .return($S0) +.end + +.sub main :main load_bytecode 'library/Test/More.pir' .local pmc _ .IMPORT( 'Test::More', 'plan', _ ) .IMPORT( 'Test::More', 'ok', _ ) .IMPORT( 'Test::More', 'is', _ ) + $P0 = find_global 'Test::More', 'skip' + store_global '_skip', $P0 - plan( 2 ) + plan( 5 ) =head1 NAME @@ -31,12 +49,47 @@ Tests the creation and invocation of Perl6 multi subs. =cut - new P0, .MultiSub - I0 = defined P0 - ok(I0, "create PMC") + $P0 = new .MultiSub + $I0 = defined $P0 + ok($I0, "create PMC") + + $I0 = elements $P0 + is($I0, 0, "multisubs start empty") + + #push $P0, skipone + $P1 = find_global "skipone" + push $P0, $P1 + + #push $P0, skipn + $P1 = find_global "skipn" + push $P0, $P1 + + $I0 = elements $P0 + is($I0, 2, "multisubs can be pushed onto") + + # need to make an object that is a new .Sub and a .NCI + store_global "skip", $P0 + + $I0 = 2 + push_eh skipit + goto begin + +skipit: + _skip("mmd exception") + dec $I0 + if $I0 goto skipit + goto done + +begin: + + S0 = 'skip'("yo") + is(S0, "mmd - S - yo", "dispatch to single arg sub") + dec $I0 + + S0 = 'skip'(2, "ho") + is(S0, "mmd - S - x2 - ho", "dispatch to two arg sub") - elements I0, P0 - is(I0, 0, "multisubs start empty") +done: .end -- 1.5.0.rc3.g3e023