Skip to content

Commit 7776b6b

Browse files
committed
Update
1 parent cf9bb03 commit 7776b6b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test/Nonlinear/Nonlinear.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,6 +1408,18 @@ function test_create_binary_switch()
14081408
return
14091409
end
14101410

1411+
function test_intercept_ForwardDiff_MethodError()
1412+
r = Nonlinear.OperatorRegistry()
1413+
f(x::Float64) = sin(x)^2
1414+
g(x) = x > 1 ? f(x) : zero(x)
1415+
Nonlinear.register_operator(r, :g, 1, g)
1416+
@test Nonlinear.eval_univariate_function(r, :g, 0.0) == 0.0
1417+
@test Nonlinear.eval_univariate_function(r, :g, 2.0) sin(2.0)^2
1418+
@test Nonlinear.eval_univariate_gradient(r, :g, 0.0) == 0.0
1419+
@test_throws ErrorException Nonlinear.eval_univariate_function(r, :g, 2.0)
1420+
return
1421+
end
1422+
14111423
end # TestNonlinear
14121424

14131425
TestNonlinear.runtests()

0 commit comments

Comments
 (0)