diff --git a/Project.toml b/Project.toml index b6acb6f..bd50f06 100644 --- a/Project.toml +++ b/Project.toml @@ -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" diff --git a/src/InverseFunctions.jl b/src/InverseFunctions.jl index 4cffde1..0728ef2 100644 --- a/src/InverseFunctions.jl +++ b/src/InverseFunctions.jl @@ -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 diff --git a/test/test_inverse.jl b/test/test_inverse.jl index 79cf725..caf0924 100644 --- a/test/test_inverse.jl +++ b/test/test_inverse.jl @@ -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)