Skip to content

Commit 7152d54

Browse files
authored
make clipboard(g) work (#121)
1 parent 13247a4 commit 7152d54

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/SimpleGraphs/SimpleGraphs.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ An abstract type representing a simple graph structure.
5050
"""
5151
abstract type AbstractSimpleGraph{T<:Integer} <: AbstractGraph{T} end
5252

53-
function show(io::IO, g::AbstractSimpleGraph{T}) where T
53+
function show(io::IO, ::MIME"text/plain", g::AbstractSimpleGraph{T}) where T
5454
dir = is_directed(g) ? "directed" : "undirected"
5555
print(io, "{$(nv(g)), $(ne(g))} $dir simple $T graph")
5656
end

test/simplegraphs/simplegraphs.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,18 @@ import Random
3030
gx = SimpleGraph()
3131
for g in testgraphs(gx)
3232
T = eltype(g)
33-
@test sprint(show, g) == "{0, 0} undirected simple $T graph"
33+
@test repr("text/plain", g) == "{0, 0} undirected simple $T graph"
3434
@test @inferred(add_vertices!(g, 5) == 5)
35-
@test sprint(show, g) == "{5, 0} undirected simple $T graph"
35+
@test repr("text/plain", g) == "{5, 0} undirected simple $T graph"
36+
@test eval(Meta.parse(repr(g))) == g
3637
end
3738
gx = SimpleDiGraph()
3839
for g in testdigraphs(gx)
3940
T = eltype(g)
40-
@test sprint(show, g) == "{0, 0} directed simple $T graph"
41+
@test repr("text/plain", g) == "{0, 0} directed simple $T graph"
4142
@test @inferred(add_vertices!(g, 5) == 5)
42-
@test sprint(show, g) == "{5, 0} directed simple $T graph"
43+
@test repr("text/plain", g) == "{5, 0} directed simple $T graph"
44+
@test eval(Meta.parse(repr(g))) == g
4345
end
4446

4547
gx = path_graph(4)

0 commit comments

Comments
 (0)