Skip to content

Commit

Permalink
Add tests for structs with isbits Union fields.
Browse files Browse the repository at this point in the history
  • Loading branch information
quinnj committed Aug 23, 2017
1 parent 234e118 commit df0b9d0
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5276,6 +5276,26 @@ x.u = initvalue2(Base.uniontypes(U)[1])
x.u = initvalue(Base.uniontypes(U)[2])
@test x.u === initvalue(Base.uniontypes(U)[2])

struct AA
x::Union{Int8, Int16, NTuple{7, Int8}, Void}
end
struct B
x::Int8
y::AA
z::Int8
end
b = B(91, AA(ntuple(i -> Int8(i), Val(7))), 23)

@test b.x === Int8(91)
@test b.z === Int8(23)
@test b.y === AA(ntuple(i -> Int8(i), Val(7)))
@test sizeof(b) == 12
@test AA(Int8(1)).x === Int8(1)
@test AA(Int8(0)).x === Int8(0)
@test AA(Int16(1)).x === Int16(1)
@test AA(nothing).x === nothing
@test sizeof(b.y) == 8

for U in boxedunions
for N in (1, 2, 3, 4)
A = Array{U}(ntuple(x->0, N)...)
Expand Down

0 comments on commit df0b9d0

Please sign in to comment.