Skip to content

Commit 6e0a996

Browse files
authored
Move testhelper imports to the top of test files (#1336)
This is a matter of style, but it makes it easier to see which test helpers are being imported. This also helps avoid duplicate imports in the test files.
1 parent 5165fd3 commit 6e0a996

File tree

7 files changed

+21
-28
lines changed

7 files changed

+21
-28
lines changed

test/adjtrans.jl

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ const BASE_TEST_PATH = joinpath(Sys.BINDIR, "..", "share", "julia", "test")
1111
isdefined(Main, :OffsetArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "OffsetArrays.jl"))
1212
using .Main.OffsetArrays
1313

14+
isdefined(Main, :ImmutableArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "ImmutableArrays.jl"))
15+
using .Main.ImmutableArrays
16+
1417
@testset "Adjoint and Transpose inner constructor basics" begin
1518
intvec, intmat = [1, 2], [1 2; 3 4]
1619
# Adjoint/Transpose eltype must match the type of the Adjoint/Transpose of the input eltype
@@ -250,9 +253,6 @@ end
250253
@test convert(Transpose{Float64,Matrix{Float64}}, Transpose(intmat))::Transpose{Float64,Matrix{Float64}} == Transpose(intmat)
251254
end
252255

253-
isdefined(Main, :ImmutableArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "ImmutableArrays.jl"))
254-
using .Main.ImmutableArrays
255-
256256
@testset "Adjoint and Transpose convert methods to AbstractArray" begin
257257
# tests corresponding to #34995
258258
intvec, intmat = [1, 2], [1 2 3; 4 5 6]
@@ -593,9 +593,6 @@ end
593593
@test pointer(Transpose(D)) === pointer(D)
594594
end
595595

596-
isdefined(Main, :OffsetArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "OffsetArrays.jl"))
597-
using .Main.OffsetArrays
598-
599596
@testset "offset axes" begin
600597
s = Base.Slice(-3:3)'
601598
@test axes(s) === (Base.OneTo(1), Base.IdentityUnitRange(-3:3))

test/bidiag.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ using .Main.OffsetArrays
2424
isdefined(Main, :SizedArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "SizedArrays.jl"))
2525
using .Main.SizedArrays
2626

27+
isdefined(Main, :ImmutableArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "ImmutableArrays.jl"))
28+
using .Main.ImmutableArrays
29+
2730
include("testutils.jl") # test_approx_eq_modphase
2831

2932
n = 10 #Size of test matrix
@@ -787,9 +790,6 @@ end
787790
@test c \ A c \ Matrix(A)
788791
end
789792

790-
isdefined(Main, :ImmutableArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "ImmutableArrays.jl"))
791-
using .Main.ImmutableArrays
792-
793793
@testset "Conversion to AbstractArray" begin
794794
# tests corresponding to #34995
795795
dv = ImmutableArray([1, 2, 3, 4])

test/diagonal.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ using .Main.FillArrays
2121
isdefined(Main, :SizedArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "SizedArrays.jl"))
2222
using .Main.SizedArrays
2323

24+
isdefined(Main, :ImmutableArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "ImmutableArrays.jl"))
25+
using .Main.ImmutableArrays
26+
2427
const n=12 # Size of matrix problem to test
2528
Random.seed!(1)
2629

@@ -1127,10 +1130,6 @@ end
11271130
end
11281131
end
11291132

1130-
const BASE_TEST_PATH = joinpath(Sys.BINDIR, "..", "share", "julia", "test")
1131-
isdefined(Main, :ImmutableArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "ImmutableArrays.jl"))
1132-
using .Main.ImmutableArrays
1133-
11341133
@testset "Conversion to AbstractArray" begin
11351134
# tests corresponding to #34995
11361135
d = ImmutableArray([1, 2, 3, 4])

test/hessenberg.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ const BASE_TEST_PATH = joinpath(Sys.BINDIR, "..", "share", "julia", "test")
1010
isdefined(Main, :SizedArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "SizedArrays.jl"))
1111
using .Main.SizedArrays
1212

