Skip to content

Commit 9c11cc2

Browse files
committed
add more tests
1 parent fdc9774 commit 9c11cc2

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

test/forwarddiff_overloads.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ cache = init(prob)
6161

6262
new_A, _ = h([ForwardDiff.Dual(5.0, 1.0, 0.0), ForwardDiff.Dual(5.0, 0.0, 1.0)])
6363
cache.A = new_A
64+
@test cache.A = new_A
6465

6566
x_p = solve!(cache)
6667
backslash_x_p = new_A \ b
@@ -75,6 +76,7 @@ cache = init(prob)
7576

7677
_, new_b = h([ForwardDiff.Dual(5.0, 1.0, 0.0), ForwardDiff.Dual(5.0, 0.0, 1.0)])
7778
cache.b = new_b
79+
@test cache.b == new_b
7880

7981
x_p = solve!(cache)
8082
backslash_x_p = A \ new_b
@@ -97,7 +99,7 @@ overload_x_p = solve(prob)
9799

98100
original_x_p = A \ b
99101

100-
(overload_x_p, original_x_p, rtol = 1e-9)
102+
@test (overload_x_p, original_x_p, rtol = 1e-9)
101103

102104
function linprob_f(p)
103105
A, b = h(p)
@@ -110,9 +112,9 @@ function slash_f(p)
110112
A \ b
111113
end
112114

113-
(ForwardDiff.jacobian(slash_f, [5.0, 5.0]), ForwardDiff.jacobian(linprob_f, [5.0, 5.0]))
115+
@test (ForwardDiff.jacobian(slash_f, [5.0, 5.0]), ForwardDiff.jacobian(linprob_f, [5.0, 5.0]))
114116

115-
(ForwardDiff.jacobian(p -> ForwardDiff.jacobian(slash_f, [5.0, p[1]]), [5.0]),
117+
@test (ForwardDiff.jacobian(p -> ForwardDiff.jacobian(slash_f, [5.0, p[1]]), [5.0]),
116118
ForwardDiff.jacobian(p -> ForwardDiff.jacobian(linprob_f, [5.0, p[1]]), [5.0]))
117119

118120
function g(p)
@@ -135,5 +137,5 @@ function linprob_f_hes(p)
135137
sum(x)
136138
end
137139

138-
(ForwardDiff.hessian(slash_f_hes, [5.0]),
140+
@test (ForwardDiff.hessian(slash_f_hes, [5.0]),
139141
ForwardDiff.hessian(linprob_f_hes, [5.0]))

0 commit comments

Comments
 (0)