Skip to content

Commit 6161dab

Browse files
committed
Add recursive type tests
1 parent af8e042 commit 6161dab

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test/trimming/trimming.jl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,26 @@ let exe_suffix = splitext(Base.julia_exename())[2]
5656
@test abi["types"][CVectorPair_Float32["fields"][1]["type_id"]]["name"] == "CVector{Float32}"
5757
@test abi["types"][CVectorPair_Float32["fields"][2]["type_id"]]["name"] == "CVector{Float32}"
5858
@test CVectorPair_Float32["size"] == 32
59+
60+
# `CTree{Float64}` should have been exported with the correct info
61+
@test any(Bool[type["name"] == "CTree{Float64}" for type in abi["types"]])
62+
CTree_Float64_id = findfirst(type["name"] == "CTree{Float64}" for type in abi["types"])
63+
CTree_Float64 = abi["types"][CTree_Float64_id]
64+
@test length(CTree_Float64["fields"]) == 1
65+
@test CTree_Float64["fields"][1]["offset"] == 0
66+
CVector_CTree_Float64 = abi["types"][CTree_Float64["fields"][1]["type_id"]]
67+
@test CVector_CTree_Float64["name"] == "CVector{CTree{Float64}}"
68+
@test CTree_Float64["size"] == sizeof(UInt) * 2
69+
70+
# `CVector{CTree{Float64}}` should have been exported with the correct info
71+
@test length(CVector_CTree_Float64["fields"]) == 2
72+
@test CVector_CTree_Float64["fields"][1]["offset"] == 0
73+
@test CVector_CTree_Float64["fields"][2]["offset"] == sizeof(UInt)
74+
@test abi["types"][CVector_CTree_Float64["fields"][1]["type_id"]]["name"] == "Int32"
75+
@test abi["types"][CVector_CTree_Float64["fields"][2]["type_id"]]["name"] == "Ptr{CTree{Float64}}"
76+
@test CVector_CTree_Float64["size"] == sizeof(UInt) * 2
77+
78+
# `Ptr{CTree{Float64}}` should refer (recursively) back to the original type id
79+
Ptr_CTree_Float64 = abi["types"][CVector_CTree_Float64["fields"][2]["type_id"]]
80+
@test Ptr_CTree_Float64["pointee_type_id"] == CTree_Float64_id
5981
end

0 commit comments

Comments
 (0)