Skip to content

Commit 26aea89

Browse files
committed
Add more test
1 parent 0e4fc56 commit 26aea89

File tree

7 files changed

+63
-2
lines changed

7 files changed

+63
-2
lines changed

test/MArray.jl

+18
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
end
2020

2121
@testset "Outer constructors and macro" begin
22+
@test_throws Exception MArray(1,2,3,4) # unknown constructor
23+
2224
@test MArray{Tuple{1},Int,1}((1,)).data === (1,)
2325
@test MArray{Tuple{1},Int}((1,)).data === (1,)
2426
@test MArray{Tuple{1}}((1,)).data === (1,)
@@ -218,3 +220,19 @@
218220
@test v[] == 2
219221
end
220222
end
223+
224+
@testset "some special case" begin
225+
@test_throws Exception MVector{1}(1, 2)
226+
@test (@inferred(MVector{1}((1, 2)))::MVector{1,NTuple{2,Int}}).data === ((1,2),)
227+
@test (@inferred(MVector{2}((1, 2)))::MVector{2,Int}).data === (1,2)
228+
@test (@inferred(MVector(1, 2))::MVector{2,Int}).data === (1,2)
229+
@test (@inferred(MVector((1, 2)))::MVector{2,Int}).data === (1,2)
230+
231+
@test_throws Exception MMatrix{1,1}(1, 2)
232+
@test (@inferred(MMatrix{1,1}((1, 2)))::MMatrix{1,1,NTuple{2,Int}}).data === ((1,2),)
233+
@test (@inferred(MMatrix{1,2}((1, 2)))::MMatrix{1,2,Int}).data === (1,2)
234+
@test (@inferred(MMatrix{1}((1, 2)))::MMatrix{1,2,Int}).data === (1,2)
235+
@test (@inferred(MMatrix{1}(1, 2))::MMatrix{1,2,Int}).data === (1,2)
236+
@test (@inferred(MMatrix{2}((1, 2)))::MMatrix{2,1,Int}).data === (1,2)
237+
@test (@inferred(MMatrix{2}(1, 2))::MMatrix{2,1,Int}).data === (1,2)
238+
end

test/MMatrix.jl

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
end
1919

2020
@testset "Outer constructors and macro" begin
21+
@test_throws Exception MMatrix(1,2,3,4) # unknown constructor
22+
2123
@test MMatrix{1,1,Int}((1,)).data === (1,)
2224
@test MMatrix{1,1}((1,)).data === (1,)
2325
@test MMatrix{1}((1,)).data === (1,)
@@ -53,6 +55,7 @@
5355
test_expand_error(:(@MMatrix [1; 2; 3; 4]...))
5456
test_expand_error(:(@MMatrix a))
5557

58+
@test ((@MMatrix [1 2.;3 4])::MMatrix{2, 2, Float64}).data === (1., 3., 2., 4.) #issue #911
5659
@test ((@MMatrix zeros(2,2))::MMatrix{2, 2, Float64}).data === (0.0, 0.0, 0.0, 0.0)
5760
@test ((@MMatrix fill(3.4, 2,2))::MMatrix{2, 2, Float64}).data === (3.4, 3.4, 3.4, 3.4)
5861
@test ((@MMatrix ones(2,2))::MMatrix{2, 2, Float64}).data === (1.0, 1.0, 1.0, 1.0)

test/SArray.jl

+20
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
end
1818

