Skip to content

Commit d619a1f

Browse files
committed
update tests accordingly
1 parent e9189f3 commit d619a1f

File tree

3 files changed

+36
-36
lines changed

3 files changed

+36
-36
lines changed

test/abstractarray.jl

+12-12
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,18 @@ using StaticArrays, Test, LinearAlgebra
2727
@test @inferred(similar_type(SVector{2,Int}, Float64, Size(3,3,3))) == SArray{Tuple{3,3,3}, Float64, 3, 27}
2828

2929
# Some specializations for the mutable case
30-
@test @inferred(similar_type(MVector{3,Int}, Float64)) == SVector{3,Float64}
31-
@test @inferred(similar_type(MMatrix{3,3,Int,9}, Size(2))) == SVector{2, Int}
32-
@test @inferred(similar_type(MMatrix{3,3,Int,9}, Float64, Size(2))) == SVector{2, Float64}
33-
@test @inferred(similar_type(MMatrix{3,3,Int,9}, Float64, Size(2))) == SVector{2, Float64}
34-
35-
@test @inferred(similar_type(MMatrix{3,3,Int,9}, Float64)) == SMatrix{3, 3, Float64, 9}
36-
@test @inferred(similar_type(MVector{2,Int}, Size(3,3))) == SMatrix{3, 3, Int, 9}
37-
@test @inferred(similar_type(MVector{2,Int}, Float64, Size(3,3))) == SMatrix{3, 3, Float64, 9}
38-
39-
@test @inferred(similar_type(MArray{Tuple{4,4,4},Int,3,64}, Float64)) == SArray{Tuple{4,4,4}, Float64, 3, 64}
40-
@test @inferred(similar_type(MVector{2,Int}, Size(3,3,3))) == SArray{Tuple{3,3,3}, Int, 3, 27}
41-
@test @inferred(similar_type(MVector{2,Int}, Float64, Size(3,3,3))) == SArray{Tuple{3,3,3}, Float64, 3, 27}
30+
@test @inferred(similar_type(MVector{3,Int}, Float64)) == MVector{3,Float64}
31+
@test @inferred(similar_type(MMatrix{3,3,Int,9}, Size(2))) == MVector{2, Int}
32+
@test @inferred(similar_type(MMatrix{3,3,Int,9}, Float64, Size(2))) == MVector{2, Float64}
33+
@test @inferred(similar_type(MMatrix{3,3,Int,9}, Float64, Size(2))) == MVector{2, Float64}
34+
35+
@test @inferred(similar_type(MMatrix{3,3,Int,9}, Float64)) == MMatrix{3, 3, Float64, 9}
36+
@test @inferred(similar_type(MVector{2,Int}, Size(3,3))) == MMatrix{3, 3, Int, 9}
37+
@test @inferred(similar_type(MVector{2,Int}, Float64, Size(3,3))) == MMatrix{3, 3, Float64, 9}
38+
39+
@test @inferred(similar_type(MArray{Tuple{4,4,4},Int,3,64}, Float64)) == MArray{Tuple{4,4,4}, Float64, 3, 64}
40+
@test @inferred(similar_type(MVector{2,Int}, Size(3,3,3))) == MArray{Tuple{3,3,3}, Int, 3, 27}
41+
@test @inferred(similar_type(MVector{2,Int}, Float64, Size(3,3,3))) == MArray{Tuple{3,3,3}, Float64, 3, 27}
4242
end
4343

4444
@testset "similar" begin

test/indexing.jl

+16-16
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@ using StaticArrays, Test
2727

2828
# SVector
2929
mv = MVector{4,Int}(undef)
30-
@test (mv[SVector(1,2,3,4)] = vec; (@inferred getindex(mv, SVector(4,3,2,1)))::SVector{4,Int} == SVector((7,6,5,4)))
30+
@test (mv[SVector(1,2,3,4)] = vec; (@inferred getindex(mv, SVector(4,3,2,1)))::MVector{4,Int} == MVector((7,6,5,4)))
3131

3232
mv = MVector{4,Int}(undef)
33-
@test (mv[SVector(1,2,3,4)] = [4, 5, 6, 7]; (@inferred getindex(mv, SVector(4,3,2,1)))::SVector{4,Int} == SVector((7,6,5,4)))
34-
@test (mv[SVector(1,2,3,4)] = 2; (@inferred getindex(mv, SVector(4,3,2,1)))::SVector{4,Int} == SVector((2,2,2,2)))
33+
@test (mv[SVector(1,2,3,4)] = [4, 5, 6, 7]; (@inferred getindex(mv, SVector(4,3,2,1)))::MVector{4,Int} == MVector((7,6,5,4)))
34+
@test (mv[SVector(1,2,3,4)] = 2; (@inferred getindex(mv, SVector(4,3,2,1)))::MVector{4,Int} == MVector((2,2,2,2)))
3535

