Skip to content

Commit

Permalink
prevent type piracy on Base.merge (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
KristofferC committed Jun 26, 2020
1 parent 5950d1d commit 8407e95
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
10 changes: 3 additions & 7 deletions src/crayon.jl
Expand Up @@ -275,13 +275,9 @@ end

Base.:*(a::Crayon, b::Crayon) = merge(a, b)

function Base.merge(toks::Crayon...)
if length(toks) == 0
return Crayon()
end
tok = toks[1]
for i in 2:length(toks)
tok = merge(tok, toks[i])
function Base.merge(tok::Crayon, toks::Crayon...)
for tok2 in toks
tok = merge(tok, tok2)
end
return tok
end
1 change: 0 additions & 1 deletion test/runtests.jl
Expand Up @@ -110,7 +110,6 @@ pop!(cs) # State change: fg = default
@test string(cs) == string(Crayon(foreground = :default))

# Merge
@test string(merge()) == ""
@test string(merge(Crayon(foreground = :blue, background = :red))) == string(Crayon(foreground = :blue, background = :red))
@test string(merge(Crayon(foreground = :blue), Crayon(background = :red))) == string(Crayon(foreground = :blue, background = :red))
@test string(merge(Crayon(foreground = :blue), Crayon(background = :red), Crayon(bold = true))) == string(Crayon(foreground = :blue, background = :red, bold = true))
Expand Down

0 comments on commit 8407e95

Please sign in to comment.