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 @cond command #105

Merged
merged 6 commits into from
Feb 12, 2024
Merged

Add @cond command #105

merged 6 commits into from
Feb 12, 2024

Conversation

nystrom
Copy link
Contributor

@nystrom nystrom commented Nov 22, 2023

Add a @cond command to register an expression at the current infiltration point. The next time that point is hit, infiltration will occur only if the expression evaluates to true. This is less efficient than the @infiltrate cond macro, but is more flexible in that the condition can be updated dynamically.

Example:

julia> function f(x)
         out = []
         for i in x
           push!(out, 2i)
           @infiltrate
         end
         out
       end
f (generic function with 1 method)

julia> f([1,2,3,4,5,6,7,8,9,10])
Infiltrating f(x::Vector{Int64})
  at REPL[10]:5

infil> @cond i > 5

infil> @continue
Conditionally enabled infiltration at this infiltration point.

Infiltrating f(x::Vector{Int64})
  at REPL[10]:5

infil> i
6

I'll add some tests if this seems worthwhile to eventually merge.

@pfitzseb pfitzseb closed this Feb 12, 2024
@pfitzseb pfitzseb reopened this Feb 12, 2024
@codecov-commenter
Copy link

Codecov Report

Attention: 9 lines in your changes are missing coverage. Please review.

Comparison is base (bdf8448) 75.39% compared to head (9b3b413) 75.53%.
Report is 5 commits behind head on master.

Files Patch % Lines
src/Infiltrator.jl 78.04% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #105      +/-   ##
==========================================
+ Coverage   75.39%   75.53%   +0.14%     
==========================================
  Files           1        1              
  Lines         382      421      +39     
==========================================
+ Hits          288      318      +30     
- Misses         94      103       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@pfitzseb pfitzseb merged commit 86a3f2d into JuliaDebug:master Feb 12, 2024
6 checks passed
@pfitzseb
Copy link
Member

Thanks for this (and sorry for the delay in reviewing this)! I added a test for this, so no need to worry about that from your end :)

@nystrom
Copy link
Contributor Author

nystrom commented Feb 12, 2024

Oh, thanks a lot for accepting the PR!

@pfitzseb
Copy link
Member

Btw, I also added a note in the docs that this only takes local variables into account. Not sure how prohibitive the overhead of doing the eval at infiltration time would be, but that would solve the "issue".

@theogf
Copy link
Contributor

theogf commented Feb 14, 2024

That's a really cool feature! Thanks for adding it!

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.

4 participants