Skip to content

Commit

Permalink
Also overload show for types themselves
Browse files Browse the repository at this point in the history
  • Loading branch information
oxinabox committed Apr 6, 2023
1 parent 8afadec commit b6c06d2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/tangent.jl
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,18 @@ wrapper_name(::Type{<:ZeroBundle}) = "ZeroBundle"
wrapper_name(::Type{<:DNEBundle}) = "DNEBundle"
wrapper_name(::Type{<:AbstractZeroBundle}) = "AbstractZeroBundle"

function Base.show(io::IO, T::Type{<:AbstractZeroBundle{N, B}}) where {N,B}
print(io, wrapper_name(T))
print(io, "{$N, ")
show(io, B)
print(io, "}")
end

function Base.show(io::IO, T::Type{<:AbstractZeroBundle{N}}) where {N}
print(io, wrapper_name(T))
print(io, "{$N}")
end

function Base.show(io::IO, t::AbstractZeroBundle{N}) where N
print(io, wrapper_name(typeof(t)))
print(io, "{$N}(")
Expand Down
5 changes: 5 additions & 0 deletions test/tangent.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ using Test
@testset "Display" begin
@test repr(ZeroBundle{1}(2.0)) == "ZeroBundle{1}(2.0)"
@test repr(DNEBundle{1}(getfield)) == "DNEBundle{1}(getfield)"

@test repr(ZeroBundle{1}) == "ZeroBundle{1}"
@test repr(ZeroBundle{1, Float64}) == "ZeroBundle{1, Float64}"

@test repr(typeof(DNEBundle{1}(getfield))) == DNEBundle{1, typeof(getfield)}
end
end

Expand Down

0 comments on commit b6c06d2

Please sign in to comment.