1919
@testset "Outer constructors and macro" begin
20+
@test_throws Exception SArray(1,2,3,4) # unknown constructor
21+
2022
@test SArray{Tuple{1},Int,1}((1,)).data === (1,)
2123
@test SArray{Tuple{1},Int}((1,)).data === (1,)
2224
@test SArray{Tuple{1}}((1,)).data === (1,)
@@ -204,3 +206,21 @@
204206
@test @inferred(promote_type(SMatrix{2,3,Float32,6}, SMatrix{2,3,Complex{Float64},6})) === SMatrix{2,3,Complex{Float64},6}
205207
end
206208
end
209+
210+
@testset "some special case" begin
211+
@test_throws Exception Scalar(1, 2) # issue #809
212+
213+
@test_throws Exception SVector{1}(1, 2)
214+
@test (@inferred(SVector{1}((1, 2)))::SVector{1,NTuple{2,Int}}).data === ((1,2),)
215+
@test (@inferred(SVector{2}((1, 2)))::SVector{2,Int}).data === (1,2)
216+
@test (@inferred(SVector(1, 2))::SVector{2,Int}).data === (1,2)
217+
@test (@inferred(SVector((1, 2)))::SVector{2,Int}).data === (1,2)
218+
219+
@test_throws Exception SMatrix{1,1}(1, 2)
220+
@test (@inferred(SMatrix{1,1}((1, 2)))::SMatrix{1,1,NTuple{2,Int}}).data === ((1,2),)
221+
@test (@inferred(SMatrix{1,2}((1, 2)))::SMatrix{1,2,Int}).data === (1,2)
222+
@test (@inferred(SMatrix{1}((1, 2)))::SMatrix{1,2,Int}).data === (1,2)
223+
@test (@inferred(SMatrix{1}(1, 2))::SMatrix{1,2,Int}).data === (1,2)
224+
@test (@inferred(SMatrix{2}((1, 2)))::SMatrix{2,1,Int}).data === (1,2)
225+
@test (@inferred(SMatrix{2}(1, 2))::SMatrix{2,1,Int}).data === (1,2)
226+
end

test/SHermitianCompact.jl

+2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ fill3(x) = fill(3, x)
5858
end
5959

6060
@testset "Outer Constructors" begin
61+
@test_throws Exception SHermitianCompact(1,2,3,4) # unknown constructor
62+
6163
for (N, L) in ((3, 6), (4, 10), (6, 21))
6264
for T in (Int32, Int64)
6365
@eval begin

test/SMatrix.jl

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
end
1818

1919
@testset "Outer constructors and macro" begin
20+
@test_throws Exception SMatrix(1,2,3,4) # unknown constructor
21+
2022
@test SMatrix{1,1,Int}((1,)).data === (1,)
2123
@test SMatrix{1,1}((1,)).data === (1,)
2224
@test SMatrix{1}((1,)).data === (1,)

test/SizedArray.jl

+16
Original file line numberDiff line numberDiff line change
@@ -252,3 +252,19 @@ struct OVector <: AbstractVector{Int} end
252252
Base.length(::OVector) = 10
253253
Base.axes(::OVector) = (0:9,)
254254
@test_throws ArgumentError SizedVector{10}(OVector())
255+
256+
@testset "some special case" begin
257+
@test_throws Exception SizedVector{1}(1, 2)
258+
@test (@inferred(SizedVector{1}((1, 2)))::SizedVector{1,NTuple{2,Int}}) == [(1, 2)]
259+
@test (@inferred(SizedVector{2}((1, 2)))::SizedVector{2,Int}) == [1, 2]
260+
@test (@inferred(SizedVector(1, 2))::SizedVector{2,Int}) == [1, 2]
261+
@test (@inferred(SizedVector((1, 2)))::SizedVector{2,Int}) == [1, 2]
262+
263+
@test_throws Exception SizedMatrix{1,1}(1, 2)
264+
@test (@inferred(SizedMatrix{1,1}((1, 2)))::SizedMatrix{1,1,NTuple{2,Int}}) == fill((1, 2),1,1)
265+
@test (@inferred(SizedMatrix{1,2}((1, 2)))::SizedMatrix{1,2,Int}) == reshape(1:2, 1, 2)
266+
@test (@inferred(SizedMatrix{1}((1, 2)))::SizedMatrix{1,2,Int}) == reshape(1:2, 1, 2)
267+
@test (@inferred(SizedMatrix{1}(1, 2))::SizedMatrix{1,2,Int}) == reshape(1:2, 1, 2)
268+
@test (@inferred(SizedMatrix{2}((1, 2)))::SizedMatrix{2,1,Int}) == reshape(1:2, 2, 1)
269+
@test (@inferred(SizedMatrix{2}(1, 2))::SizedMatrix{2,1,Int}) == reshape(1:2, 2, 1)
270+
end

test/ambiguities.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Allow no new ambiguities (see #18), unless you fix some old ones first!
22

3-
const allowable_ambiguities = VERSION v"1.7" ? 60 :
4-
VERSION v"1.6" ? 61 : error("version must be ≥1.6")
3+
const allowable_ambiguities = VERSION v"1.7" ? 10 :
4+
VERSION v"1.6" ? 11 : error("version must be ≥1.6")
55

66
# TODO: Revisit and fix. See
77
# https://github.com/JuliaLang/julia/pull/36962

0 commit comments

Comments
 (0)