Skip to content

Commit

Permalink
Make ignore_throw=true the default
Browse files Browse the repository at this point in the history
Most users will find this to be a better experience.

Resolves #25.
  • Loading branch information
topolarity committed Oct 26, 2023
1 parent e62fa4f commit 632f68c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/AllocCheck.jl
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ AllocCheck.AllocInstance[]
```
"""
function check_allocs(@nospecialize(func), @nospecialize(types); entry_abi=:specfunc, ret_mod=false, ignore_throw=false)
function check_allocs(@nospecialize(func), @nospecialize(types); entry_abi=:specfunc, ret_mod=false, ignore_throw=true)
job = create_job(func, types; entry_abi)
allocs = AllocInstance[]
mod = JuliaContext() do ctx
Expand Down
10 changes: 5 additions & 5 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ function same_ccall()
end

@testset "AllocCheck.jl" begin
@test length(check_allocs(mod, (Float64,Float64))) == 0
@test length(check_allocs(mod, (Float64,Float64)); ignore_throw=false) == 0
@test length(check_allocs(sin, (Float64,); ignore_throw=false)) > 0
@test length(check_allocs(sin, (Float64,); ignore_throw=true)) == 0
@test length(check_allocs(*, (Matrix{Float64},Matrix{Float64}))) != 0
@test length(check_allocs(*, (Matrix{Float64},Matrix{Float64}); ignore_throw=true)) != 0

@test length(check_allocs(alloc_in_catch, (); ignore_throw=false)) == 2
@test length(check_allocs(alloc_in_catch, (); ignore_throw=true)) == 1

@test length(check_allocs(same_ccall, (), ignore_throw=false)) == 2
@test length(check_allocs(same_ccall, (), ignore_throw=true)) == 2

@test length(check_allocs(first, (Core.SimpleVector,); ignore_throw = false)) == 3
@test length(check_allocs(first, (Core.SimpleVector,); ignore_throw = true)) == 0
@test length(check_allocs(time, ())) == 0
@test length(check_allocs(first, (Core.SimpleVector,); ignore_throw=false)) == 3
@test length(check_allocs(first, (Core.SimpleVector,); ignore_throw=true)) == 0
@test length(check_allocs(time, ()); ignore_throw=false) == 0
end

0 comments on commit 632f68c

Please sign in to comment.