httpd-test-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Geoffrey Young <>
Subject Re: switching t_cmp() argument order
Date Wed, 09 Jun 2004 15:11:30 GMT

> but the tests need to be adjusted to swap the args, no?

only the regex ones, and only before the deprecation period ends.

outside of the regex case, where the comparison order is important, the
syllogism principle applies.

> That won't work with readonly args:
> % perl -le 'a("A", "b"); sub a {($_[0], $_[1]) = ($_[1], $_[0]);}'
> Modification of a read-only value attempted at -e line 1.

yeah, ok.  but I don't think this is very common:

  t_cmp("a", qr/a/);

which would be the only case where the argument swapping would occur _and_
that would cause a problem.

so, I can change the patch to use temporary assignments of $@ arguments and
avoid the problem, or we can agree that comparing a regex to a constant is
probably never going to happen, or at least it's not a problem if it does,
since it would force people to recode since they need to anyway.

>>      t_debug("testing : " . pop) if @_ == 3;
>> -    t_debug("expected: " . struct_as_string(0, $_[0]));
>> -    t_debug("received: " . struct_as_string(0, $_[1]));
>> -    return t_is_equal($_[0], $_[1]);
>> +    t_debug("received: " . struct_as_string(0, $_[0]));
>> +    t_debug("expected: " . struct_as_string(0, $_[1]));
>> +    return t_is_equal($_[1], $_[0]);
> why the swap of the t_is_equal args?

because the regex needs to occur first in t_is_equal().  the new t_cmp()
expects the regex second (in $expected) so the order needs to be swapped to
make t_cmp() actually work, since t_is_equal() wants the regex first.  I
could have changed t_is_equal() instead, but I didn't see the need to play
with two functions when simply changing t_cmp() to match is() (where the
functionality is essentially the same) was the issue.


View raw message