On Tuesday 30 June 2009 21:44:50 Michael Peters wrote:
> Ovid wrote:
> >     use Test::Fluent 'no_plan';
> >
> >     my ( $have, $want ) = ( 1, 1 );
> >     have $have, want $want, reason 'Some test name';
> >     have [ 3, 4 ], want [ 4, 5 ], reason 'cuz I said so';   # fails
> >     true 3,  reason '3 had better be true';
> >     false 3, reason '3 had better still better be true';    # fails
>
> I would much rather see something like
>
> cmp_ok(
>    have       => 1,
>    want       => 2,
>    reason     => 'Some test name',
>    diagnostic => { world => $world },
> );
>
> Much more Perlish. I've always disliked some APIs where it's not
> immediately clear what's a function call and what's an argument to that
> function: is reason() an argument to want() or have()?. It also seems more
> obvious for doing things like data-driven tests where you just have a large
> data structure that tests are run against.

I tend to agree with this. However, for my subroutines, I prefer to pass named 
arguments in a hash-ref, instead of clobbered into @_. So "mysub({%args})", 
and "my $args = shift;" rather than "mysub(%args)" and "my %args = shift;".

In any case, in my opinion, your proposal for syntax is saner than Ovid's 
proposed DSL.

Regards,

        Shlomi Fish

-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
http://www.shlomifish.org/humour/ways_to_do_it.html

God gave us two eyes and ten fingers so we will type five times as much as we
read.

Reply via email to