Skip to content

Commit d8530d7

Browse files
committed
Select types randomly
1 parent e3eacb6 commit d8530d7

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

test/testtriag.jl

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# This file is a part of Julia. License is MIT: https://julialang.org/license
22

3+
function rand_except(elty2_list, elty1)
4+
v = copy(elty2_list)
5+
ind_match = findfirst(==(elty1), v)
6+
if !isnothing(ind_match)
7+
deleteat!(v, ind_match)
8+
end
9+
rand(v)
10+
end
11+
312
# The following test block tries to call all methods in base/linalg/triangular.jl in order for a combination of input element types. Keep the ordering when adding code.
413
function test_triangular(elty1_types)
514
n = 9
@@ -314,12 +323,10 @@ function test_triangular(elty1_types)
314323
@test ((A1 \ A1)::t1) M1 \ M1
315324

316325
# Begin loop for second Triangular matrix
317-
@testset for elty2 in (Float32, Float64, BigFloat, ComplexF32, ComplexF64, Complex{BigFloat}, Int)
318-
# Only test methods for the same element type and a single combination of mixed element types
319-
# to avoid too much compilation
320-
if !(elty1 == elty2 || elty1 (ComplexF32, Int) || elty2 (ComplexF32, Int))
321-
continue
322-
end
326+
# Only test methods for the same element type and a single combination of mixed element types
327+
# to avoid too much compilation
328+
elty2_list = [Float32, Float64, BigFloat, ComplexF32, ComplexF64, Complex{BigFloat}, Int]
329+
@testset for elty2 in (elty1, rand_except(elty2_list, elty1))
323330
@testset for (t2, uplo2) in ((UpperTriangular, :U),
324331
(UnitUpperTriangular, :U),
325332
(LowerTriangular, :L),
@@ -409,13 +416,10 @@ function test_triangular(elty1_types)
409416
end
410417
end
411418

412-
@testset for eltyB in (Float32, Float64, BigFloat, ComplexF32, ComplexF64, Complex{BigFloat})
413-
# Only test methods for the same element type and a single combination of mixed element types
414-
# to avoid too much compilation
415-
if !(elty1 == eltyB || elty1 (ComplexF32, Int) || eltyB (ComplexF32, Int))
416-
continue
417-
end
418-
419+
# Only test methods for the same element type and a single combination of mixed element types
420+
# to avoid too much compilation
421+
eltyB_list = [Float32, Float64, BigFloat, ComplexF32, ComplexF64, Complex{BigFloat}]
422+
@testset for eltyB in (elty1, rand_except(eltyB_list, elty1))
419423
B = convert(Matrix{eltyB}, (elty1 <: Complex ? real(A1) : A1) * fill(1.0, n, n))
420424

421425
Tri = Tridiagonal(rand(eltyB, n - 1), rand(eltyB, n), rand(eltyB, n - 1))

0 commit comments

Comments
 (0)