On Mar 15, 2005, at 10:53 AM, Nathan Gray wrote:
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 disagree. I feel that testing is kind of another form of documentation. And the test function you choose helps to document your assumptions. Test code is not like regular code. IMO, test code should be as verbose and obvious as possible. So following that train of thought, the more specific individual test functions the better.


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

compare two values

we already have is(), and then what you propose for cmp_ok().

skip test because of reason

I don't know if we should skip because of the reason (assuming by reason you mean the $desc parameter).


I say this because most of the time when doing a skip test, it is because something really won't compile, or makes a really big/bad error when you try to compile it. So to just add it as another parameter would defeat the purpose because it would blow up just trying the test anyway.

But then to be honest, I almost never use skip(). In my mind it's either todo or not todo.

ignore failure because it's still todo

We already have this with the todo_is(), todo_ok(), todo_isa_ok() and todo_fail() functions. And then when we add cmp_ok() we will also add a todo_cmp_ok() function as well.



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.

<snip>

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

I am sorry, but I really don't like this idea at all. I think that will defeat the self-documenting nature of the tests. And while it might seem simpler in some ways, I think it will actually complicate things since it wont be immediately obvious (from the function used) what I am trying to compare/test. I also see very little reason to ever change the test routines being called except to change todo_<something>() to <something>().


Test writing is one place where I am really not at all concerned about programmer efficiency. In a way I think test writing *should* be tedious.

- Stevan



Reply via email to