Skip to content

Commit

Permalink
make tests more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisRackauckas committed Dec 8, 2021
1 parent b9e5df1 commit 0d2b4fd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "NonlinearSolve"
uuid = "8913a72c-1f9b-4ce2-8d82-65094dcecaec"
authors = ["Kanav Gupta <[email protected]>"]
version = "0.3.11"
version = "0.3.12"

[deps]
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
Expand Down
25 changes: 16 additions & 9 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,28 @@ function benchmark_scalar(f, u0)
sol = (solve(probN, NewtonRaphson()))
end

f, u0 = (u,p) -> u .* u .- 2, @SVector[1.0, 1.0]
sf, su0 = (u,p) -> u * u - 2, 1.0
sol = benchmark_immutable(f, u0)
function ff(u,p)
u .* u .- 2
end
const cu0 = @SVector[1.0, 1.0]
function sf(u,p)
u * u - 2
end
const csu0 = 1.0

sol = benchmark_immutable(ff, cu0)
@test sol.retcode === Symbol(NonlinearSolve.DEFAULT)
@test all(sol.u .* sol.u .- 2 .< 1e-9)
sol = benchmark_mutable(f, u0)
sol = benchmark_mutable(ff, cu0)
@test sol.retcode === Symbol(NonlinearSolve.DEFAULT)
@test all(sol.u .* sol.u .- 2 .< 1e-9)
sol = benchmark_scalar(sf, su0)
sol = benchmark_scalar(sf, csu0)
@test sol.retcode === Symbol(NonlinearSolve.DEFAULT)
@test sol.u * sol.u - 2 < 1e-9

@test (@ballocated benchmark_immutable($f, $u0)) == 0
@test (@ballocated benchmark_mutable($f, $u0)) < 200
@test (@ballocated benchmark_scalar($sf, $su0)) == 0
@test (@ballocated benchmark_immutable(ff, cu0)) == 0
@test (@ballocated benchmark_mutable(ff, cu0)) < 200
@test (@ballocated benchmark_scalar(sf, csu0)) == 0

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

solver = init(probB, Bisection(); immutable = false)
Expand Down

0 comments on commit 0d2b4fd

Please sign in to comment.