3636
# Colon
3737
mv = MVector{4,Int}(undef)
38-
@test (mv[:] = vec; (@inferred getindex(mv, :))::SVector{4,Int} == SVector((4,5,6,7)))
39-
@test (mv[:] = [4, 5, 6, 7]; (@inferred getindex(mv, :))::SVector{4,Int} == SVector((4,5,6,7)))
40-
@test (mv[:] = 2; (@inferred getindex(mv, :))::SVector{4,Int} == SVector((2,2,2,2)))
38+
@test (mv[:] = vec; (@inferred getindex(mv, :))::MVector{4,Int} == MVector((4,5,6,7)))
39+
@test (mv[:] = [4, 5, 6, 7]; (@inferred getindex(mv, :))::MVector{4,Int} == MVector((4,5,6,7)))
40+
@test (mv[:] = 2; (@inferred getindex(mv, :))::MVector{4,Int} == MVector((2,2,2,2)))
4141

4242
@test_throws DimensionMismatch setindex!(mv, SVector(1,2,3), SVector(1,2,3,4))
4343
@test_throws DimensionMismatch setindex!(mv, SVector(1,2,3), :)
@@ -50,11 +50,11 @@ using StaticArrays, Test
5050

5151
# SVector
5252
mm = MMatrix{2,2,Int}(undef)
53-
@test (mm[SVector(1,2,3,4)] = vec; (@inferred getindex(mm, SVector(4,3,2,1)))::SVector{4,Int} == SVector((7,6,5,4)))
53+
@test (mm[SVector(1,2,3,4)] = vec; (@inferred getindex(mm, SVector(4,3,2,1)))::MVector{4,Int} == MVector((7,6,5,4)))
5454

5555
# Colon
5656
mm = MMatrix{2,2,Int}(undef)
57-
@test (mm[:] = vec; (@inferred getindex(mm, :))::SVector{4,Int} == SVector((4,5,6,7)))
57+
@test (mm[:] = vec; (@inferred getindex(mm, :))::MVector{4,Int} == MVector((4,5,6,7)))
5858
end
5959

6060
@testset "Linear getindex()/setindex!() with a SVector on an Array" begin
@@ -93,16 +93,16 @@ using StaticArrays, Test
9393
sm = @MMatrix [1 3; 2 4]
9494

9595
# Tuple, scalar
96-
@test (mm = MMatrix{2,2,Int}(undef); mm[SVector(2,1),SVector(2,1)] = sm[SVector(2,1),SVector(2,1)]; (@inferred getindex(mm, SVector(2,1), SVector(2,1)))::SMatrix == @SMatrix [4 2; 3 1])
97-
@test (mm = MMatrix{2,2,Int}(undef); mm[1,SVector(1,2)] = sm[1,SVector(1,2)]; (@inferred getindex(mm, 1, SVector(1,2)))::SVector == @SVector [1,3])
98-
@test (mm = MMatrix{2,2,Int}(undef); mm[SVector(1,2),1] = sm[SVector(1,2),1]; (@inferred getindex(mm, SVector(1,2), 1))::SVector == @SVector [1,2])
96+
@test (mm = MMatrix{2,2,Int}(undef); mm[SVector(2,1),SVector(2,1)] = sm[SVector(2,1),SVector(2,1)]; (@inferred getindex(mm, SVector(2,1), SVector(2,1)))::MMatrix == @MMatrix [4 2; 3 1])
97+
@test (mm = MMatrix{2,2,Int}(undef); mm[1,SVector(1,2)] = sm[1,SVector(1,2)]; (@inferred getindex(mm, 1, SVector(1,2)))::MVector == @MVector [1,3])
98+
@test (mm = MMatrix{2,2,Int}(undef); mm[SVector(1,2),1] = sm[SVector(1,2),1]; (@inferred getindex(mm, SVector(1,2), 1))::MVector == @MVector [1,2])
9999

