Skip to content

Commit

Permalink
Remove returns and testing to check show a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
richardreeve committed Nov 22, 2023
1 parent 1124194 commit 09bd868
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/LinkTree.jl
Original file line number Diff line number Diff line change
Expand Up @@ -435,51 +435,51 @@ import Base.show
function show(io::IO, node::LinkNode{Unrooted})
print(io, "Unrooted LinkNode '$(node.name)', with $(length(node.other)) connection(s).")
if length(node.other) == 0
println(io, "a node with no connections.")
print(io, "a node with no connections.")

Check warning on line 438 in src/LinkTree.jl

View check run for this annotation

Codecov / codecov/patch

src/LinkTree.jl#L438

Added line #L438 was not covered by tests
elseif length(node.other) == 1
println(io, "a node with 1 connection (branch $(node.other[1].name))")
print(io, "a node with 1 connection (branch $(node.other[1].name))")

Check warning on line 440 in src/LinkTree.jl

View check run for this annotation

Codecov / codecov/patch

src/LinkTree.jl#L440

Added line #L440 was not covered by tests
else
print(io, "a node with $(length(node.other)) outbound connections (branches $(node.other[1].name)")
for i in 2:length(node.other)
print(io, ", $(node.other[i].name)")
end
println(io, ")")
print(io, ")")

Check warning on line 446 in src/LinkTree.jl

View check run for this annotation

Codecov / codecov/patch

src/LinkTree.jl#L446

Added line #L446 was not covered by tests
end
end

function show(io::IO, node::LinkNode)
print(io, "LinkNode $(node.name), ")
if ismissing(node.inbound)
if length(node.other) == 0
println(io, "an isolated node with no connections.")
print(io, "an isolated node with no connections.")

Check warning on line 454 in src/LinkTree.jl

View check run for this annotation

Codecov / codecov/patch

src/LinkTree.jl#L454

Added line #L454 was not covered by tests
elseif length(node.other) == 1
println(io, "a root node with 1 outbound connection (branch $(node.other[1].name))")
print(io, "a root node with 1 outbound connection (branch $(node.other[1].name))")

Check warning on line 456 in src/LinkTree.jl

View check run for this annotation

Codecov / codecov/patch

src/LinkTree.jl#L456

Added line #L456 was not covered by tests
else
print(io, "a root node with $(length(node.other)) outbound connections (branches $(node.other[1].name)")
for i in 2:length(node.other)
print(io, ", $(node.other[i].name)")
end
println(io, ")")
print(io, ")")

Check warning on line 462 in src/LinkTree.jl

View check run for this annotation

Codecov / codecov/patch

src/LinkTree.jl#L462

Added line #L462 was not covered by tests
end
else
if length(node.other) == 0
println(io, "a tip of the tree with an incoming connection (branch $(node.inbound.name)).")
print(io, "a tip of the tree with an incoming connection (branch $(node.inbound.name)).")
elseif length(node.other) == 1
println(io, "an internal node with 1 inbound and 1 outbound connection (branches $(node.inbound.name) and $(node.other[1].name))")
print(io, "an internal node with 1 inbound and 1 outbound connection (branches $(node.inbound.name) and $(node.other[1].name))")

Check warning on line 468 in src/LinkTree.jl

View check run for this annotation

Codecov / codecov/patch

src/LinkTree.jl#L468

Added line #L468 was not covered by tests
else
print(io, "an internal node with 1 inbound and $(length(node.other)) outbound connections (branches $(node.inbound.name) and $(node.other[1].name)")
for i in 2:length(node.other)
print(io, ", $(node.other[i].name)")
end
println(io, ")")
print(io, ")")
end
end
end

function show(io::IO, branch::LinkBranch{Unrooted})
println(io, "Unrooted LinkBranch $(branch.name), connecting nodes $(branch.inout[1].name) and $(branch.inout[2].name)$(ismissing(branch.length) ? "" : " (length $(branch.length))").")
print(io, "Unrooted LinkBranch $(branch.name), connecting nodes $(branch.inout[1].name) and $(branch.inout[2].name)$(ismissing(branch.length) ? "" : " (length $(branch.length))").")

Check warning on line 480 in src/LinkTree.jl

View check run for this annotation

Codecov / codecov/patch

src/LinkTree.jl#L480

Added line #L480 was not covered by tests
end

function show(io::IO, branch::LinkBranch)
println(io, "LinkBranch $(branch.name), from node $(branch.inout[1].name) to node $(branch.inout[2].name)$(ismissing(branch.length) ? "" : " (length $(branch.length))").")
print(io, "LinkBranch $(branch.name), from node $(branch.inout[1].name) to node $(branch.inout[2].name)$(ismissing(branch.length) ? "" : " (length $(branch.length))").")
end
2 changes: 2 additions & 0 deletions test/test_show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ a = IOBuffer()
@test_nowarn show(a, ps)
@test_nowarn show(a, first(nodeiter(ps)))
@test_nowarn show(a, first(branchiter(ps)))
@test_nowarn show(a, (ps, first(getnodes(ps))))
@test_nowarn show(a, (ps, first(getbranches(ps))))
end
end

0 comments on commit 09bd868

Please sign in to comment.