Skip to content

Commit

Permalink
test: issue 451
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed Sep 27, 2024
1 parent 0f2a62f commit 736b4a3
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/misc/issues_tests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@testitem "Issue #451" tags=[:misc] begin
f(u, p) = u^2 - p

jac_calls = 0
function df(u, p)
global jac_calls += 1
return 2u
end

fn = NonlinearFunction(f; jac = df)
prob = NonlinearProblem(fn, 1.0, 2.0)
sol = solve(prob, NewtonRaphson())
@test sol.retcode == ReturnCode.Success
@test jac_calls 1

jac_calls = 0
fn2 = NonlinearFunction(f)
prob = NonlinearProblem(fn2, 1.0, 2.0)
sol = solve(prob, NewtonRaphson())
@test sol.retcode == ReturnCode.Success
@test jac_calls == 0
end

0 comments on commit 736b4a3

Please sign in to comment.