Skip to content

Commit

Permalink
backport tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
oscardssmith authored Oct 21, 2022
1 parent 66e7683 commit 0d28d0b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2355,3 +2355,16 @@ end
@test sprint(show, setenv(setcpuaffinity(`true`, [1, 2]), "A" => "B")) ==
"""setenv(setcpuaffinity(`true`, [1, 2]),["A=B"])"""
end

# Test that alignment takes into account unicode and computes alignment without
# color/formatting.

struct ColoredLetter; end
Base.show(io::IO, ces::ColoredLetter) = Base.printstyled(io, 'A'; color=:red)

struct ⛵; end
Base.show(io::IO, ces::⛵) = Base.print(io, '')

@test Base.alignment(stdout, ()) == (0, 2)
@test Base.alignment(IOContext(IOBuffer(), :color=>true), ColoredLetter()) == (0, 1)
@test Base.alignment(IOContext(IOBuffer(), :color=>false), ColoredLetter()) == (0, 1)

0 comments on commit 0d28d0b

Please sign in to comment.