11using Test: @test , @test_throws
22
33using BlockArrays: Block, blocklength, blocklengths, blockedrange, blockisequal, blocks
4+ using TestExtras: @constinferred
45
56using TensorAlgebra: BlockedTuple
67
@@ -10,20 +11,20 @@ using TensorAlgebra: BlockedTuple
1011
1112 bt = BlockedTuple {divs} (flat)
1213
13- @test Tuple (bt) == flat
14+ @test @constinferred Tuple (bt) == flat
1415 @test bt == BlockedTuple ((true ,), (' a' , 2 ), (" b" , 3.0 ))
1516 @test BlockedTuple (bt) == bt
1617 @test blocklength (bt) == 3
1718 @test blocklengths (bt) == (1 , 2 , 2 )
18- @test blocks (bt) == ((true ,), (' a' , 2 ), (" b" , 3.0 ))
19+ @test @constinferred blocks (bt) == ((true ,), (' a' , 2 ), (" b" , 3.0 ))
1920
20- @test bt[1 ] == true
21- @test bt[2 ] == ' a'
22- @test bt[Block (1 )] == blocks (bt)[1 ]
23- @test bt[Block (2 )] == blocks (bt)[2 ]
24- @test bt[Block (1 ): Block (2 )] == blocks (bt)[1 : 2 ]
25- @test bt[Block (2 )[1 : 2 ]] == (' a' , 2 )
26- @test bt[2 : 4 ] == (' a' , 2 , " b" )
21+ @test @constinferred bt[1 ] == true
22+ @test @constinferred bt[2 ] == ' a'
23+ @test @constinferred bt[Block (1 )] == blocks (bt)[1 ]
24+ @test @constinferred bt[Block (2 )] == blocks (bt)[2 ]
25+ @test @constinferred bt[Block (1 ): Block (2 )] == blocks (bt)[1 : 2 ]
26+ @test @constinferred bt[Block (2 )[1 : 2 ]] == (' a' , 2 )
27+ @test @constinferred bt[2 : 4 ] == (' a' , 2 , " b" )
2728
2829 @test firstindex (bt) == 1
2930 @test lastindex (bt) == 5
@@ -41,11 +42,11 @@ using TensorAlgebra: BlockedTuple
4142 @test copy (bt) == bt
4243 @test deepcopy (bt) == bt
4344
44- @test map (n -> n + 1 , bt) == BlockedTuple {blocklengths(bt)} (Tuple (bt) .+ 1 )
45+ @test @constinferred map (n -> n + 1 , bt) == BlockedTuple {blocklengths(bt)} (Tuple (bt) .+ 1 )
4546 @test bt .+ BlockedTuple ((1 ,), (1 , 1 ), (1 , 1 )) ==
4647 BlockedTuple {blocklengths(bt)} (Tuple (bt) .+ 1 )
4748 @test_throws DimensionMismatch bt .+ BlockedTuple ((1 , 1 ), (1 , 1 ), (1 ,))
4849
4950 bt = BlockedTuple ((1 : 2 , 1 : 2 ), (1 : 3 ,))
50- @test length .(bt) == BlockedTuple ((2 , 2 ), (3 ,))
51+ @test @constinferred length .(bt) == BlockedTuple ((2 , 2 ), (3 ,))
5152end
0 commit comments