Hello!

I'm writing in nearly every Perl test script a method
all_ok, all_dies_ok or all_throws_ok new.

That's why I want to write a module specialled in 
testing one feature for many parameters.
As I'm very interested in your opinion about,
I'll describe some planned features in the following.

I want to name it Test::ManyParams
but I'm not a very creative man,
perhaps anybody has even a better idea :-)


E.g. let's assume, I would rewrite an Image module.

One of the first tests is to create a new one,
and I would like to be sure that it is empty,
what I prefer to write as:

my $img = Image->new(width => $width, height => $height);
all_ok {$img->color(@_) == 0}
       [ [0 .. $height-1], [0 .. $width-1] ],
       "Image should be empty after initialization";

what would print in the case of a failure something like
not ok XX - ....
# Parameters (0, 3)

Another example is to test for wrong paramters,
where I suppose the subroutine to die.

use constant WRONG_PARAMETERS => (
   -1,   # can't scale negative
   "double",   # well, a feature of the future, let's say 2.0 at the time
   undef,
   [],    # no array ref
   {},    # no hash ref
   "2x",  # still write it as 2.0
);
all_dies_ok {$img->scale($_)}
            [WRONG_PARAMETERS],
            "should die with wrong parameters"
       

Perhaps, I'm too paranoid in these examples,
but I'm sure, it would be useful to have a module
specialled in testing one feature for many parameters.


Thinking in general,
there could be also some other features included.
Let's think we'd like to test the creation of big pictures,
perhaps 5_000 x 5_000.
It could take a while to make a test for all pixels,
but we also would like to test some of them (randomly choosen),
to avoid systematic error.
That could be nice written as:

$img->fill(BLUE);   # my transformation to test
most_ok {$img->color(@_) == BLUE}
        [ [0 .. 5_000], [0 .. 5_000] ] => 1_000,
        "after filling with blue it should be blue - hick";

Well, I'm not sure about the name most_ok,
perhaps you have a better idea.
The third parameter in the above example
specifies that 1000 tests should be done.
I thought that also specification like
"500 + bounds"   # to test 500 ones + all corners
"5%"
"10 seconds"     # to test 10 seconds long
...


Further, convinient methods like
all_like,
all_can, 
all_isa,
all_warn,
could be useful, too.


Greetings,
Janek

Reply via email to