@@ -18,19 +18,29 @@ block_size = BlockSizes([1,2,3], [2, 3])
18
18
@test nblocks (block_size, 1 ) == 3
19
19
@test nblocks (block_size, 2 ) == 2
20
20
21
- @inferred globalrange (block_size, (1 ,1 )) == (1 : 1 , 1 : 2 )
22
- @inferred globalrange (block_size, (1 ,2 )) == (1 : 1 , 3 : 5 )
23
- @inferred globalrange (block_size, (2 ,1 )) == (2 : 3 , 1 : 2 )
24
- @inferred globalrange (block_size, (2 ,2 )) == (2 : 3 , 3 : 5 )
21
+ @test @inferred ( globalrange (block_size, (1 ,1 ) )) == (1 : 1 , 1 : 2 )
22
+ @test @inferred ( globalrange (block_size, (1 ,2 ) )) == (1 : 1 , 3 : 5 )
23
+ @test @inferred ( globalrange (block_size, (2 ,1 ) )) == (2 : 3 , 1 : 2 )
24
+ @test @inferred ( globalrange (block_size, (2 ,2 ) )) == (2 : 3 , 3 : 5 )
25
25
26
- @inferred global2blockindex (block_size, (3 , 1 )) == BlockIndex ((2 ,1 ), (2 ,1 ))
27
- @inferred global2blockindex (block_size, (1 , 4 )) == BlockIndex ((1 ,2 ), (1 ,2 ))
28
- @inferred global2blockindex (block_size, (4 , 5 )) == BlockIndex ((3 ,2 ), (1 ,3 ))
26
+ # Test for allocations inside a function to avoid noise due to global
27
+ # variable references
28
+ wrapped_allocations = (bs, i) -> @allocated (globalrange (bs, i))
29
+ @test wrapped_allocations (block_size, (1 , 1 )) == 0
29
30
30
- @inferred blockindex2global ( block_size, BlockIndex (( 2 , 1 ), ( 2 , 1 ))) == ( 3 , 1 )
31
- @inferred blockindex2global ( block_size, BlockIndex (( 1 , 2 ), ( 1 , 2 ))) == ( 1 , 4 )
32
- @inferred blockindex2global ( block_size, BlockIndex ((3 ,2 ), (1 ,3 ))) == ( 4 , 5 )
31
+ @test @inferred ( global2blockindex ( block_size, ( 3 , 1 ))) == BlockIndex (( 2 , 1 ), ( 2 , 1 ) )
32
+ @test @inferred ( global2blockindex ( block_size, ( 1 , 4 ))) == BlockIndex (( 1 , 2 ), ( 1 , 2 ) )
33
+ @test @inferred ( global2blockindex ( block_size, ( 4 , 5 ))) == BlockIndex ((3 ,2 ), (1 ,3 ))
33
34
35
+ wrapped_allocations = (bs, i) -> @allocated (global2blockindex (bs, i))
36
+ @test wrapped_allocations (block_size, (3 , 1 )) == 0
37
+
38
+ @test @inferred (blockindex2global (block_size, BlockIndex ((2 ,1 ), (2 ,1 )))) == (3 , 1 )
39
+ @test @inferred (blockindex2global (block_size, BlockIndex ((1 ,2 ), (1 ,2 )))) == (1 , 4 )
40
+ @test @inferred (blockindex2global (block_size, BlockIndex ((3 ,2 ), (1 ,3 )))) == (4 , 5 )
41
+
42
+ wrapped_allocations = (bs, i) -> @allocated (blockindex2global (bs, i))
43
+ @test wrapped_allocations (block_size, BlockIndex ((2 ,1 ), (2 ,1 ))) == 0
34
44
35
45
@test block_size == BlockSizes (1 : 3 , 2 : 3 )
36
46
0 commit comments