On Tue Mar 13 16:10:04 2007, [EMAIL PROTECTED] wrote:
> [library/Test::More] add isnt() to test inequality - ints only

> refactor the is() :multi for integers into a _cmp_ok() function, and
> then use that to provide is() and isnt()

I spent some time poking at refactoring this patch and #41806 (since
they are really one change), then decided it was a better use of your
time and mine, and better PIR training for you, if I tell you how (and
why) I want it refactored.

I definitely like adding isnt(). I'm fine with implementing is() and
isnt() as simple pass-throughs to cmp_ok(). But, the particular
implementation here, with :multi is(), :multi isnt(), :multi _cmp_ok(),
a pile of _eq_*() and _ne_*() utility functions, and the grab-bag
_is_or_isnt(), is a good example of a solution that seems simple enough
when applied to just ints, but expands into unmaintainability when
applied to the full range of cases. So, these are my requests:

- Instead of a "private" utility function _cmp_ok(), implement the
public cmp_ok() function, similar to Perl 5's Test::More.

- Instead of passing a Sub PMC into cmp_ok(), pass a string "eq", "ne",
"gt", "ge", etc. (to make it usable as a public function).

- Implement is(), isnt(), and cmp_ok() as methods on Test::Builder
instead of functions in Test::More, so they're available to everyone.
The Test::More functions can be simple pass-throughs to the methods,
like Test::More's plan(), ok(), and diag().

- The :multi strategy clearly isn't working, so let's eliminate it. You
had to repeat all the selections by type name in _is_or_isnt() anyway,
so just make that the primary implementation of cmp_ok(). When non-PMC
register and constant arguments are passed to PMC parameters, strings
are autopromoted to PMC Strings, and ints and floats are autopromoted to
PMC Floats, so the comparisons will work. (Though, it does make me
wonder if int registers and constants should be autopromoted to PMC
Integers instead.)

- Eliminate all the _eq_*() and _ne_*() utility functions. Most of them
were just syntactic sugar wrappers to change the name of the builtin
comparison opcodes.

Feel free to come back with questions, etc. and I'll be on #parrot all
day Saturday if you want to work on it interactively.

Thanks!
Allison

Reply via email to