diff --git a/src/SimpleGraphs/SimpleGraphs.jl b/src/SimpleGraphs/SimpleGraphs.jl index ac125b3c1..ecc870af3 100644 --- a/src/SimpleGraphs/SimpleGraphs.jl +++ b/src/SimpleGraphs/SimpleGraphs.jl @@ -50,7 +50,7 @@ An abstract type representing a simple graph structure. """ abstract type AbstractSimpleGraph{T<:Integer} <: AbstractGraph{T} end -function show(io::IO, g::AbstractSimpleGraph{T}) where T +function show(io::IO, ::MIME"text/plain", g::AbstractSimpleGraph{T}) where T dir = is_directed(g) ? "directed" : "undirected" print(io, "{$(nv(g)), $(ne(g))} $dir simple $T graph") end diff --git a/test/simplegraphs/simplegraphs.jl b/test/simplegraphs/simplegraphs.jl index c62b9eefd..2a1b3a12d 100644 --- a/test/simplegraphs/simplegraphs.jl +++ b/test/simplegraphs/simplegraphs.jl @@ -30,16 +30,18 @@ import Random gx = SimpleGraph() for g in testgraphs(gx) T = eltype(g) - @test sprint(show, g) == "{0, 0} undirected simple $T graph" + @test repr("text/plain", g) == "{0, 0} undirected simple $T graph" @test @inferred(add_vertices!(g, 5) == 5) - @test sprint(show, g) == "{5, 0} undirected simple $T graph" + @test repr("text/plain", g) == "{5, 0} undirected simple $T graph" + @test eval(Meta.parse(repr(g))) == g end gx = SimpleDiGraph() for g in testdigraphs(gx) T = eltype(g) - @test sprint(show, g) == "{0, 0} directed simple $T graph" + @test repr("text/plain", g) == "{0, 0} directed simple $T graph" @test @inferred(add_vertices!(g, 5) == 5) - @test sprint(show, g) == "{5, 0} directed simple $T graph" + @test repr("text/plain", g) == "{5, 0} directed simple $T graph" + @test eval(Meta.parse(repr(g))) == g end gx = path_graph(4)