|
1 | | -println("Testing NaN detection.") |
2 | 1 | using DynamicExpressions |
3 | 2 | using Test |
4 | 3 |
|
@@ -29,8 +28,37 @@ function run_nan_detection_test(T) |
29 | 28 | @test !flag |
30 | 29 | end |
31 | 30 |
|
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 |
34 | 37 | end |
35 | 38 |
|
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