Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "InverseFunctions"
uuid = "3587e190-3f89-42d0-90ee-14403ec27112"
version = "0.1.17"
version = "0.1.18"

[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Expand Down
2 changes: 1 addition & 1 deletion src/InverseFunctions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ if isdefined(Base, :get_extension) && isdefined(Base.Experimental, :register_err
function __init__()
Base.Experimental.register_error_hint(MethodError) do io, exc, _, _
if exc.f === test_inverse &&
(Base.get_extension(InverseFunctions, :InverseFunctionsTest) === nothing)
(Base.get_extension(InverseFunctions, :InverseFunctionsTestExt) === nothing)
print(io, "\nDid you forget to load Test?")
end
end
Expand Down
27 changes: 27 additions & 0 deletions test/test_inverse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,33 @@ end
InverseFunctions.test_inverse(inverse, log, compare = ===)
end

@testset "test_inverse" begin
@test hasmethod(InverseFunctions.test_inverse, Tuple{Any,Any})

err = try
InverseFunctions.test_inverse(identity)
catch e
e
end
@test err isa MethodError
@test !occursin("Did you forget to load Test?", sprint(showerror, err))

# Test can't be unloaded, so the behaviour without it is checked in a subprocess
if isdefined(Base, :get_extension)
script = """
using InverseFunctions
println("hasmethod: ", hasmethod(InverseFunctions.test_inverse, Tuple{Any,Any}))
InverseFunctions.test_inverse(identity, 1)
"""
cmd = `$(Base.julia_cmd()) --startup-file=no --project=$(Base.active_project()) -e $script`
output = IOBuffer()
run(pipeline(ignorestatus(cmd); stdout=output, stderr=output))
str = String(take!(output))
@test occursin("hasmethod: false", str)
@test occursin("Did you forget to load Test?", str)
end
end

@testset "maths" begin
InverseFunctions.test_inverse(!, false)

Expand Down
Loading