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
Feature: Evaluate Logical Truthiness #629
Conversation
@adrian-burlacu-software I'm open to an extension like this, but I think there are two things I'd like to see first:
|
@bcoe Thanks, will do! |
@bcoe OK, I think all the requested changes are committed. Please take a look at:
The checks won't be successful likely because of the istanbul-lib-converage dependency 🥇 |
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.
The checks won't be successful likely because of the istanbul-lib-converage dependency
Could we split the changes to the instrumenter out into a separate PR, that way we can release a new version of the instrumenter and ensure tests pass for the updated istanbul-lib-coverage.
@bcoe |
Apologies missed this.
I think I was misunderstanding, reading your code you represent the statement as this right:
This would only evaluate |
@adrian-burlacu-software that's quite cool, I'd love to play with try this out on some of my libraries. |
@bcoe As soon as I can, I'll update to your suggested method with conjuction, fix tests, also make a new set of tests, and move the options parameter to last. This way no variable is needed and there's no caveats -- state change and evaluation will be able to happen simultaneously too. Wow, thanks so much for your input! Now I'll definitely need to update my Fast-Fuzz library with this update. |
Co-authored-by: Benjamin E. Coe <bencoe@google.com>
@adrian-burlacu-software I think I'm slightly off, you'd actually want the terminal value to always be truthy right:
☝️ I think that would work for logical operations, with the same logical output, and only evaluate once 😄 |
@bcoe I have tried the following: The bad thing is now I had to detect await somewhere in the AST so that I can await an async function that wraps the original await...OR detect an async function context so that I can just await no matter what the expression. I also tried to set up variables, but this is not a valid expression because variable declarations have to be hoisted: So now I'm just going to reuse a variable Everything is done on my end. That being said, I can't wait for any more ideas/comments. Also hope we can finally land this one soon too given it's behind an option that's off by default. Cheerio and thank you kindly :D |
@bcoe |
@adrian-burlacu-software I'm really happy with where this landed 👍 I'm excited that code coverage should be exactly as efficient, but you can now use Istanbul for a fuzzing tool. |
@adrian-burlacu-software great work on this one, I'm going to go ahead and release, let me know if it works for you. |
Istanbul is a great tool that I intend on using :D Yet, it fails to report the simple matter of logical truthiness of logical expressions.
For example, expressions such as:
x && y
This does report coverage of X and not Y even when X is false. But I want to know if these branches are ever able to become true.
Another simple example:
x || y
When Y is true, the coverage of X is reported even though it never becomes true.
This change handles these cases in a new counter that piggybacks on the branches count, called branchesTrue(bT).
Some caveats:
Thanks to the team working on this beloved library, I hope you find the time and willingness to merge this tested and necessary pull request into the master branch.