Skip to content
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

Merged
merged 1 commit into from
Jan 3, 2021
Merged

Add predicate method mutations #1192

merged 1 commit into from
Jan 3, 2021

Conversation

dgollahon
Copy link
Collaborator

@dgollahon dgollahon force-pushed the add-predicate-mutations branch 2 times, most recently from f80e4a6 to 5f2813e Compare January 2, 2021 18:25
@@ -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?)
Copy link
Owner

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).

Copy link
Collaborator Author

@dgollahon dgollahon Jan 2, 2021

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.

Copy link
Collaborator Author

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?

Copy link
Owner

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.

@mbj mbj self-requested a review January 2, 2021 21:42
- Adds mutations from predicate-like methods (methods ending in ?) to `true`/`false`
  * `a.b?` -> `false`
  * `a.b?` -> `true`
- Closes #263
@dgollahon dgollahon merged commit 3f79ad0 into master Jan 3, 2021
@dgollahon dgollahon deleted the add-predicate-mutations branch January 3, 2021 00:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Predicate call site specific mutations
2 participants