Skip to content

Commit

Permalink
Try to reproduce #671
Browse files Browse the repository at this point in the history
  • Loading branch information
rrrene committed Jul 16, 2019
1 parent 9a53f4b commit 9e89e7a
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/credo/code/interpolation_helper_test.exs
Expand Up @@ -454,4 +454,17 @@ defmodule Credo.Code.InterpolationHelperTest do

assert expected == InterpolationHelper.replace_interpolations(source, "$")
end

@tag needs_elixir: "1.7.0"
test "it should replace a single interpolation in a string" do
source = ~S"""
file_patt = "*.{#{ Enum.join(file_exts, ",") }}"
"""

expected = ~S"""
file_patt = "*.{$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$}"
"""

assert expected == InterpolationHelper.replace_interpolations(source, "$")
end
end
34 changes: 34 additions & 0 deletions test/credo/code_test.exs
Expand Up @@ -251,6 +251,40 @@ defmodule Credo.CodeTest do
assert match?({:ok, _}, Code.string_to_quoted(result))
end

test "it should produce valid code /2" do
source = ~S"""
file_patt = "*.{#{ Enum.join(file_exts, ",") }}"
"""

expected = ~S"""
file_patt = " "
"""

result = Credo.Code.clean_charlists_strings_sigils_and_comments(source)
result2 = Credo.Code.clean_charlists_strings_sigils_and_comments(result)

assert result == expected
assert result == result2, "clean_charlists_strings_sigils_and_comments/2 should be idempotent"
assert match?({:ok, _}, Code.string_to_quoted(result))
end

test "it should produce valid code /3" do
source = ~S"""
file_patt = "*.{#{ Enum.join(file_exts, ",") }}"
"""

expected = ~S"""
file_patt = " "
"""

result = Credo.Code.clean_charlists_strings_and_sigils(source)
result2 = Credo.Code.clean_charlists_strings_and_sigils(result)

assert result == expected
assert result == result2, "clean_charlists_strings_and_sigils/2 should be idempotent"
assert match?({:ok, _}, Code.string_to_quoted(result))
end

test "returns ast without metadata" do
ast =
{:__block__, [],
Expand Down

0 comments on commit 9e89e7a

Please sign in to comment.