Skip to content

Commit 181cddd

Browse files
authored
Modularize tests (#197)
1 parent d79c989 commit 181cddd

File tree

7 files changed

+66
-42
lines changed

7 files changed

+66
-42
lines changed

test/runtests.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
using ArrayLayouts
1+
module ArrayLayoutsTests
2+
3+
import ArrayLayouts
24
import Aqua
3-
using FillArrays
4-
using Random
5-
using SparseArrays
5+
import Random
66
using Test
77

8-
import ArrayLayouts: MemoryLayout, @_layoutlmul, triangulardata
9-
108
@testset "Project quality" begin
119
Aqua.test_all(ArrayLayouts,
1210
ambiguities = false,
@@ -22,3 +20,5 @@ include("test_muladd.jl")
2220
include("test_ldiv.jl")
2321
include("test_layoutarray.jl")
2422
include("test_cumsum.jl")
23+
24+
end

test/test_cumsum.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
module TestCumsum
2+
13
using ArrayLayouts, Test
24

35
include("infinitearrays.jl")
@@ -26,3 +28,5 @@ include("infinitearrays.jl")
2628
r = RangeCumsum(InfiniteArrays.OneToInf())
2729
@test axes(r, 1) == InfiniteArrays.OneToInf()
2830
end
31+
32+
end

test/test_layoutarray.jl

Lines changed: 41 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
using ArrayLayouts, LinearAlgebra, FillArrays, Test
2-
using ArrayLayouts: sub_materialize, MemoryLayout, ColumnNorm, RowMaximum, CRowMaximum
1+
module TestLayoutArray
2+
3+
using ArrayLayouts, LinearAlgebra, FillArrays, Test, SparseArrays
4+
using ArrayLayouts: sub_materialize, MemoryLayout, ColumnNorm, RowMaximum, CRowMaximum, @_layoutlmul
5+
import ArrayLayouts: triangulardata
36

47
struct MyMatrix <: LayoutMatrix{Float64}
58
A::Matrix{Float64}
@@ -37,7 +40,7 @@ MemoryLayout(::Type{MyVector}) = DenseColumnMajor()
3740
@test a[1:3] == a.A[1:3]
3841
@test a[:] == a
3942
@test (a')[1,:] == (a')[1,1:3] == a
40-
@test sprint(show, "text/plain", a) == "3-element MyVector{Float64}:\n 1.0\n 2.0\n 3.0"
43+
@test sprint(show, "text/plain", a) == "3-element $MyVector{Float64}:\n 1.0\n 2.0\n 3.0"
4144
@test B*a B*a.A
4245
@test B'*a B'*a.A
4346
@test transpose(B)*a transpose(B)*a.A
@@ -209,7 +212,7 @@ MemoryLayout(::Type{MyVector}) = DenseColumnMajor()
209212
end
210213

211214
C = MyMatrix([1 2; 3 4])
212-
@test sprint(show, "text/plain", C) == "2×2 MyMatrix:\n 1.0 2.0\n 3.0 4.0"
215+
@test sprint(show, "text/plain", C) == "2×2 $MyMatrix:\n 1.0 2.0\n 3.0 4.0"
213216

214217
@testset "layoutldiv" begin
215218
A = MyMatrix(randn(5,5))
@@ -476,6 +479,38 @@ MemoryLayout(::Type{MyVector}) = DenseColumnMajor()
476479
@test UpperTriangular(A') * UnitUpperTriangular(A') UpperTriangular(A.A') * UnitUpperTriangular(A.A')
477480
end
478481

482+
@testset "mul! involving a triangular" begin
483+
A = MyMatrix(rand(4,4))
484+
UA = UpperTriangular(A)
485+
MA = Matrix(A)
486+
MUA = Matrix(UA)
487+
B = rand(4,4)
488+
UB = UpperTriangular(B)
489+
@test mul!(zeros(4,4), A, UB) MA * UB
490+
@test mul!(ones(4,4), A, UB, 2, 2) 2 * MA * UB .+ 2
491+
@test mul!(zeros(4,4), UA, B) MUA * B
492+
@test mul!(ones(4,4), UA, B, 2, 2) 2 * MUA * B .+ 2
493+
@test mul!(zeros(4,4), UA, UB) MUA * UB
494+
@test mul!(ones(4,4), UA, UB, 2, 2) 2 * MUA * UB .+ 2
495+
@test mul!(zeros(4,4), UB, A) UB * MA
496+
@test mul!(ones(4,4), UB, A, 2, 2) 2 * UB * MA .+ 2
497+
@test mul!(zeros(4,4), UB, UA) UB * MUA
498+
@test mul!(ones(4,4), UB, UA, 2, 2) 2 * UB * MUA .+ 2
499+
@test mul!(zeros(4,4), B, UA) B * MUA
500+
@test mul!(ones(4,4), B, UA, 2, 2) 2 * B * MUA .+ 2
501+
@test mul!(zeros(4,4), A, UA) MA * MUA
502+
@test mul!(ones(4,4), A, UA, 2, 2) 2 * MA * MUA .+ 2
503+
@test mul!(zeros(4,4), UA, A) MUA * MA
504+
@test mul!(ones(4,4), UA, A, 2, 2) 2 * MUA * MA .+ 2
505+
@test mul!(zeros(4,4), UA, UA) MUA * MUA
506+
@test mul!(ones(4,4), UA, UA, 2, 2) 2 * MUA * MUA .+ 2
507+
508+
509+
v = rand(4)
510+
@test mul!(zeros(4), UA, v) MUA * v
511+
@test mul!(ones(4), UA, v, 2, 2) 2 * MUA * v .+ 2
512+
end
513+
479514
if isdefined(LinearAlgebra, :copymutable_oftype)
480515
@testset "copymutable_oftype" begin
481516
A = MyMatrix(randn(3,3))
@@ -536,38 +571,6 @@ MemoryLayout(::Type{MyVector}) = DenseColumnMajor()
536571
end
537572
end
538573

539-
@testset "mul involving a triangular" begin
540-
A = MyMatrix(rand(4,4))
541-
UA = UpperTriangular(A)
542-
MA = Matrix(A)
543-
MUA = Matrix(UA)
544-
B = rand(4,4)
545-
UB = UpperTriangular(B)
546-
@test mul!(zeros(4,4), A, UB) MA * UB
547-
@test mul!(ones(4,4), A, UB, 2, 2) 2 * MA * UB .+ 2
548-
@test mul!(zeros(4,4), UA, B) MUA * B
549-
@test mul!(ones(4,4), UA, B, 2, 2) 2 * MUA * B .+ 2
550-
@test mul!(zeros(4,4), UA, UB) MUA * UB
551-
@test mul!(ones(4,4), UA, UB, 2, 2) 2 * MUA * UB .+ 2
552-
@test mul!(zeros(4,4), UB, A) UB * MA
553-
@test mul!(ones(4,4), UB, A, 2, 2) 2 * UB * MA .+ 2
554-
@test mul!(zeros(4,4), UB, UA) UB * MUA
555-
@test mul!(ones(4,4), UB, UA, 2, 2) 2 * UB * MUA .+ 2
556-
@test mul!(zeros(4,4), B, UA) B * MUA
557-
@test mul!(ones(4,4), B, UA, 2, 2) 2 * B * MUA .+ 2
558-
@test mul!(zeros(4,4), A, UA) MA * MUA
559-
@test mul!(ones(4,4), A, UA, 2, 2) 2 * MA * MUA .+ 2
560-
@test mul!(zeros(4,4), UA, A) MUA * MA
561-
@test mul!(ones(4,4), UA, A, 2, 2) 2 * MUA * MA .+ 2
562-
@test mul!(zeros(4,4), UA, UA) MUA * MUA
563-
@test mul!(ones(4,4), UA, UA, 2, 2) 2 * MUA * MUA .+ 2
564-
565-
566-
v = rand(4)
567-
@test mul!(zeros(4), UA, v) MUA * v
568-
@test mul!(ones(4), UA, v, 2, 2) 2 * MUA * v .+ 2
569-
end
570-
571574
struct MyUpperTriangular{T} <: AbstractMatrix{T}
572575
A::UpperTriangular{T,Matrix{T}}
573576
end
@@ -611,3 +614,5 @@ triangulardata(A::MyUpperTriangular) = triangulardata(A.A)
611614
@test MyMatrix(A) / U A / U
612615
VERSION >= v"1.9" && @test U / MyMatrix(A) U / A
613616
end
617+
618+
end

test/test_layouts.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
module TestLayouts
2+
13
using ArrayLayouts, LinearAlgebra, FillArrays, Test
24
import ArrayLayouts: MemoryLayout, DenseRowMajor, DenseColumnMajor, StridedLayout,
35
ConjLayout, RowMajor, ColumnMajor, UnitStride,
@@ -456,3 +458,5 @@ struct FooNumber <: Number end
456458
@test colsupport(view(randn(5,5),:,1),1:1) Base.OneTo(5)
457459
end
458460
end
461+
462+
end

test/test_ldiv.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
module TestLdiv
2+
13
using ArrayLayouts, LinearAlgebra, FillArrays, Test
24
import ArrayLayouts: ApplyBroadcastStyle, QRCompactWYQLayout, QRCompactWYLayout, QRPackedQLayout, QRPackedLayout
35

@@ -286,3 +288,4 @@ import ArrayLayouts: ApplyBroadcastStyle, QRCompactWYQLayout, QRCompactWYLayout,
286288
end
287289
end
288290

291+
end

test/test_muladd.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
module TestMulAdd
2+
13
using ArrayLayouts, FillArrays, Random, StableRNGs, LinearAlgebra, Test, Quaternions
24
using ArrayLayouts: DenseColumnMajor, AbstractStridedLayout, AbstractColumnMajor, DiagonalLayout, mul, Mul, zero!
35

@@ -843,3 +845,5 @@ Random.seed!(0)
843845
end
844846
end
845847
end
848+
849+
end

test/test_utils.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
module TestUtils
2+
13
using ArrayLayouts, LinearAlgebra, FillArrays, Test
24

35
@testset "_copy_oftype" begin
@@ -42,3 +44,5 @@ using ArrayLayouts, LinearAlgebra, FillArrays, Test
4244
@test all(==(0), A)
4345
end
4446
end
47+
48+
end

0 commit comments

Comments
 (0)