@@ -200,6 +200,7 @@ ForwardDiff.:≺(::Int, ::Type{TestTag()}) = false
200200
201201 # Predicates #
202202 # ------------#
203+ @testset " Predicates" begin
203204
204205 @test ForwardDiff. isconstant (zero (FDNUM))
205206 @test ForwardDiff. isconstant (one (FDNUM))
@@ -212,10 +213,13 @@ ForwardDiff.:≺(::Int, ::Type{TestTag()}) = false
212213 @test isequal (FDNUM, Dual {TestTag()} (PRIMAL, PARTIALS2)) == (N == 0 )
213214 @test isequal (PRIMAL, PRIMAL2) == isequal (FDNUM, FDNUM2)
214215
215- @test isequal (NESTED_FDNUM, Dual {TestTag()} (Dual {TestTag()} (PRIMAL, M_PARTIALS2), NESTED_PARTIALS2)) == (N == M == 0 )
216- # @test isequal(PRIMAL, PRIMAL2) == isequal(NESTED_FDNUM, NESTED_FDNUM2)
216+ # Recall that FDNUM = Dual{TestTag()}(PRIMAL, PARTIALS) has N partials,
217+ # and FDNUM2 has everything with a 2, and all random numbers nonzero.
218+ # M is the length of M_PARTIALS, which affects:
219+ # NESTED_FDNUM = Dual{TestTag()}(Dual{TestTag()}(PRIMAL, M_PARTIALS), NESTED_PARTIALS)
217220
218- @info " Predicates" N M V PRIMAL PRIMAL2 NESTED_FDNUM NESTED_FDNUM2
221+ @test isequal (NESTED_FDNUM, Dual {TestTag()} (Dual {TestTag()} (PRIMAL, M_PARTIALS2), NESTED_PARTIALS2)) == (N == M == 0 )
222+ @test isequal (NESTED_FDNUM, NESTED_FDNUM2) == isequal (PRIMAL, PRIMAL2) && (N == M == 0 )
219223
220224 @test (FDNUM == Dual {TestTag()} (PRIMAL, PARTIALS2)) == (N == 0 )
221225 @test (PRIMAL == PRIMAL2) == (FDNUM == FDNUM2)
@@ -300,6 +304,7 @@ ForwardDiff.:≺(::Int, ::Type{TestTag()}) = false
300304 @test isodd (Dual {TestTag()} (Dual {TestTag()} (1 )))
301305 @test ! (isodd (Dual {TestTag()} (Dual {TestTag()} (2 ))))
302306
307+ end
303308 # #######################
304309 # Promotion/Conversion #
305310 # #######################
@@ -373,8 +378,11 @@ ForwardDiff.:≺(::Int, ::Type{TestTag()}) = false
373378
374379 # Division #
375380 # ----------#
381+ @testset " Division" begin
376382
377383 if M > 0 && N > 0
384+ # Recall that FDNUM = Dual{TestTag()}(PRIMAL, PARTIALS) has N partials,
385+ # all random numbers nonzero, and FDNUM2 another draw. M only affects NESTED_FDNUM.
378386 @test Dual {1} (FDNUM) / Dual {1} (PRIMAL) === Dual {1} (FDNUM / PRIMAL)
379387 @test Dual {1} (PRIMAL) / Dual {1} (FDNUM) === Dual {1} (PRIMAL / FDNUM)
380388 @test_broken Dual {1} (FDNUM) / FDNUM2 === Dual {1} (FDNUM / FDNUM2)
@@ -391,8 +399,12 @@ ForwardDiff.:≺(::Int, ::Type{TestTag()}) = false
391399 @test dual_isapprox (NESTED_FDNUM / PRIMAL, Dual {TestTag()} (value (NESTED_FDNUM) / PRIMAL, partials (NESTED_FDNUM) / PRIMAL))
392400 @test dual_isapprox (PRIMAL / NESTED_FDNUM, Dual {TestTag()} (PRIMAL / value (NESTED_FDNUM), (- (PRIMAL) / value (NESTED_FDNUM)^ 2 ) * partials (NESTED_FDNUM)))
393401
402+ end
403+
394404 # Exponentiation #
395405 # ----------------#
406+ @testset " Exponentiation" begin
407+
396408 # If V == Int, the LHS terms are Int's. Large inputs cause integer overflow
397409 # within the generic fallback of `isapprox`, resulting in a DomainError.
398410 # Promote to Float64 to avoid issues.
@@ -406,6 +418,7 @@ ForwardDiff.:≺(::Int, ::Type{TestTag()}) = false
406418
407419 @test partials (NaNMath. pow (Dual {TestTag()} (- 2.0 , 1.0 ), Dual {TestTag()} (2.0 , 0.0 )), 1 ) == - 4.0
408420
421+ end
409422 # ##################################
410423 # General Mathematical Operations #
411424 # ##################################
@@ -461,6 +474,7 @@ ForwardDiff.:≺(::Int, ::Type{TestTag()}) = false
461474
462475 # Special Cases #
463476 # ---------------#
477+ @testset " Special Cases" begin
464478
465479 @test_broken dual_isapprox (hypot (FDNUM, FDNUM2, FDNUM), sqrt (2 * (FDNUM^ 2 ) + FDNUM2^ 2 ))
466480 @test_broken dual_isapprox (hypot (FDNUM, FDNUM2, FDNUM3), sqrt (FDNUM^ 2 + FDNUM2^ 2 + FDNUM3^ 2 ))
@@ -485,8 +499,14 @@ ForwardDiff.:≺(::Int, ::Type{TestTag()}) = false
485499 @test dual_isapprox (f (FDNUM, PRIMAL2, PRIMAL3), Dual {TestTag()} (f (PRIMAL, PRIMAL2, PRIMAL3), PRIMAL2* PARTIALS))
486500 @test dual_isapprox (f (PRIMAL, PRIMAL2, FDNUM3), Dual {TestTag()} (f (PRIMAL, PRIMAL2, PRIMAL3), PARTIALS3))
487501 end
502+
503+ end # testset
488504end
489505
506+ # ############
507+ # bug fixes #
508+ # ############
509+
490510@testset " Exponentiation of zero" begin
491511 x0 = 0.0
492512 x1 = Dual {:t1} (x0, 1.0 )
0 commit comments