Front page | perl.perl5.porters |
Postings from February 2020
Re: chained comparisons
Thread Previous
|
Thread Next
From:
Zefram via perl5-porters
Date:
February 7, 2020 12:19
Subject:
Re: chained comparisons
Message ID:
20200207121915.cprf6mvkan7q2guf@fysh.org
hv@crypt.org wrote:
>op.c:Perl_cmpchain_start looks to be missing a PERL_ARGS_ASSERT.
There's nothing to assert, so that macro expansion is empty. The dominant
style seems to be to omit the reference to such no-op assertions.
>Also the tests are excellent for numeric compares, but don't appear
>to touch the string compares or integer compares;
I trust the preexisting tests to establish that the comparison ops
individually work. t/op/cmpchain.t establishes first that chained
parsing applies to all the relevant operators, and then, by testing with
numeric comparisons, that chaining invokes the comparison behaviour of
the specific operators being used. It only takes a couple of operator
combinations to establish that the chaining system does pay due attention
to the specific operators.
If one wanted more thorough coverage, it would not be sufficient to test
the string comparison operators separately, paralleling the numeric tests,
and it would not do at all to just use the same inputs. One would have
to test with inputs that give different results in numeric and string
comparisons, to ensure that the correct type of comparison is being done,
and one would have to test on chains that mix the two types of comparison.
The former consideration would also apply to integer comparisons.
But I think this kind of expansion would be superfluous.
Incidentally, I was amused that I didn't have to edit any preexisting
tests. Evidently there were no tests checking the non-associativity
of the relational or equality operators. So when I'd implemented the
chaining but not touched the tests, the modified perl passed the whole
test suite.
-zefram
Thread Previous
|
Thread Next