Skip to content

Commit 736b4a3

Browse files
committed
test: issue 451
1 parent 0f2a62f commit 736b4a3

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test/misc/issues_tests.jl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
@testitem "Issue #451" tags=[:misc] begin
2+
f(u, p) = u^2 - p
3+
4+
jac_calls = 0
5+
function df(u, p)
6+
global jac_calls += 1
7+
return 2u
8+
end
9+
10+
fn = NonlinearFunction(f; jac = df)
11+
prob = NonlinearProblem(fn, 1.0, 2.0)
12+
sol = solve(prob, NewtonRaphson())
13+
@test sol.retcode == ReturnCode.Success
14+
@test jac_calls 1
15+
16+
jac_calls = 0
17+
fn2 = NonlinearFunction(f)
18+
prob = NonlinearProblem(fn2, 1.0, 2.0)
19+
sol = solve(prob, NewtonRaphson())
20+
@test sol.retcode == ReturnCode.Success
21+
@test jac_calls == 0
22+
end

0 commit comments

Comments
 (0)