From dd1b10eb084e92003d7e404f0677f7a99a81bad4 Mon Sep 17 00:00:00 2001 From: Jishnu Bhattacharya Date: Sun, 4 May 2025 21:41:50 +0530 Subject: [PATCH] Move testhelper imports to the top of test files --- test/adjtrans.jl | 9 +++------ test/bidiag.jl | 6 +++--- test/diagonal.jl | 7 +++---- test/hessenberg.jl | 6 +++--- test/symmetric.jl | 7 +++---- test/triangular.jl | 6 +++--- test/tridiag.jl | 8 +++----- 7 files changed, 21 insertions(+), 28 deletions(-) diff --git a/test/adjtrans.jl b/test/adjtrans.jl index 975e9a44..adf6d9a7 100644 --- a/test/adjtrans.jl +++ b/test/adjtrans.jl @@ -11,6 +11,9 @@ const BASE_TEST_PATH = joinpath(Sys.BINDIR, "..", "share", "julia", "test") isdefined(Main, :OffsetArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "OffsetArrays.jl")) using .Main.OffsetArrays +isdefined(Main, :ImmutableArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "ImmutableArrays.jl")) +using .Main.ImmutableArrays + @testset "Adjoint and Transpose inner constructor basics" begin intvec, intmat = [1, 2], [1 2; 3 4] # Adjoint/Transpose eltype must match the type of the Adjoint/Transpose of the input eltype @@ -250,9 +253,6 @@ end @test convert(Transpose{Float64,Matrix{Float64}}, Transpose(intmat))::Transpose{Float64,Matrix{Float64}} == Transpose(intmat) end -isdefined(Main, :ImmutableArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "ImmutableArrays.jl")) -using .Main.ImmutableArrays - @testset "Adjoint and Transpose convert methods to AbstractArray" begin # tests corresponding to #34995 intvec, intmat = [1, 2], [1 2 3; 4 5 6] @@ -593,9 +593,6 @@ end @test pointer(Transpose(D)) === pointer(D) end -isdefined(Main, :OffsetArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "OffsetArrays.jl")) -using .Main.OffsetArrays - @testset "offset axes" begin s = Base.Slice(-3:3)' @test axes(s) === (Base.OneTo(1), Base.IdentityUnitRange(-3:3)) diff --git a/test/bidiag.jl b/test/bidiag.jl index 209fb024..3abf2cb5 100644 --- a/test/bidiag.jl +++ b/test/bidiag.jl @@ -24,6 +24,9 @@ using .Main.OffsetArrays isdefined(Main, :SizedArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "SizedArrays.jl")) using .Main.SizedArrays +isdefined(Main, :ImmutableArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "ImmutableArrays.jl")) +using .Main.ImmutableArrays + include("testutils.jl") # test_approx_eq_modphase n = 10 #Size of test matrix @@ -787,9 +790,6 @@ end @test c \ A ≈ c \ Matrix(A) end -isdefined(Main, :ImmutableArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "ImmutableArrays.jl")) -using .Main.ImmutableArrays - @testset "Conversion to AbstractArray" begin # tests corresponding to #34995 dv = ImmutableArray([1, 2, 3, 4]) diff --git a/test/diagonal.jl b/test/diagonal.jl index 2b7cfd4d..02410707 100644 --- a/test/diagonal.jl +++ b/test/diagonal.jl @@ -21,6 +21,9 @@ using .Main.FillArrays isdefined(Main, :SizedArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "SizedArrays.jl")) using .Main.SizedArrays +isdefined(Main, :ImmutableArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "ImmutableArrays.jl")) +using .Main.ImmutableArrays + const n=12 # Size of matrix problem to test Random.seed!(1) @@ -1127,10 +1130,6 @@ end end end -const BASE_TEST_PATH = joinpath(Sys.BINDIR, "..", "share", "julia", "test") -isdefined(Main, :ImmutableArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "ImmutableArrays.jl")) -using .Main.ImmutableArrays - @testset "Conversion to AbstractArray" begin # tests corresponding to #34995 d = ImmutableArray([1, 2, 3, 4]) diff --git a/test/hessenberg.jl b/test/hessenberg.jl index 28859fd5..bf2a725f 100644 --- a/test/hessenberg.jl +++ b/test/hessenberg.jl @@ -10,6 +10,9 @@ const BASE_TEST_PATH = joinpath(Sys.BINDIR, "..", "share", "julia", "test") isdefined(Main, :SizedArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "SizedArrays.jl")) using .Main.SizedArrays +isdefined(Main, :ImmutableArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "ImmutableArrays.jl")) +using .Main.ImmutableArrays + # for tuple tests below ≅(x,y) = all(p -> p[1] ≈ p[2], zip(x,y)) @@ -218,9 +221,6 @@ end end end -isdefined(Main, :ImmutableArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "ImmutableArrays.jl")) -using .Main.ImmutableArrays - @testset "Conversion to AbstractArray" begin # tests corresponding to #34995 A = ImmutableArray([1 2 3; 4 5 6; 7 8 9]) diff --git a/test/symmetric.jl b/test/symmetric.jl index c6b6fdc4..38601070 100644 --- a/test/symmetric.jl +++ b/test/symmetric.jl @@ -14,6 +14,9 @@ using .Main.Quaternions isdefined(Main, :SizedArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "SizedArrays.jl")) using .Main.SizedArrays +isdefined(Main, :ImmutableArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "ImmutableArrays.jl")) +using .Main.ImmutableArrays + Random.seed!(1010) @testset "Pauli σ-matrices: $σ" for σ in map(Hermitian, @@ -722,10 +725,6 @@ end end end -const BASE_TEST_PATH = joinpath(Sys.BINDIR, "..", "share", "julia", "test") -isdefined(Main, :ImmutableArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "ImmutableArrays.jl")) -using .Main.ImmutableArrays - @testset "Conversion to AbstractArray" begin # tests corresponding to #34995 immutablemat = ImmutableArray([1 2 3; 4 5 6; 7 8 9]) diff --git a/test/triangular.jl b/test/triangular.jl index 642411fe..aeb41aa6 100644 --- a/test/triangular.jl +++ b/test/triangular.jl @@ -15,6 +15,9 @@ using .Main.SizedArrays isdefined(Main, :FillArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "FillArrays.jl")) using .Main.FillArrays +isdefined(Main, :ImmutableArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "ImmutableArrays.jl")) +using .Main.ImmutableArrays + n = 9 Random.seed!(123) @@ -243,9 +246,6 @@ end # dimensional correctness: const BASE_TEST_PATH = joinpath(Sys.BINDIR, "..", "share", "julia", "test") -isdefined(Main, :ImmutableArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "ImmutableArrays.jl")) -using .Main.ImmutableArrays - @testset "AbstractArray constructor should preserve underlying storage type" begin # tests corresponding to #34995 local m = 4 diff --git a/test/tridiag.jl b/test/tridiag.jl index 423012c8..effea2b0 100644 --- a/test/tridiag.jl +++ b/test/tridiag.jl @@ -23,6 +23,9 @@ using .Main.OffsetArrays isdefined(Main, :SizedArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "SizedArrays.jl")) using .Main.SizedArrays +isdefined(Main, :ImmutableArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "ImmutableArrays.jl")) +using .Main.ImmutableArrays + include("testutils.jl") # test_approx_eq_modphase #Test equivalence of eigenvectors/singular vectors taking into account possible phase (sign) differences @@ -769,9 +772,6 @@ end @test ishermitian(S) end -isdefined(Main, :ImmutableArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "ImmutableArrays.jl")) -using .Main.ImmutableArrays - @testset "Conversion to AbstractArray" begin # tests corresponding to #34995 v1 = ImmutableArray([1, 2]) @@ -796,8 +796,6 @@ end end end -isdefined(Main, :SizedArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "SizedArrays.jl")) -using .Main.SizedArrays @testset "non-number eltype" begin @testset "sum for SymTridiagonal" begin dv = [SizedArray{(2,2)}(rand(1:2048,2,2)) for i in 1:10]