100100
# Colon
101-
@test (mm = MMatrix{2,2,Int}(undef); mm[:,:] = sm[:,:]; (@inferred getindex(mm, :, :))::SMatrix == @MMatrix [1 3; 2 4])
102-
@test (mm = MMatrix{2,2,Int}(undef); mm[SVector(2,1),:] = sm[SVector(2,1),:]; (@inferred getindex(mm, SVector(2,1), :))::SMatrix == @SMatrix [2 4; 1 3])
103-
@test (mm = MMatrix{2,2,Int}(undef); mm[:,SVector(2,1)] = sm[:,SVector(2,1)]; (@inferred getindex(mm, :, SVector(2,1)))::SMatrix == @SMatrix [3 1; 4 2])
104-
@test (mm = MMatrix{2,2,Int}(undef); mm[1,:] = sm[1,:]; (@inferred getindex(mm, 1, :))::SVector == @SVector [1,3])
105-
@test (mm = MMatrix{2,2,Int}(undef); mm[:,1] = sm[:,1]; (@inferred getindex(mm, :, 1))::SVector == @SVector [1,2])
101+
@test (mm = MMatrix{2,2,Int}(undef); mm[:,:] = sm[:,:]; (@inferred getindex(mm, :, :))::MMatrix == @MMatrix [1 3; 2 4])
102+
@test (mm = MMatrix{2,2,Int}(undef); mm[SVector(2,1),:] = sm[SVector(2,1),:]; (@inferred getindex(mm, SVector(2,1), :))::MMatrix == @MMatrix [2 4; 1 3])
103+
@test (mm = MMatrix{2,2,Int}(undef); mm[:,SVector(2,1)] = sm[:,SVector(2,1)]; (@inferred getindex(mm, :, SVector(2,1)))::MMatrix == @MMatrix [3 1; 4 2])
104+
@test (mm = MMatrix{2,2,Int}(undef); mm[1,:] = sm[1,:]; (@inferred getindex(mm, 1, :))::MVector == @MVector [1,3])
105+
@test (mm = MMatrix{2,2,Int}(undef); mm[:,1] = sm[:,1]; (@inferred getindex(mm, :, 1))::MVector == @MVector [1,2])
106106
end
107107

108108
@testset "3D scalar indexing" begin

test/matrix_multiply.jl

+8-8
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,21 @@ using StaticArrays, Test, LinearAlgebra
2727
@test @inferred(v*transpose(v)) === @SMatrix [1 2; 2 4]
2828

2929
v3 = [1, 2]
30-
@test m*v3 === @SVector [5, 11]
30+
@test m*v3 == @MVector [5, 11]
3131
v3_bad = [1, 2, 3]
3232
@test_throws DimensionMismatch m*v3_bad
3333

3434
m2 = @MMatrix [1 2; 3 4]
3535
v4 = @MVector [1, 2]
36-
@test (m2*v4)::SVector == @SVector [5, 11]
36+
@test (m2*v4)::MVector == @MVector [5, 11]
3737

3838
m3 = @SArray [1 2; 3 4]
3939
v5 = @SArray [1, 2]
4040
@test m3*v5 === @SVector [5, 11]
4141

4242
m4 = @MArray [1 2; 3 4]
4343
v6 = @MArray [1, 2]
44-
@test (m4*v6) === @SVector [5, 11]
44+
@test (m4*v6) == @MVector [5, 11]
4545

4646
m5 = @SMatrix [1.0 2.0; 3.0 4.0]
4747
v7 = [1.0, 2.0]
@@ -95,7 +95,7 @@ using StaticArrays, Test, LinearAlgebra
9595

9696
m = @MMatrix [1 2; 3 4]
9797
n = @MMatrix [2 3; 4 5]
98-
@test (m*n) === @SMatrix [10 13; 22 29]
98+
@test (m*n) == @MMatrix [10 13; 22 29]
9999

100100
m = @SArray [1 2; 3 4]
101101
n = @SArray [2 3; 4 5]
@@ -107,8 +107,8 @@ using StaticArrays, Test, LinearAlgebra
107107

108108
# block matrices
109109
bm = @SMatrix [m m; m m]
110-
bm2 = @SMatrix [14 20; 30 44]
111-
@test (bm*bm)::SMatrix{2,2,SMatrix{2,2,Int,4}} == @SMatrix [bm2 bm2; bm2 bm2]
110+
bm2 = @MMatrix [14 20; 30 44]
111+
@test (bm*bm)::SMatrix{2,2,MMatrix{2,2,Int,4}} == @SMatrix [bm2 bm2; bm2 bm2]
112112

113113
# Alternative methods used between 8 < n <= 14 and n > 14
114114
m_array = rand(1:10, 10, 10)
@@ -142,15 +142,15 @@ using StaticArrays, Test, LinearAlgebra
142142

143143
m = MMatrix{10,10}(m_array)
144144
n = MMatrix{10,10}(n_array)
145-
@test (m*n)::SMatrix == a_array
145+
@test (m*n)::MMatrix == a_array
146146

147147
m_array = rand(1:10, 16, 16)
148148
n_array = rand(1:10, 16, 16)
149149
a_array = m_array*n_array
150150

151151
m = MMatrix{16,16}(m_array)
152152
n = MMatrix{16,16}(n_array)
153-
@test (m*n)::SMatrix == a_array
153+
@test (m*n)::MMatrix == a_array
154154

155155
# Mutating BLAS types follow yet different behaviour
156156
m_array = randn(4, 4)

0 commit comments

Comments
 (0)