Skip to content

Commit

Permalink
Fix: Enum values doesn't display UInt8 correctly (JuliaLang#29035)
Browse files Browse the repository at this point in the history
  • Loading branch information
mimame authored and fredrikekre committed Sep 5, 2018
1 parent 3fbdc9b commit 807ae71
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion base/Enums.jl
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ macro enum(T, syms...)
else
print(io, x, "::")
show(IOContext(io, :compact => true), typeof(x))
print(io, " = ", $basetype(x))
print(io, " = ")
show(io, $basetype(x))
end
end
function Base.show(io::IO, t::Type{$(esc(typename))})
Expand Down
8 changes: 6 additions & 2 deletions test/enums.jl
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,12 @@ let b = IOBuffer()
@test deserialize(b) === apple
end

@enum UI8::UInt8 ten=0x0A thr=0x03 sevn=0x07
@test repr("text/plain", UI8) == "Enum $(string(UI8)):\nten = 0x0a\nthr = 0x03\nsevn = 0x07"
@enum UI8::UInt8 ten=0x0A thr=0x03 sevn=0x07 fiftn=0xF0
@test repr("text/plain", UI8) == "Enum $(string(UI8)):\nten = 0x0a\nthr = 0x03\nsevn = 0x07\nfiftn = 0xf0"
@test repr("text/plain", ten) == "$(string(ten))::UI8 = 0x0a"
@test repr("text/plain", thr) == "$(string(thr))::UI8 = 0x03"
@test repr("text/plain", sevn) == "$(string(sevn))::UI8 = 0x07"
@test repr("text/plain", fiftn) == "$(string(fiftn))::UI8 = 0xf0"

# test block form
@enum BritishFood begin
Expand Down

0 comments on commit 807ae71

Please sign in to comment.