Browse Source

Indent instances in show.

pull/8/head
Fredrik Ekre 4 years ago
parent
commit
f2ed44fe0c
  1. 2
      src/EnumX.jl
  2. 4
      test/runtests.jl

2
src/EnumX.jl

@ -115,7 +115,7 @@ function Base.show(io::IO, ::MIME"text/plain", ::Base.Type{E}) where E <: Enum @@ -115,7 +115,7 @@ function Base.show(io::IO, ::MIME"text/plain", ::Base.Type{E}) where E <: Enum
"Enum{$(Base.Enums.basetype(E))} with $(n) instance$(n == 1 ? "" : "s"):"
)
for (k, v) in stringmap
print(iob, "\n", rpad(k, mx), " = $(v)")
print(iob, "\n ", rpad(k, mx), " = $(v)")
end
write(io, seekstart(iob))
return nothing

4
test/runtests.jl

@ -62,7 +62,7 @@ end @@ -62,7 +62,7 @@ end
let io = IOBuffer()
show(io, "text/plain", Fruit.Type)
str = String(take!(io))
@test str == "Enum type Fruit.Type <: Enum{Int32} with 2 instances:\nFruit.Apple = 0\nFruit.Banana = 1"
@test str == "Enum type Fruit.Type <: Enum{Int32} with 2 instances:\n Fruit.Apple = 0\n Fruit.Banana = 1"
show(io, "text/plain", Fruit.Apple)
str = String(take!(io))
@test str == "Fruit.Apple = 0"
@ -183,7 +183,7 @@ end @@ -183,7 +183,7 @@ end
let io = IOBuffer()
show(io, "text/plain", FruitDup.Type)
str = String(take!(io))
@test str == "Enum type FruitDup.Type <: Enum{Int32} with 2 instances:\nFruitDup.Apple = 0\nFruitDup.Banana = 0"
@test str == "Enum type FruitDup.Type <: Enum{Int32} with 2 instances:\n FruitDup.Apple = 0\n FruitDup.Banana = 0"
show(io, "text/plain", FruitDup.Apple)
str = String(take!(io))
@test str == "FruitDup.Apple = FruitDup.Banana = 0"

Loading…
Cancel
Save