Skip to content
Permalink
Browse files

Update Credo.Code related tests

  • Loading branch information...
rrrene committed Jul 30, 2019
1 parent 99773a1 commit 7f51b45406968d28b7435ddcfb52745e9575e1fc
Showing with 33 additions and 3 deletions.
  1. +9 −0 test/credo/code/charlists_test.exs
  2. +2 −2 test/credo/code/heredocs_test.exs
  3. +22 −1 test/credo/code_test.exs
@@ -70,4 +70,13 @@ defmodule Credo.Code.CharlistsTest do

assert expected == source |> Charlists.replace_with_spaces(".")
end

@example_code2 File.read!("test/fixtures/example_code/nested_escaped_heredocs.ex")
test "it should produce valid code /2" do
result = Charlists.replace_with_spaces(@example_code2)
result2 = Charlists.replace_with_spaces(result)

assert result == result2, "Charlists.replace_with_spaces/2 should be idempotent"
assert match?({:ok, _}, Code.string_to_quoted(result))
end
end
@@ -246,9 +246,9 @@ defmodule Credo.Code.HeredocsTest do
assert match?({:ok, _}, Code.string_to_quoted(result))
end

@example_code File.read!("test/fixtures/example_code/nested_escaped_heredocs.ex")
@example_code2 File.read!("test/fixtures/example_code/nested_escaped_heredocs.ex")
test "it should produce valid code /2" do
result = Heredocs.replace_with_spaces(@example_code)
result = Heredocs.replace_with_spaces(@example_code2)
result2 = Heredocs.replace_with_spaces(result)

assert result == result2, "Heredocs.replace_with_spaces/2 should be idempotent"
@@ -263,7 +263,28 @@ defmodule Credo.CodeTest do
"Credo.Code.clean_charlists_strings_sigils_and_comments/1 should produce valid code"
end

@example_code File.read!("test/fixtures/example_code/clean.ex")
test "it should produce valid code /3" do
result = Credo.Code.clean_charlists_strings_and_sigils(@example_code)
result2 = Credo.Code.clean_charlists_strings_and_sigils(result)

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

@example_code File.read!("test/fixtures/example_code/nested_escaped_heredocs.ex")
test "it should produce valid code /4" do
result = Credo.Code.clean_charlists_strings_and_sigils(@example_code)
result2 = Credo.Code.clean_charlists_strings_and_sigils(result)

assert result == result2,
"Credo.Code.clean_charlists_strings_and_sigils/1 should be idempotent"

assert match?({:ok, _}, Code.string_to_quoted(result)),
"Credo.Code.clean_charlists_strings_and_sigils/1 should produce valid code"
end

test "it should produce valid code /5" do
source = ~S"""
file_patt = "*.{#{ Enum.join(file_exts, ",") }}"
"""
@@ -280,7 +301,7 @@ defmodule Credo.CodeTest do
assert match?({:ok, _}, Code.string_to_quoted(result))
end

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

0 comments on commit 7f51b45

Please sign in to comment.
You can’t perform that action at this time.