Skip to content

Commit df0b9d0

Browse files
committed
Add tests for structs with isbits Union fields.
1 parent 234e118 commit df0b9d0

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

test/core.jl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5276,6 +5276,26 @@ x.u = initvalue2(Base.uniontypes(U)[1])
52765276
x.u = initvalue(Base.uniontypes(U)[2])
52775277
@test x.u === initvalue(Base.uniontypes(U)[2])
52785278

5279+
struct AA
5280+
x::Union{Int8, Int16, NTuple{7, Int8}, Void}
5281+
end
5282+
struct B
5283+
x::Int8
5284+
y::AA
5285+
z::Int8
5286+
end
5287+
b = B(91, AA(ntuple(i -> Int8(i), Val(7))), 23)
5288+
5289+
@test b.x === Int8(91)
5290+
@test b.z === Int8(23)
5291+
@test b.y === AA(ntuple(i -> Int8(i), Val(7)))
5292+
@test sizeof(b) == 12
5293+
@test AA(Int8(1)).x === Int8(1)
5294+
@test AA(Int8(0)).x === Int8(0)
5295+
@test AA(Int16(1)).x === Int16(1)
5296+
@test AA(nothing).x === nothing
5297+
@test sizeof(b.y) == 8
5298+
52795299
for U in boxedunions
52805300
for N in (1, 2, 3, 4)
52815301
A = Array{U}(ntuple(x->0, N)...)

0 commit comments

Comments
 (0)