diff --git a/src/EnumX.jl b/src/EnumX.jl index 0a384cf..511c94f 100644 --- a/src/EnumX.jl +++ b/src/EnumX.jl @@ -132,7 +132,7 @@ function Base.show(io::IO, ::MIME"text/plain", ::Base.Type{E}) where E <: Enum mx = maximum(x -> textwidth(x.first), stringmap; init = 0) print(iob, "Enum type $(nameof(parentmodule(E))).$(nameof(E)) <: ", - "Enum{$(Base.Enums.basetype(E))} with $(n) instance$(n == 1 ? "" : "s"):" + "Enum{$(Base.Enums.basetype(E))} with $(n) instance$(n == 1 ? "" : "s")$(n>0 ? ":" : "")" ) for (k, v) in stringmap print(iob, "\n ", rpad(k, mx), " = $(v)") diff --git a/test/runtests.jl b/test/runtests.jl index 9135ae7..b3cdc3a 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -213,7 +213,6 @@ end @test FruitT.Apple === FruitT.Typ(0) let io = IOBuffer() - io = IOBuffer() show(io, "text/plain", FruitT.Typ) str = String(take!(io)) @test str == "Enum type FruitT.Typ <: Enum{Int32} with 2 instances:\n FruitT.Apple = 0\n FruitT.Banana = 1" @@ -235,4 +234,17 @@ catch err @test err.msg == "instance name Fruit.Apple reserved for the Enum typename." end + +# Empty enum +@enumx FruitEmpty +@test instances(FruitEmpty.T) == () +let io = IOBuffer() + show(io, "text/plain", FruitEmpty.T) + str = String(take!(io)) + @test str == "Enum type FruitEmpty.T <: Enum{Int32} with 0 instances" +end + +@enumx T=Typ FruitEmptyT +@test instances(FruitEmptyT.Typ) == () + end # testset