develooper Front page | | Postings from June 2016

Re: Writing our own modules in Test2

Thread Previous | Thread Next
Andy Lester
June 27, 2016 14:35
Re: Writing our own modules in Test2
Message ID:

> On Jun 24, 2016, at 4:41 PM, Buddy Burden <> wrote:
>    is_true($val);
>    is_false($val);
> Because with just `ok($val)` you can tell whether it's true or false, but, when it inevitably fails, you really want to know what the bad value turned out to be.

I have a bool_eq() so you can do this:

bool_eq( $want_foos, scalar @foos );

without having to do

if ( $want_foos ) {
    ok( scalar @foos );
else {
    is( scalar @foos, 0 );

We were also writing that as

is( !!$want_foos, !!(scalar @foos) );

which works, but obscures the meaning.

I don’t like the name bool_eq() (“booleans are equal”) but it was the best I could come up with.

Andy Lester =>

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About