Skip to content

Commit 18f15b3

Browse files
authored
remove pieces specific to old julia versions
1 parent 89cab2f commit 18f15b3

File tree

3 files changed

+38
-46
lines changed

3 files changed

+38
-46
lines changed

src/ConstructionBase.jl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,4 @@ end
168168
include("nonstandard.jl")
169169
include("functions.jl")
170170

171-
if !isdefined(Base, :get_extension)
172-
include("../ext/ConstructionBaseLinearAlgebraExt.jl")
173-
end
174-
175171
end # module

src/nonstandard.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,5 @@ linrange_constructor(start, stop, len, lendiv) = LinRange(start, stop, len)
3636
constructorof(::Type{<:LinRange}) = linrange_constructor
3737

3838
### Expr: args get splatted
39-
# ::Expr annotation is to make it type-stable on Julia 1.3-
39+
# ::Expr annotation is to make it type-stable on Julia 1.3-, probably not necessary anymore
4040
constructorof(::Type{<:Expr}) = (head, args) -> Expr(head, args...)::Expr

test/runtests.jl

Lines changed: 37 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,6 @@ Base.getproperty(s::SProp, prop::Symbol) = "ps$prop"
353353
Base.getproperty(s::SProp, prop::Int) = "pi$prop"
354354
Base.getproperty(s::SProp, prop::String) = "pstr$prop"
355355

356-
# automatic getproperties() supported only on 1.7+
357-
358356
@testset "properties can be numbered" begin
359357
@test getproperties(SProp((:a, :b))) === (a="psa", b="psb")
360358
@test getproperties(SProp((1, 2))) === ("pi1", "pi2")
@@ -551,45 +549,43 @@ end
551549

552550
using StaticArrays, IntervalSets
553551

