Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return nothing from printfmt, fix #81 #83

Merged
merged 1 commit into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading