Skip to content

Commit 10dfdb4

Browse files
committed
More detailed NaN detection testing
1 parent 414aefb commit 10dfdb4

File tree

1 file changed

+32
-4
lines changed

1 file changed

+32
-4
lines changed

test/test_nan_detection.jl

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
println("Testing NaN detection.")
21
using DynamicExpressions
32
using Test
43

@@ -29,8 +28,37 @@ function run_nan_detection_test(T)
2928
@test !flag
3029
end
3130

32-
for T in [Float16, Float32, Float64]
33-
run_nan_detection_test(T)
31+
@testset "Simple NaN detections" begin
32+
for T in [Float16, Float32, Float64]
33+
@testset "NaN detection with $T" begin
34+
run_nan_detection_test(T)
35+
end
36+
end
3437
end
3538

36-
println("Passed.")
39+
using DynamicExpressions.UtilsModule: is_bad_array
40+
using StaticArrays
41+
42+
function manual_nan_test(
43+
::Type{T}, array_size, nan_location, ::Val{static_array}, unroll
44+
) where {T,static_array}
45+
x = ones(T, array_size)
46+
x = static_array ? MVector{array_size}(x) : x
47+
@test !is_bad_array(x, unroll)
48+
x[nan_location] = T(NaN)
49+
@test is_bad_array(x, unroll)
50+
end
51+
52+
@testset "Manual NaN tests" begin
53+
unroll_size = 16
54+
unroll = Val(unroll_size)
55+
for T in [Float16, Float32, Float64, ComplexF16, ComplexF32, ComplexF64],
56+
array_size in 1:(2 * unroll_size + 1),
57+
nan_location in 1:array_size,
58+
static_array in [false, true]
59+
60+
manual_nan_test(
61+
T, array_size, nan_location, static_array ? Val(true) : Val(false), unroll
62+
)
63+
end
64+
end

0 commit comments

Comments
 (0)