On Tue, Mar 15, 2005 at 08:27:32AM -0500, Stevan Little wrote:
> On Mar 15, 2005, at 6:45 AM, Nathan Gray wrote:
> >I also think it would be very nice to be able to use other operators,
> >such as gt, lt, or isa.
> >
> >  is($got, $expected, $desc, operator => 'gt');
> 
> Personally, I think a more familiar form, like Test::More::cmp_ok would 
> be better.
> 
>       cmp_ok($got, 'gt', $expected, $desc);
> 
> It should be easy enough to implement.

Fair enough.  That syntax is easier to read.

In addition to adding functionality, I would like to avoid having to
add subroutines.

I think we need a subroutine for each of the following:

  compare two values
  skip test because of reason
  ignore failure because it's still todo

Those three would all accept the same parameters, in the same order, so
it would be very easy to change which subroutine we are calling.  Those
three could also handle every type of comparison, including comparison
to truth if $expected was not passed in.

Thinking out-loud, we could even remove the skip subroutine, and just
pass the reason in as a named parameter 'skip'.

  ok($got, $expected, $desc, skip => $skip_test_if_true);

But adding in an operator parameter could be more confusing than
creating new subroutines for that purpose.  So that would leave us with
four subroutines:

  ok($got, $expected, $desc);
  todo($got, $expected, $desc);
  ok_cmp($got, $operator, $expected, $desc);
  todo_cmp($got, $operator, $expected, $desc);

Each of these subroutines would take an optional named parameter 'skip',
which if true, would skip the test, if false, would still test.

I'm not sure how accurate it would be to compare a single value to
truth, such as the current

  ok($got, $desc);

becoming

  ok($got, true, $desc);

That may be completely inaccurate.  But if not, Oh the simplicity of it
all!

-kolibrie

Reply via email to