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

Handle branches in anonymous function pattern matching #534

Merged
merged 2 commits into from
Feb 9, 2023
Merged

Handle branches in anonymous function pattern matching #534

merged 2 commits into from
Feb 9, 2023

Conversation

jrglee
Copy link
Contributor

@jrglee jrglee commented Feb 9, 2023

While adopting my previous contribution in #493, I was still finding case patterns not being counted as branches. This was only in anonymous functions, where the parameter is used as selector, e.g.:

(1 to 100).map {
  case i if i % 2 == 0 => true
  case _ => false
}

The match handling does not instrument the case statements when the selector gets generated. But anonymous functions are a special case because the case statements are written by the user.

The solution in this PR handles anonymous function case by checking if the function body itself is a match node in the AST.

Copy link
Member

@ckipp01 ckipp01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @jrglee! Thanks for the PR. This make sense, LGTM!

@ckipp01 ckipp01 merged commit 068e41d into scoverage:main Feb 9, 2023
@davidhoyt
Copy link

Thank you!! Will there be a new release soon with this? I really appreciate contributors' and maintainers' hard work! 😄

@ckipp01
Copy link
Member

ckipp01 commented Feb 10, 2023

Thank you!! Will there be a new release soon with this? I really appreciate contributors' and maintainers' hard work! 😄

Hey! Just cut a new release so you should be good to update!

@davidhoyt
Copy link

Thank you for getting a new release out so quickly!

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.

3 participants