Andy,

I’ve accumulated a number of test functions in our work codebase for
doing what I call “expressive” tests to avoid common cut & paste.  I’m
using the term “expressive” for now because they’re expressing what it
is you want, rather than making you write the code that explains them.

Sounds good.  I would definitely use such a module.

is_empty_array( $foo );
is_nonempty_array( $foo );

because I believe that it’s easier to read the English “is empty array”
than to translate “is( scalar @{$foo}, 0 )” into that meaning.

*Plus* it gives you an opportunity to display better diagnostics. E.g. "okay, test failed, so the array's not _empty_ ... but what the hell is in it?" This is exactly why I 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.

Anywho, things like this are, as you say, simple to write, but valuable in several different ways.


                -- Buddy

Reply via email to