Skip to content

Commit

Permalink
re-add IO tests
Browse files Browse the repository at this point in the history
  • Loading branch information
exaexa committed Nov 2, 2023
1 parent 52ee28d commit 9f688b0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
9 changes: 9 additions & 0 deletions docs/src/canonical.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ m.reactions["exchange2"] = Reaction(
)
nothing #hide

show_contains(x, y) = contains(sprint(show, MIME"text/plain"(), x), y) #src
@test show_contains(m, "reactions = ") #src
@test show_contains(m, "metabolites = ") #src
@test show_contains(m, "genes = ") #src
@test show_contains(m.reactions["and_back"], "\"export\"") #src
@test show_contains(m.reactions["forward"], "\"g1\"") #src
@test show_contains(m.metabolites["m1"], "\"inside\"") #src
@test show_contains(m.genes["g1"], "name = nothing") #src

# We should immediately find the basic accessors working:
A.stoichiometry(m)

Expand Down
10 changes: 3 additions & 7 deletions src/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,9 @@ function pretty_print_kwdef(io::Base.IO, x::T) where T
(_, cols) = displaysize(io)
for fn in fieldnames(T)
shw = repr(getfield(x, fn))
if get(io, :limit, true)::Bool
tgt_cols = max(16, cols - (2 + length(String(fn)) + 3 + 1))
if length(shw) >= tgt_cols
shw = join(collect(shw)[begin:tgt_cols]) * ""
else
shw *= ","
end
tgt_cols = max(16, cols - (2 + length(String(fn)) + 3 + 1))
if get(io, :limit, true)::Bool && length(shw) >= tgt_cols
shw = join(collect(shw)[begin:tgt_cols]) * ""
else
shw *= ","
end
Expand Down

0 comments on commit 9f688b0

Please sign in to comment.