Browse Source

Fix handling of inline comments in export/public expressions

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

2
src/runestone.jl

@ -986,7 +986,7 @@ function spaces_in_export_public(ctx::Context, node::Node)
elseif kind(kid) in KSet"Comment NewlineWs" elseif kind(kid) in KSet"Comment NewlineWs"
any_changes && push!(kids′, kid) any_changes && push!(kids′, kid)
accept_node!(ctx, kid) accept_node!(ctx, kid)
state = :expect_identifier state = :expect_space
else else
@assert false @assert false
end end

2
test/runtests.jl

@ -850,6 +850,8 @@ end
@test format_string("$(verb) $(a)$(sp),\n$(b)") == "$(verb) $(a),\n $(b)" @test format_string("$(verb) $(a)$(sp),\n$(b)") == "$(verb) $(a),\n $(b)"
@test format_string("$(verb) \n$(a)$(sp),\n$(b)") == "$(verb)\n $(a),\n $(b)" @test format_string("$(verb) \n$(a)$(sp),\n$(b)") == "$(verb)\n $(a),\n $(b)"
@test format_string("$(verb) $(a)$(sp),\n# b\n$(b)") == "$(verb) $(a),\n # b\n $(b)" @test format_string("$(verb) $(a)$(sp),\n# b\n$(b)") == "$(verb) $(a),\n # b\n $(b)"
# Inline comments
@test format_string("export a$(sp),$(sp)#= b, =#$(sp)c") == "export a, #= b, =# c"
end end
# Interpolated identifiers (currently only expected in K"quote" and K"macrocall") # Interpolated identifiers (currently only expected in K"quote" and K"macrocall")
@test format_string(":(export \$a)") == ":(export \$a)" @test format_string(":(export \$a)") == ":(export \$a)"

Loading…
Cancel
Save