Skip to content

Commit 3a30c94

Browse files
committed
add regression test against #221
1 parent fc3b681 commit 3a30c94

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test/grad.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,18 @@ using FiniteDifferences: grad, jacobian, _jvp, jvp, j′vp, _j′vp, to_vec
8484
@test J one(Matrix{T}(undef, size(J)))
8585
end
8686

87+
@testset "jacobian that throws errors" begin
88+
# https://github.com/JuliaDiff/FiniteDifferences.jl/issues/221
89+
x = zeros(5)
90+
try
91+
jacobian(fdm, error, x)
92+
catch err
93+
@assert err isa ErrorException
94+
end
95+
# Make sure state of `x` is restored.
96+
@test x == zeros(5)
97+
end
98+
8799
@testset "multi vars jacobian/grad" begin
88100
rng, fdm = MersenneTwister(123456), central_fdm(5, 1)
89101

0 commit comments

Comments
 (0)