Skip to content

Commit b37f31b

Browse files
committed
mark svd test as broken on v1.6 and later & swap between @test and @test_broken for abstractarray.jl tests
1 parent 8ce8a8c commit b37f31b

File tree

3 files changed

+32
-9
lines changed

3 files changed

+32
-9
lines changed

test/abstractarray.jl

+9-7
Original file line numberDiff line numberDiff line change
@@ -185,19 +185,21 @@ using StaticArrays, Test, LinearAlgebra
185185
@test @inferred(convert(AbstractArray{Float64}, diag)) isa Diagonal{Float64,SVector{2,Float64}}
186186
@test convert(AbstractArray{Float64}, diag) == diag
187187
# The following cases currently convert the SMatrix into an MMatrix, because
188-
# the constructor in Base invokes `similar`, rather than `convert`, on the static array
188+
# the constructor in Base invokes `similar`, rather than `convert`, on the static
189+
# array. This was fixed in https://github.com/JuliaLang/julia/pull/40831; so should
190+
# work from Julia v1.8.0-DEV.55
189191
trans = Transpose(SVector(1,2))
190-
@test_broken @inferred(convert(AbstractArray{Float64}, trans)) isa Transpose{Float64,SVector{2,Float64}}
192+
@test_was_once_broken v"1.8.0-DEV.55" @inferred(convert(AbstractArray{Float64}, trans)) isa Transpose{Float64,SVector{2,Float64}}
191193
adj = Adjoint(SVector(1,2))
192-
@test_broken @inferred(convert(AbstractArray{Float64}, adj)) isa Adjoint{Float64,SVector{2,Float64}}
194+
@test_was_once_broken v"1.8.0-DEV.55" @inferred(convert(AbstractArray{Float64}, adj)) isa Adjoint{Float64,SVector{2,Float64}}
193195
uptri = UpperTriangular(SA[1 2; 0 3])
194-
@test_broken @inferred(convert(AbstractArray{Float64}, uptri)) isa UpperTriangular{Float64,SMatrix{2,2,Float64,4}}
196+
@test_was_once_broken v"1.8.0-DEV.55" @inferred(convert(AbstractArray{Float64}, uptri)) isa UpperTriangular{Float64,SMatrix{2,2,Float64,4}}
195197
lotri = LowerTriangular(SA[1 0; 2 3])
196-
@test_broken @inferred(convert(AbstractArray{Float64}, lotri)) isa LowerTriangular{Float64,SMatrix{2,2,Float64,4}}
198+
@test_was_once_broken v"1.8.0-DEV.55" @inferred(convert(AbstractArray{Float64}, lotri)) isa LowerTriangular{Float64,SMatrix{2,2,Float64,4}}
197199
unituptri = UnitUpperTriangular(SA[1 2; 0 1])
198-
@test_broken @inferred(convert(AbstractArray{Float64}, unituptri)) isa UnitUpperTriangular{Float64,SMatrix{2,2,Float64,4}}
200+
@test_was_once_broken v"1.8.0-DEV.55" @inferred(convert(AbstractArray{Float64}, unituptri)) isa UnitUpperTriangular{Float64,SMatrix{2,2,Float64,4}}
199201
unitlotri = UnitLowerTriangular(SA[1 0; 2 1])
200-
@test_broken @inferred(convert(AbstractArray{Float64}, unitlotri)) isa UnitLowerTriangular{Float64,SMatrix{2,2,Float64,4}}
202+
@test_was_once_broken v"1.8.0-DEV.55" @inferred(convert(AbstractArray{Float64}, unitlotri)) isa UnitLowerTriangular{Float64,SMatrix{2,2,Float64,4}}
201203
end
202204
end
203205

test/svd.jl

+6-2
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,18 @@ using StaticArrays, Test, LinearAlgebra
7171
@testinf svd(m_sing2'; full=Val(true)) \ v2 svd(Matrix(m_sing2'); full=true) \ Vector(v2)
7272
@testinf svd(m_sing2; full=Val(true)) \ m23' svd(Matrix(m_sing2); full=true) \ Matrix(m23')
7373
@testinf svd(m_sing2'; full=Val(true)) \ m23 svd(Matrix(m_sing2'); full=true) \ Matrix(m23)
74-
if v"1.6" > VERSION >= v"1.5-DEV"
74+
if VERSION >= v"1.5"
7575
# Test that svd of rectangular matrix is inferred.
7676
# Note the placement of @inferred brackets is important.
7777
#
7878
# This only seems to work on v"1.5" due to unknown compiler improvements; seems
7979
# to have stopped working again on v"1.6" and later?
8080
svd_full_false(A) = svd(A, full=false)
81-
@test @inferred(svd_full_false(m_sing2)).S svd(Matrix(m_sing2)).S
81+
if VERSION < v"1.6"
82+
@test @inferred(svd_full_false(m_sing2)).S svd(Matrix(m_sing2)).S
83+
else
84+
@test_broken @inferred(svd_full_false(m_sing2)).S svd(Matrix(m_sing2)).S
85+
end
8286
end
8387

8488
@testinf svd(mc_sing) \ v svd(Matrix(mc_sing)) \ Vector(v)

test/testutil.jl

+17
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,23 @@ macro inferred_maybe_allow(allow, ex)
9292
end
9393
end
9494

95+
"""
96+
@test_was_once_broken good_version ex
97+
98+
Expands to `@test ex` if `VERSION ≥ good_version` and to `@test_broken ex` if
99+
`VERSION ≥ good_version`. Useful for tests that are broken on earlier versions of Julia
100+
that are fixed on later versions.
101+
"""
102+
macro test_was_once_broken(good_version, ex)
103+
esc(quote
104+
if VERSION < $good_version
105+
@test_broken $ex
106+
else
107+
@test $ex
108+
end
109+
end)
110+
end
111+
95112
@testset "test utils" begin
96113
@testset "@testinf" begin
97114
@testinf [1,2] == [1,2]

0 commit comments

Comments
 (0)