New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Forbid '=' as a cmp_ok operator #141
Comments
All other assignment operators should be forbiden too: += .= x= ^= |= ||= &&= ... |
I concur. Assignment operators don't make much sense. I don't know how far to take this. '=' vs '==' is an obvious trap. The rest not so much. I'd prefer a blacklist over a whitelist, as that allows people to get creative with comparison ops we haven't thought of (or get added like smartmatch). |
Signed-off-by: Michael G. Schwern <schwern@pobox.com>
Fix the test to properly predict the x= error from cmp_ok() based on our passing in an error message rather than try the operator. For #141
Signed-off-by: Michael G. Schwern <schwern@pobox.com> For #141
Merged into the master branch, thanks! |
Using '=' as an operator is always a user mistake, as he probably wants '==' instead.
This mistake is currently not visible if $got is an lvalue.
Here is an example where Test::More should die in first test:
use Test::More tests => 1;
my @arr;
cmp_ok(scalar @arr, '=', 3);
cmp_ok(scalar @arr, '==', 0);
The text was updated successfully, but these errors were encountered: