From 0d2b4fdee6aa3a90e69123283fbcbaf699267f53 Mon Sep 17 00:00:00 2001 From: Chris Rackauckas Date: Wed, 8 Dec 2021 15:03:57 -0500 Subject: [PATCH] make tests more robust --- Project.toml | 2 +- test/runtests.jl | 25 ++++++++++++++++--------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/Project.toml b/Project.toml index a65ffa760..23eccbc3f 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "NonlinearSolve" uuid = "8913a72c-1f9b-4ce2-8d82-65094dcecaec" authors = ["Kanav Gupta "] -version = "0.3.11" +version = "0.3.12" [deps] ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" diff --git a/test/runtests.jl b/test/runtests.jl index c021c8a86..7b3367904 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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 @@ -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)