Skip to content

Commit 0d2b4fd

Browse files
make tests more robust
1 parent b9e5df1 commit 0d2b4fd

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "NonlinearSolve"
22
uuid = "8913a72c-1f9b-4ce2-8d82-65094dcecaec"
33
authors = ["Kanav Gupta <kanav0610@gmail.com>"]
4-
version = "0.3.11"
4+
version = "0.3.12"
55

66
[deps]
77
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"

test/runtests.jl

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,28 @@ function benchmark_scalar(f, u0)
2020
sol = (solve(probN, NewtonRaphson()))
2121
end
2222

23-
f, u0 = (u,p) -> u .* u .- 2, @SVector[1.0, 1.0]
24-
sf, su0 = (u,p) -> u * u - 2, 1.0
25-
sol = benchmark_immutable(f, u0)
23+
function ff(u,p)
24+
u .* u .- 2
25+
end
26+
const cu0 = @SVector[1.0, 1.0]
27+
function sf(u,p)
28+
u * u - 2
29+
end
30+
const csu0 = 1.0
31+
32+
sol = benchmark_immutable(ff, cu0)
2633
@test sol.retcode === Symbol(NonlinearSolve.DEFAULT)
2734
@test all(sol.u .* sol.u .- 2 .< 1e-9)
28-
sol = benchmark_mutable(f, u0)
35+
sol = benchmark_mutable(ff, cu0)
2936
@test sol.retcode === Symbol(NonlinearSolve.DEFAULT)
3037
@test all(sol.u .* sol.u .- 2 .< 1e-9)
31-
sol = benchmark_scalar(sf, su0)
38+
sol = benchmark_scalar(sf, csu0)
3239
@test sol.retcode === Symbol(NonlinearSolve.DEFAULT)
3340
@test sol.u * sol.u - 2 < 1e-9
3441

35-
@test (@ballocated benchmark_immutable($f, $u0)) == 0
36-
@test (@ballocated benchmark_mutable($f, $u0)) < 200
37-
@test (@ballocated benchmark_scalar($sf, $su0)) == 0
42+
@test (@ballocated benchmark_immutable(ff, cu0)) == 0
43+
@test (@ballocated benchmark_mutable(ff, cu0)) < 200
44+
@test (@ballocated benchmark_scalar(sf, csu0)) == 0
3845

3946
# AD Tests
4047
using ForwardDiff
@@ -143,7 +150,7 @@ sol = solve!(solver)
143150
# these should call the iterator version
144151
solver = init(probB, Bisection())
145152
@test solver isa NonlinearSolve.BracketingImmutableSolver
146-
# Question: Do we need BracketingImmutableSolver? We have fast scalar overload and
153+
# Question: Do we need BracketingImmutableSolver? We have fast scalar overload and
147154
# Bracketing solvers work only for scalars.
148155

149156
solver = init(probB, Bisection(); immutable = false)

0 commit comments

Comments
 (0)