Skip to content

Commit 9412fa1

Browse files
authored
More checks for supported eltypes in tests. (#395)
1 parent 86cbb7e commit 9412fa1

File tree

3 files changed

+26
-19
lines changed

3 files changed

+26
-19
lines changed

test/testsuite/base.jl

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -116,23 +116,23 @@ end
116116
end
117117

118118
@testset "cat" begin
119-
@test compare(hcat, AT, rand(3), rand(3))
120-
@test compare(hcat, AT, rand(), rand(1, 3))
121-
@test compare(hcat, AT, rand(1, 3), rand())
122-
@test compare(hcat, AT, rand(3), rand(3, 3))
123-
@test compare(hcat, AT, rand(3, 3), rand(3))
124-
@test compare(hcat, AT, rand(3, 3), rand(3, 3))
125-
#@test compare(hcat, AT, rand(), rand(3, 3))
126-
#@test compare(hcat, AT, rand(3, 3), rand())
127-
128-
@test compare(vcat, AT, rand(3), rand(3))
129-
@test compare(vcat, AT, rand(3, 3), rand(3, 3))
130-
@test compare(vcat, AT, rand(), rand(3))
131-
@test compare(vcat, AT, rand(3), rand())
132-
@test compare(vcat, AT, rand(), rand(3, 3))
133-
#@test compare(vcat, AT, rand(3, 3), rand())
134-
135-
@test compare((a,b) -> cat(a, b; dims=4), AT, rand(3, 4), rand(3, 4))
119+
@test compare(hcat, AT, rand(Float32, 3), rand(Float32, 3))
120+
@test compare(hcat, AT, rand(Float32, ), rand(Float32, 1, 3))
121+
@test compare(hcat, AT, rand(Float32, 1, 3), rand(Float32))
122+
@test compare(hcat, AT, rand(Float32, 3), rand(Float32, 3, 3))
123+
@test compare(hcat, AT, rand(Float32, 3, 3), rand(Float32, 3))
124+
@test compare(hcat, AT, rand(Float32, 3, 3), rand(Float32, 3, 3))
125+
#@test compare(hcat, AT, rand(Float32, ), rand(Float32, 3, 3))
126+
#@test compare(hcat, AT, rand(Float32, 3, 3), rand(Float32))
127+
128+
@test compare(vcat, AT, rand(Float32, 3), rand(Float32, 3))
129+
@test compare(vcat, AT, rand(Float32, 3, 3), rand(Float32, 3, 3))
130+
@test compare(vcat, AT, rand(Float32, ), rand(Float32, 3))
131+
@test compare(vcat, AT, rand(Float32, 3), rand(Float32))
132+
@test compare(vcat, AT, rand(Float32, ), rand(Float32, 3, 3))
133+
#@test compare(vcat, AT, rand(Float32, 3, 3), rand(Float32))
134+
135+
@test compare((a,b) -> cat(a, b; dims=4), AT, rand(Float32, 3, 4), rand(Float32, 3, 4))
136136
end
137137

138138
@testset "reshape" begin

test/testsuite/linalg.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,10 @@ end
235235
if T == Int8
236236
continue
237237
end
238+
if !in(typeof(float(zero(T))), eltypes)
239+
# norm promotes to float, so make sure that type is supported
240+
continue
241+
end
238242
range = real(T) <: Integer ? (T.(1:10)) : T # prevent integer overflow
239243
@test compare(norm, AT, rand(range, sz), Ref(p))
240244
@test typeof(norm(rand(range, sz))) <: Real

test/testsuite/reductions.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,14 @@ end
5858
(10,)=>:, (10,10)=>:, (10,10,10)=>:,
5959
(10,10,10)=>[1], (10,10,10)=>[2], (10,10,10)=>[3]]
6060
@test compare(A->sum(A), AT, rand(range, sz))
61-
@test compare(A->sum(abs, A), AT, rand(range, sz))
6261
@test compare(A->sum(A; dims=dims), AT, rand(range, sz))
6362
@test compare(A->prod(A), AT, rand(range, sz))
64-
@test compare(A->prod(abs, A), AT, rand(range, sz))
6563
@test compare(A->prod(A; dims=dims), AT, rand(range, sz))
64+
if typeof(abs(rand(range))) in eltypes
65+
# abs(::Complex{Int}) promotes to Float64
66+
@test compare(A->sum(abs, A), AT, rand(range, sz))
67+
@test compare(A->prod(abs, A), AT, rand(range, sz))
68+
end
6669
end
6770

6871
if ET in (Float32, Float64, Int64, ComplexF32, ComplexF64)

0 commit comments

Comments
 (0)