Skip to content

Commit

Permalink
Return nothing from printfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
ScottPJones committed Mar 26, 2024
1 parent 37b5c92 commit 44882d5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/fmtspec.jl
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ function printfmt(io::IO, fs::FormatSpec, x)
else # cls == 'c'
_pfmt_s(io, fs, Char(x))
end
nothing
end

printfmt(fs::FormatSpec, x) = printfmt(_stdout(), fs, x)
Expand Down
1 change: 1 addition & 0 deletions src/formatexpr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ function printfmt(io::IO, fe::FormatExpr, args...)
end
end
isempty(fe.suffix) || print(io, fe.suffix)
nothing
end

const StringOrFE = Union{AbstractString, FormatExpr}
Expand Down
10 changes: 5 additions & 5 deletions test/fmtspec.jl
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,13 @@ end
# May need to change how separators are handled with zero padding,
# to produce the same results as Python

# @test pyfmt("08,d", 1234) == "0,001,234"
# @test pyfmt("09,d", 1234) == "0,001,234"
# @test pyfmt("010,d", 1234) == "00,001,234"
@test_broken pyfmt("08,d", 1234) == "0,001,234"
@test_broken pyfmt("09,d", 1234) == "0,001,234"
@test_broken pyfmt("010,d", 1234) == "00,001,234"

@test pyfmt("+#012_b", 42) == "+0b0010_1010"
# @test pyfmt("+#013_b", 42) == "+0b0_0010_1010"
# @test pyfmt("+#014_b", 42) == "+0b0_0010_1010"
@test_broken pyfmt("+#013_b", 42) == "+0b0_0010_1010"
@test_broken pyfmt("+#014_b", 42) == "+0b0_0010_1010"

end

Expand Down
12 changes: 8 additions & 4 deletions test/formatexpr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,17 @@
@test_throws(ErrorException, format("{1", 10) )

f = FormatExpr("{1:s}")
printfmt(f,"")
printfmtln(f,"")
printfmt(f, "")
printfmtln(f, "")
io = IOBuffer()
printfmt(io,f,"foobar")
printfmt(io, f, "foobar")
@test io.size == 6
printfmtln(io,f,"ugly")
printfmtln(io, f, "ugly")
@test io.size == 11

# Issue #81
@test printfmt("{:d}", 1000) == nothing

end

@testset "format escape {{ and }}" begin
Expand Down

0 comments on commit 44882d5

Please sign in to comment.