[Pdx-pm] Test::Builder calling convention
benh
ben.hengst at gmail.com
Fri Mar 13 12:52:21 PDT 2009
+1
On Fri, Mar 13, 2009 at 12:08 PM, Hans Dieter Pearcey
<hdp.perl.pm.pdx at weftsoar.net> wrote:
> On Fri, Mar 13, 2009 at 11:51:04AM -0700, Michael G Schwern wrote:
>> As always, +1 and -1s appreciated.
>
> +1
>
>> PS At PDX.pm we talked about an or() method which would do this:
>>
>> $builder->ok( open my $fh, $file )
>> ->diag( "Errno: $!" )
>> ->or
>> ->is( $!, ENOBACON )
>> ->name( "Insufficient bacon" );
>>
>> Its a short circuit method. If the result is true, it returns a null object
>> that does nothing. If it's false, it chains the result through and the
>> following is() starts a new result object. Trouble is, I can't remember what
>> it bought us over a regular or operator.
>>
>> $builder->ok( open my $fh, $file )
>> ->diag( "Errno: $!" )
>> or
>> $builder->is( $!, ENOBACON )
>> ->name( "Insufficient bacon" );
>>
>> That would appear to be perfectly sufficient, understandable to all and you
>> get real short circuiting, not calling empty methods on an empty object.
>
> It seems weird to me that diag() in your second example is returning whether or
> not the test passed.
>
> The whole example is a little contrived, though. Do you really want to run a
> second test based on whether the first passed? It's hard to consider this
> syntax without a real use case.
I would think that it should at least be an option. SKIP, as an idea,
is already a dependant test, so would it be that bad to allow a multi
level setup?
>
> hdp.
> _______________________________________________
> Pdx-pm-list mailing list
> Pdx-pm-list at pm.org
> http://mail.pm.org/mailman/listinfo/pdx-pm-list
>
--
benh~
http://three.sentenc.es/
More information about the Pdx-pm-list
mailing list