Skip to content

Commit a562e33

Browse files
committed
Add tests for structs with isbits Union fields.
1 parent 560aca9 commit a562e33

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
@@ -5316,6 +5316,26 @@ x.u = initvalue2(Base.uniontypes(U)[1])
53165316
x.u = initvalue(Base.uniontypes(U)[2])
53175317
@test x.u === initvalue(Base.uniontypes(U)[2])
53185318

5319+
struct AA
5320+
x::Union{Int8, Int16, NTuple{7, Int8}, Void}
5321+
end
5322+
struct B
5323+
x::Int8
5324+
y::AA
5325+
z::Int8
5326+
end
5327+
b = B(91, AA(ntuple(i -> Int8(i), Val(7))), 23)
5328+
5329+
@test b.x === Int8(91)
5330+
@test b.z === Int8(23)
5331+
@test b.y === AA(ntuple(i -> Int8(i), Val(7)))
5332+
@test sizeof(b) == 12
5333+
@test AA(Int8(1)).x === Int8(1)
5334+
@test AA(Int8(0)).x === Int8(0)
5335+
@test AA(Int16(1)).x === Int16(1)
5336+
@test AA(nothing).x === nothing
5337+
@test sizeof(b.y) == 8
5338+
53195339
for U in boxedunions
53205340
local U
53215341
for N in (1, 2, 3, 4)

0 commit comments

Comments
 (0)