using OrdinaryDiffEqBDF, ADTypes, Test
using OrdinaryDiffEqNonlinearSolve: NonlinearSolveAlg
using NonlinearSolve: TrustRegion
import OrdinaryDiffEqCore.SciMLLogging as SciMLLogging
using OrdinaryDiffEqCore: DEVerbosity

prob = ODEProblem((du, u, p, t) -> du .= u, zeros(1), (0.0, 1.0))
nlalg = FBDF(
    autodiff = AutoFiniteDiff(),
    nlsolve = NonlinearSolveAlg(TrustRegion(autodiff = AutoFiniteDiff()))
)
basicalg = FBDF(autodiff = AutoFiniteDiff())
basicalgad = FBDF()

nlsolver = @inferred OrdinaryDiffEqBDF.build_nlsolver(
    basicalg, prob.u0, prob.u0, prob.p, 0.0, 0.0, prob.f, prob.u0, Float64,
    Float64, Float64, 0.0, 0.0, Val(true), DEVerbosity()
)
nlsolver = @inferred OrdinaryDiffEqBDF.build_nlsolver(
    nlalg, prob.u0, prob.u0, prob.p, 0.0, 0.0, prob.f, prob.u0, Float64,
    Float64, Float64, 0.0, 0.0, Val(true), DEVerbosity()
)
nlsolver = @test_throws Any @inferred OrdinaryDiffEqBDF.build_nlsolver(
    basicalgad, prob.u0, prob.u0, prob.p, 0.0, 0.0, prob.f, prob.u0, Float64,
    Float64, Float64, 0.0, 0.0, Val(true), DEVerbosity()
)