554-
if isdefined(Base, :get_extension) # some 1.9 version
555-
@testset "staticarrays" begin
556-
sa = @SVector [2, 4, 6, 8]
557-
sa2 = ConstructionBase.constructorof(typeof(sa))((3.0, 5.0, 7.0, 9.0))
558-
@test sa2 === @SVector [3.0, 5.0, 7.0, 9.0]
559-
560-
ma = @MMatrix [2.0 4.0; 6.0 8.0]
561-
ma2 = @inferred ConstructionBase.constructorof(typeof(ma))((1, 2, 3, 4))
562-
@test ma2 isa MArray{Tuple{2,2},Int,2,4}
563-
@test all(ma2 .=== @MMatrix [1 3; 2 4])
564-
565-
sz = SizedArray{Tuple{2,2}}([1 2;3 4])
566-
sz2 = @inferred ConstructionBase.constructorof(typeof(sz))([:a :b; :c :d])
567-
@test sz2 == SizedArray{Tuple{2,2}}([:a :b; :c :d])
568-
@test typeof(sz2) <: SizedArray{Tuple{2,2},Symbol,2,2}
569-
570-
for T in (SVector, MVector)
571-
@test @inferred(ConstructionBase.constructorof(T)((1, 2, 3)))::T == T((1, 2, 3))
572-
@test @inferred(ConstructionBase.constructorof(T{3})((1, 2, 3)))::T == T((1, 2, 3))
573-
@test @inferred(ConstructionBase.constructorof(T{3})((1, 2)))::T == T((1, 2))
574-
@test @inferred(ConstructionBase.constructorof(T{3, Symbol})((1, 2, 3)))::T == T((1, 2, 3))
575-
@test @inferred(ConstructionBase.constructorof(T{3, Symbol})((1, 2)))::T == T((1, 2))
576-
@test @inferred(ConstructionBase.constructorof(T{3, X} where {X})((1, 2, 3)))::T == T((1, 2, 3))
577-
@test @inferred(ConstructionBase.constructorof(T{3, X} where {X})((1, 2)))::T == T((1, 2))
578-
@test @inferred(ConstructionBase.constructorof(T{X, Symbol} where {X})((1, 2, 3)))::T == T((1, 2, 3))
579-
end
580-
581-
sv = SVector(1, 2)
582-
@test SVector(3.0, 2.0) === @inferred setproperties(sv, x = 3.0)
583-
@test SVector(3.0, 5.0) === @inferred setproperties(sv, x = 3.0, y = 5.0)
584-
@test SVector(-1.0, -2.0) === @inferred setproperties(sv, data = (-1.0, -2))
585-
@test_throws "does not have properties z" setproperties(sv, z = 3.0)
586-
@test_throws "does not have properties z" setproperties(SVector(1, 2, 3, 4, 5), z = 3.0)
552+
@testset "staticarrays" begin
553+
sa = @SVector [2, 4, 6, 8]
554+
sa2 = ConstructionBase.constructorof(typeof(sa))((3.0, 5.0, 7.0, 9.0))
555+
@test sa2 === @SVector [3.0, 5.0, 7.0, 9.0]
556+
557+
ma = @MMatrix [2.0 4.0; 6.0 8.0]
558+
ma2 = @inferred ConstructionBase.constructorof(typeof(ma))((1, 2, 3, 4))
559+
@test ma2 isa MArray{Tuple{2,2},Int,2,4}
560+
@test all(ma2 .=== @MMatrix [1 3; 2 4])
561+
562+
sz = SizedArray{Tuple{2,2}}([1 2;3 4])
563+
sz2 = @inferred ConstructionBase.constructorof(typeof(sz))([:a :b; :c :d])
564+
@test sz2 == SizedArray{Tuple{2,2}}([:a :b; :c :d])
565+
@test typeof(sz2) <: SizedArray{Tuple{2,2},Symbol,2,2}
566+
567+
for T in (SVector, MVector)
568+
@test @inferred(ConstructionBase.constructorof(T)((1, 2, 3)))::T == T((1, 2, 3))
569+
@test @inferred(ConstructionBase.constructorof(T{3})((1, 2, 3)))::T == T((1, 2, 3))
570+
@test @inferred(ConstructionBase.constructorof(T{3})((1, 2)))::T == T((1, 2))
571+
@test @inferred(ConstructionBase.constructorof(T{3, Symbol})((1, 2, 3)))::T == T((1, 2, 3))
572+
@test @inferred(ConstructionBase.constructorof(T{3, Symbol})((1, 2)))::T == T((1, 2))
573+
@test @inferred(ConstructionBase.constructorof(T{3, X} where {X})((1, 2, 3)))::T == T((1, 2, 3))
574+
@test @inferred(ConstructionBase.constructorof(T{3, X} where {X})((1, 2)))::T == T((1, 2))
575+
@test @inferred(ConstructionBase.constructorof(T{X, Symbol} where {X})((1, 2, 3)))::T == T((1, 2, 3))
587576
end
588577

589-
@testset "intervalsets" begin
590-
@test constructorof(typeof(1..2))(0.5, 1.5) === 0.5..1.5
591-
@test constructorof(typeof(OpenInterval(1, 2)))(0.5, 1.5) === OpenInterval(0.5, 1.5)
592-
@test setproperties(1..2, left=0.0) === 0.0..2.0
593-
@test setproperties(OpenInterval(1.0, 2.0), left=1, right=5) === OpenInterval(1, 5)
594-
end
578+
sv = SVector(1, 2)
579+
@test SVector(3.0, 2.0) === @inferred setproperties(sv, x = 3.0)
580+
@test SVector(3.0, 5.0) === @inferred setproperties(sv, x = 3.0, y = 5.0)
581+
@test SVector(-1.0, -2.0) === @inferred setproperties(sv, data = (-1.0, -2))
582+
@test_throws "does not have properties z" setproperties(sv, z = 3.0)
583+
@test_throws "does not have properties z" setproperties(SVector(1, 2, 3, 4, 5), z = 3.0)
584+
end
585+
586+
@testset "intervalsets" begin
587+
@test constructorof(typeof(1..2))(0.5, 1.5) === 0.5..1.5
588+
@test constructorof(typeof(OpenInterval(1, 2)))(0.5, 1.5) === OpenInterval(0.5, 1.5)
589+
@test setproperties(1..2, left=0.0) === 0.0..2.0
590+
@test setproperties(OpenInterval(1.0, 2.0), left=1, right=5) === OpenInterval(1, 5)
595591
end

0 commit comments

Comments
 (0)