13+
isdefined(Main, :ImmutableArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "ImmutableArrays.jl"))
14+
using .Main.ImmutableArrays
15+
1316
# for tuple tests below
1417
(x,y) = all(p -> p[1] p[2], zip(x,y))
1518

@@ -218,9 +221,6 @@ end
218221
end
219222
end
220223

221-
isdefined(Main, :ImmutableArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "ImmutableArrays.jl"))
222-
using .Main.ImmutableArrays
223-
224224
@testset "Conversion to AbstractArray" begin
225225
# tests corresponding to #34995
226226
A = ImmutableArray([1 2 3; 4 5 6; 7 8 9])

test/symmetric.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ using .Main.Quaternions
1414
isdefined(Main, :SizedArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "SizedArrays.jl"))
1515
using .Main.SizedArrays
1616

17+
isdefined(Main, :ImmutableArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "ImmutableArrays.jl"))
18+
using .Main.ImmutableArrays
19+
1720
Random.seed!(1010)
1821

1922
@testset "Pauli σ-matrices: " for σ in map(Hermitian,
@@ -722,10 +725,6 @@ end
722725
end
723726
end
724727

725-
const BASE_TEST_PATH = joinpath(Sys.BINDIR, "..", "share", "julia", "test")
726-
isdefined(Main, :ImmutableArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "ImmutableArrays.jl"))
727-
using .Main.ImmutableArrays
728-
729728
@testset "Conversion to AbstractArray" begin
730729
# tests corresponding to #34995
731730
immutablemat = ImmutableArray([1 2 3; 4 5 6; 7 8 9])

test/triangular.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ using .Main.SizedArrays
1515
isdefined(Main, :FillArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "FillArrays.jl"))
1616
using .Main.FillArrays
1717

18+
isdefined(Main, :ImmutableArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "ImmutableArrays.jl"))
19+
using .Main.ImmutableArrays
20+
1821
n = 9
1922
Random.seed!(123)
2023

@@ -243,9 +246,6 @@ end
243246
# dimensional correctness:
244247
const BASE_TEST_PATH = joinpath(Sys.BINDIR, "..", "share", "julia", "test")
245248

246-
isdefined(Main, :ImmutableArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "ImmutableArrays.jl"))
247-
using .Main.ImmutableArrays
248-
249249
@testset "AbstractArray constructor should preserve underlying storage type" begin
250250
# tests corresponding to #34995
251251
local m = 4

test/tridiag.jl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ using .Main.OffsetArrays
2323
isdefined(Main, :SizedArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "SizedArrays.jl"))
2424
using .Main.SizedArrays
2525

26+
isdefined(Main, :ImmutableArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "ImmutableArrays.jl"))
27+
using .Main.ImmutableArrays
28+
2629
include("testutils.jl") # test_approx_eq_modphase
2730

2831
#Test equivalence of eigenvectors/singular vectors taking into account possible phase (sign) differences
@@ -769,9 +772,6 @@ end
769772
@test ishermitian(S)
770773
end
771774

772-
isdefined(Main, :ImmutableArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "ImmutableArrays.jl"))
773-
using .Main.ImmutableArrays
774-
775775
@testset "Conversion to AbstractArray" begin
776776
# tests corresponding to #34995
777777
v1 = ImmutableArray([1, 2])
@@ -796,8 +796,6 @@ end
796796
end
797797
end
798798

799-
isdefined(Main, :SizedArrays) || @eval Main include(joinpath($(BASE_TEST_PATH), "testhelpers", "SizedArrays.jl"))
800-
using .Main.SizedArrays
801799
@testset "non-number eltype" begin
802800
@testset "sum for SymTridiagonal" begin
803801
dv = [SizedArray{(2,2)}(rand(1:2048,2,2)) for i in 1:10]

0 commit comments

Comments
 (0)