-
-
Notifications
You must be signed in to change notification settings - Fork 153
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
Add predicate method mutations #1192
Conversation
f80e4a6
to
5f2813e
Compare
@@ -92,6 +93,13 @@ def emit_selector_specific_mutations | |||
emit_lambda_mutation | |||
end | |||
|
|||
def emit_predicate_mutations | |||
return unless selector.match?(/\?\z/) && !selector.equal?(:defined?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should go for selector.to_s.end_with?('?')
instead of the regexp.
Rationale: Asking if a string is a suffix is provided natively by String
. And regexp are a "too powerful tool" for this operation. We should use the simplest API that gets the job done and not use "untapped power" (of regexp in this case).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree but this was to workaround to adding an --ignore-subject
. Later rubies support end_with?('?')
directly on Symbol
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am actually working on adding a mutation to #start_with?
and #end_with?
(there is an issue for the former) so this may become an alive again later anyway. How would you like me to resolve this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets stay with regexp. For the moment, till mutant forces us to think about it again when we add the static suffix and prefix regexp to native method call mutations.
5f2813e
to
49ed21d
Compare
- Adds mutations from predicate-like methods (methods ending in ?) to `true`/`false` * `a.b?` -> `false` * `a.b?` -> `true` - Closes #263
49ed21d
to
65dfdf6
Compare
true
/false
a.b?
->false
a.b?
->true