It occurs to me that we might be well served by nailing down the
arguments to assert and failif. I can see two ways of going:

1. A three argument form:

  assert(ASSERTION, ARG, MESSAGE)

where, in the case of, say, a CodeRef, ARG would probably be a
reference to an array of arguments, but in the case of a regex, it'd
be a simple scalar. The next question is, in the case of an ARRAY ref,
do we dereference it and pass in an array of values, or do we just
pass it in as a reference. I'm thinking that Test::Unit::Test should
just pass it through unmolested, but that T:U:A::CodeRef should
do something like:

    sub do_assertion {
        my($self,$arg,$message) = @_;
        my @args = (ref($arg) eq 'ARRAY') ? @$arg : $arg;
        # Set $a and $b so 'sort like' subs will work
        local($a, $b) = @args;
        $$self->(@args, $message) ||
            $self->do_failure([@args], $message);
    }

    sub do_failure {
        # Makes a sensible failure message...
    }

2. Variable arglist:

  assert(ASSERTION, MESSAGE, ARG, ARG, ...)

Which has simplicity on its side, but I'm not desperately keen on it,
because it moves the arguments away from the thing they're arguments
to. 

Thoughts? I'd really like to be able to pass in a message for every
assertion type, especially the custom ones...

-- 
Piers


_______________________________________________
Perlunit-devel mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/perlunit-devel

Reply via email to