Browse Source

Remove trailing `;` in paren-blocks

pull/19/head
Fredrik Ekre 1 year ago
parent
commit
6e59ab3196
No known key found for this signature in database
GPG Key ID: DE82E6D5E364C0A2
  1. 2
      src/runestone.jl
  2. 6
      test/runtests.jl

2
src/runestone.jl

@ -607,7 +607,7 @@ function spaces_in_listlike(ctx::Context, node::Node) @@ -607,7 +607,7 @@ function spaces_in_listlike(ctx::Context, node::Node)
end
else
@assert state === :expect_closing
if kind(kid′) === K"," ||
if kind(kid′) === K"," || kind(kid′) === K";" ||
(kind(kid′) === K"Whitespace" && peek(i) !== K"Comment")
# Trailing comma (when not wanted) and space not followed by a comment are
# removed

6
test/runtests.jl

@ -201,7 +201,7 @@ end @@ -201,7 +201,7 @@ end
end
end
@testset "spaces in lists" begin
@testset "spaces in listlike" begin
for sp in ("", " ", " "), a in ("a", "a + a", "a(x)"), b in ("b", "b + b", "b(y)")
# tuple, call, dotcall, vect, ref
for (o, c) in (("(", ")"), ("f(", ")"), ("f.(", ")"), ("[", "]"), ("T[", "]"))
@ -271,6 +271,10 @@ end @@ -271,6 +271,10 @@ end
@test format_string("$(x){\n$(sp)$(a)$(sp);$(sp)$(b)$(sp)\n}") ==
"$(x){\n $(a); $(b)$(tr)\n}"
end
# Trailing `;` in paren-block
@test format_string("(a = A;)") == "(a = A)"
@test format_string("cond && (a = A;)") == "cond && (a = A)"
@test format_string("(a = A; b = B;)") == "(a = A; b = B)"
end
@testset "whitespace around ->" begin

Loading…
Cancel
Save