|
487 | 487 | @inferred getproperties(funny_numbers(S,20)) |
488 | 488 | @inferred getproperties(funny_numbers(S,40)) |
489 | 489 | end |
| 490 | + |
| 491 | + |
| 492 | +using StaticArrays, IntervalSets |
| 493 | + |
| 494 | +if isdefined(Base, :get_extension) # some 1.9 version |
| 495 | + @testset "staticarrays" begin |
| 496 | + sa = @SVector [2, 4, 6, 8] |
| 497 | + sa2 = ConstructionBase.constructorof(typeof(sa))((3.0, 5.0, 7.0, 9.0)) |
| 498 | + @test sa2 === @SVector [3.0, 5.0, 7.0, 9.0] |
| 499 | + |
| 500 | + ma = @MMatrix [2.0 4.0; 6.0 8.0] |
| 501 | + ma2 = @inferred ConstructionBase.constructorof(typeof(ma))((1, 2, 3, 4)) |
| 502 | + @test ma2 isa MArray{Tuple{2,2},Int,2,4} |
| 503 | + @test all(ma2 .=== @MMatrix [1 3; 2 4]) |
| 504 | + |
| 505 | + sz = SizedArray{Tuple{2,2}}([1 2;3 4]) |
| 506 | + sz2 = @inferred ConstructionBase.constructorof(typeof(sz))([:a :b; :c :d]) |
| 507 | + @test sz2 == SizedArray{Tuple{2,2}}([:a :b; :c :d]) |
| 508 | + @test typeof(sz2) <: SizedArray{Tuple{2,2},Symbol,2,2} |
| 509 | + |
| 510 | + for T in (SVector, MVector) |
| 511 | + @test @inferred(ConstructionBase.constructorof(T)((1, 2, 3)))::T == T((1, 2, 3)) |
| 512 | + @test @inferred(ConstructionBase.constructorof(T{3})((1, 2, 3)))::T == T((1, 2, 3)) |
| 513 | + @test @inferred(ConstructionBase.constructorof(T{3})((1, 2)))::T == T((1, 2)) |
| 514 | + @test @inferred(ConstructionBase.constructorof(T{3, Symbol})((1, 2, 3)))::T == T((1, 2, 3)) |
| 515 | + @test @inferred(ConstructionBase.constructorof(T{3, Symbol})((1, 2)))::T == T((1, 2)) |
| 516 | + @test @inferred(ConstructionBase.constructorof(T{3, X} where {X})((1, 2, 3)))::T == T((1, 2, 3)) |
| 517 | + @test @inferred(ConstructionBase.constructorof(T{3, X} where {X})((1, 2)))::T == T((1, 2)) |
| 518 | + @test @inferred(ConstructionBase.constructorof(T{X, Symbol} where {X})((1, 2, 3)))::T == T((1, 2, 3)) |
| 519 | + end |
| 520 | + |
| 521 | + sv = SVector(1, 2) |
| 522 | + @test SVector(3.0, 2.0) === @inferred setproperties(sv, x = 3.0) |
| 523 | + @test SVector(3.0, 5.0) === @inferred setproperties(sv, x = 3.0, y = 5.0) |
| 524 | + @test SVector(-1.0, -2.0) === @inferred setproperties(sv, data = (-1.0, -2)) |
| 525 | + @test_throws "does not have properties z" setproperties(sv, z = 3.0) |
| 526 | + @test_throws "does not have properties z" setproperties(SVector(1, 2, 3, 4, 5), z = 3.0) |
| 527 | + end |
| 528 | + |
| 529 | + @testset "intervalsets" begin |
| 530 | + @test constructorof(typeof(1..2))(0.5, 1.5) === 0.5..1.5 |
| 531 | + @test constructorof(typeof(OpenInterval(1, 2)))(0.5, 1.5) === OpenInterval(0.5, 1.5) |
| 532 | + @test setproperties(1..2, left=0.0) === 0.0..2.0 |
| 533 | + @test setproperties(OpenInterval(1.0, 2.0), left=1, right=5) === OpenInterval(1, 5) |
| 534 | + end |
| 535 | +end |
0 commit comments