Skip to content

Commit

Permalink
Remove deprecated code and add TODOs
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Nov 13, 2023
1 parent 65ffb5d commit a48c2d5
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 22 deletions.
2 changes: 2 additions & 0 deletions lib/elixir/lib/code/formatter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ defmodule Code.Formatter do
end
end

# TODO: Remove this clause on Elixir v2.0 once single-quoted charlists are removed
defp quoted_to_algebra(
{{:., _, [List, :to_charlist]}, meta, [entries]} = quoted,
context,
Expand Down Expand Up @@ -2224,6 +2225,7 @@ defmodule Code.Formatter do
(not interpolated?(entries) and eol_or_comments?(meta, state))
end

# TODO: Remove this clause on Elixir v2.0 once single-quoted charlists are removed
defp next_break_fits?({{:., _, [List, :to_charlist]}, meta, [[_ | _]]}, _state) do
meta[:delimiter] == ~s[''']
end
Expand Down
1 change: 1 addition & 0 deletions lib/elixir/lib/code/normalizer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ defmodule Code.Normalizer do
end

# Charlists with interpolations
# TODO: Remove this clause on Elixir v2.0 once single-quoted charlists are removed
defp do_normalize({{:., dot_meta, [List, :to_charlist]}, call_meta, [parts]} = quoted, state) do
if list_interpolated?(parts) do
parts =
Expand Down
22 changes: 0 additions & 22 deletions lib/elixir/test/elixir/code_normalizer/quoted_ast_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -688,28 +688,6 @@ defmodule Code.Normalizer.QuotedASTTest do
assert quoted_to_string(~c"\x00\x01\x10") == ~S/[0, 1, 16]/
end

test "charlists with interpolations" do
# using string_to_quoted to avoid the formatter fixing the charlists

assert Code.string_to_quoted!(~S/'one #{2} three'/) |> quoted_to_string(escape: false) ==
~S/~c"one #{2} three"/

assert Code.string_to_quoted!(~S/'one #{2} three'/) |> quoted_to_string() ==
~S/~c"one #{2} three"/

assert Code.string_to_quoted!(~S/'one\n\'#{2}\'\nthree'/) |> quoted_to_string(escape: false) ==
~s[~c"one\n'\#{2}'\nthree"]

assert Code.string_to_quoted!(~S/'one\n\'#{2}\'\nthree'/) |> quoted_to_string() ==
~S[~c"one\n'#{2}'\nthree"]

assert Code.string_to_quoted!(~S/'one\n"#{2}"\nthree'/) |> quoted_to_string(escape: false) ==
~s[~c"one\n\\"\#{2}\\"\nthree"]

assert Code.string_to_quoted!(~S/'one\n"#{2}"\nthree'/) |> quoted_to_string() ==
~S[~c"one\n\"#{2}\"\nthree"]
end

test "atoms" do
assert quoted_to_string(quote(do: :"a\nb\tc"), escape: false) == ~s/:"a\nb\tc"/
assert quoted_to_string(quote(do: :"a\nb\tc")) == ~S/:"a\nb\tc"/
Expand Down

0 comments on commit a48c2d5

Please sign in to comment.