Skip to content

Commit e599944

Browse files
committed
let's add testsets
1 parent 39938d9 commit e599944

File tree

4 files changed

+56
-44
lines changed

4 files changed

+56
-44
lines changed

test/DualTest.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ dual_isapprox(a::Dual{T,T1,T2}, b::Dual{T3,T4,T5}) where {T,T1,T2,T3,T4,T5} = er
2727
ForwardDiff.:(::Type{TestTag()}, ::Int) = true
2828
ForwardDiff.:(::Int, ::Type{TestTag()}) = false
2929

30-
for N in (0,3), M in (0,4), V in (Int, Float32)
30+
@testset "Dual{TestTag(),$V,$N} and Dual{TestTag(),Dual{TestTag(),$V,$M},$N}" for N in (0,3), M in (0,4), V in (Int, Float32)
3131
println(" ...testing Dual{TestTag(),$V,$N} and Dual{TestTag(),Dual{TestTag(),$V,$M},$N}")
3232

3333
PARTIALS = Partials{N,V}(ntuple(n -> intrand(V), N))
@@ -215,7 +215,7 @@ for N in (0,3), M in (0,4), V in (Int, Float32)
215215
@test isequal(NESTED_FDNUM, Dual{TestTag()}(Dual{TestTag()}(PRIMAL, M_PARTIALS2), NESTED_PARTIALS2)) == (N == M == 0)
216216
# @test isequal(PRIMAL, PRIMAL2) == isequal(NESTED_FDNUM, NESTED_FDNUM2)
217217

218-
@info "weird test?" N M V PRIMAL PRIMAL2 NESTED_FDNUM NESTED_FDNUM2
218+
@info "Predicates" N M V PRIMAL PRIMAL2 NESTED_FDNUM NESTED_FDNUM2
219219

220220
@test (FDNUM == Dual{TestTag()}(PRIMAL, PARTIALS2)) == (N == 0)
221221
@test (PRIMAL == PRIMAL2) == (FDNUM == FDNUM2)

test/GradientTest.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ end
8484

8585
println(" ...testing specialized StaticArray codepaths")
8686

87-
x = rand(3, 3)
87+
@testset "$T" for T in (StaticArrays.SArray, StaticArrays.MArray)
88+
x = rand(3, 3)
8889

89-
for T in (StaticArrays.SArray, StaticArrays.MArray)
9090
sx = T{Tuple{3,3}}(x)
9191

9292
cfg = ForwardDiff.GradientConfig(nothing, x)

test/PartialsTest.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ using ForwardDiff: Partials
77

88
samerng() = MersenneTwister(1)
99

10-
for N in (0, 3), T in (Int, Float32, Float64)
10+
@testset "Partials{$N,$T}" for N in (0, 3), T in (Int, Float32, Float64)
1111
println(" ...testing Partials{$N,$T}")
1212

1313
VALUES = (rand(T,N)...,)

test/runtests.jl

Lines changed: 51 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,51 @@
1-
using ForwardDiff
2-
3-
println("Testing Partials...")
4-
t = @elapsed include("PartialsTest.jl")
5-
println("done (took $t seconds).")
6-
7-
println("Testing Dual...")
8-
t = @elapsed include("DualTest.jl")
9-
println("done (took $t seconds).")
10-
11-
println("Testing derivative functionality...")
12-
t = @elapsed include("DerivativeTest.jl")
13-
println("done (took $t seconds).")
14-
15-
println("Testing gradient functionality...")
16-
t = @elapsed include("GradientTest.jl")
17-
println("done (took $t seconds).")
18-
19-
println("Testing jacobian functionality...")
20-
t = @elapsed include("JacobianTest.jl")
21-
println("done (took $t seconds).")
22-
23-
println("Testing hessian functionality...")
24-
t = @elapsed include("HessianTest.jl")
25-
println("done (took $t seconds).")
26-
27-
println("Testing perturbation confusion functionality...")
28-
t = @elapsed include("ConfusionTest.jl")
29-
println("done (took $t seconds).")
30-
31-
println("Testing miscellaneous functionality...")
32-
t = @elapsed include("MiscTest.jl")
33-
println("done (took $t seconds).")
34-
35-
if VERSION >= v"1.5-"
36-
println("Testing allocations...")
37-
t = @elapsed include("AllocationsTest.jl")
38-
println("done (took $t seconds).")
39-
end
1+
using ForwardDiff, Test
2+
3+
@testset "ForwardDiff" begin
4+
@testset "Partials" begin
5+
println("Testing Partials...")
6+
t = @elapsed include("PartialsTest.jl")
7+
println("done (took $t seconds).")
8+
end
9+
@testset "Dual" begin
10+
println("Testing Dual...")
11+
t = @elapsed include("DualTest.jl")
12+
println("done (took $t seconds).")
13+
end
14+
@testset "Derivative" begin
15+
println("Testing derivative functionality...")
16+
t = @elapsed include("DerivativeTest.jl")
17+
println("done (took $t seconds).")
18+
end
19+
@testset "Gradient" begin
20+
println("Testing gradient functionality...")
21+
t = @elapsed include("GradientTest.jl")
22+
println("done (took $t seconds).")
23+
end
24+
@testset "Jacobian" begin
25+
println("Testing jacobian functionality...")
26+
t = @elapsed include("JacobianTest.jl")
27+
println("done (took $t seconds).")
28+
end
29+
@testset "Hessian" begin
30+
println("Testing hessian functionality...")
31+
t = @elapsed include("HessianTest.jl")
32+
println("done (took $t seconds).")
33+
end
34+
@testset "Perturbation confusion" begin
35+
println("Testing perturbation confusion functionality...")
36+
t = @elapsed include("ConfusionTest.jl")
37+
println("done (took $t seconds).")
38+
end
39+
@testset "Miscellaneous" begin
40+
println("Testing miscellaneous functionality...")
41+
t = @elapsed include("MiscTest.jl")
42+
println("done (took $t seconds).")
43+
end
44+
if VERSION >= v"1.5-"
45+
@testset "Allocations" begin
46+
println("Testing allocations...")
47+
t = @elapsed include("AllocationsTest.jl")
48+
println("done (took $t seconds).")
49+
end
50+
end
51+
end

0 commit comments

Comments
 (0)