Skip to content

Commit f33dbb7

Browse files
committed
test type stability
1 parent 2342979 commit f33dbb7

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

test/Project.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[deps]
2+
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
23
BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
34
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"
45
EllipsisNotation = "da5c29d0-fa7d-589e-88eb-ea29b0a81949"
@@ -8,16 +9,16 @@ LabelledNumbers = "f856a3a6-4152-4ec4-b2a7-02c1a55d7993"
89
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
910
NDTensors = "23ae76d9-e61a-49c4-8f12-3f1a16adf9cf"
1011
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
11-
TensorAlgebra = "68bd88dc-f39d-4e12-b2ca-f046b68fcc6a"
12-
TensorOperations = "6aa20fa7-93e2-5fca-9bc0-fbd0db3c71a2"
13-
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
1412
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
1513
Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb"
14+
TensorAlgebra = "68bd88dc-f39d-4e12-b2ca-f046b68fcc6a"
15+
TensorOperations = "6aa20fa7-93e2-5fca-9bc0-fbd0db3c71a2"
1616
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
17+
TestExtras = "5ed8adda-3752-4e41-b88a-e8b09835ee3a"
1718

1819
[compat]
19-
TensorOperations = "4.1.1"
2020
Aqua = "0.8.9"
2121
SafeTestsets = "0.1"
2222
Suppressor = "0.2"
23+
TensorOperations = "4.1.1"
2324
Test = "1.10"

test/test_blockedtuple.jl

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Test: @test, @test_throws
22

33
using BlockArrays: Block, blocklength, blocklengths, blockedrange, blockisequal, blocks
4+
using TestExtras: @constinferred
45

56
using 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,))
5152
end

0 commit comments

Comments
 (0)