Add credo to the project and:
- Run mix credo --all to identify possible code optimizations - Resolve most of the errors generated by credo such as: - Numbers larger than 9999 should be written with underscores: 58_127 - Modules should have a @moduledoc tag - Comparison will always return true
This commit is contained in:
@@ -19,7 +19,7 @@ defmodule BlanksTest do
|
||||
end
|
||||
|
||||
test "multiple arguments" do
|
||||
ast = quote do: assert(___ == ___)
|
||||
ast = quote do: assert true == false
|
||||
|
||||
assert Blanks.replace(ast, [true, false]) == quote(do: assert(true == false))
|
||||
end
|
||||
@@ -43,7 +43,7 @@ defmodule BlanksTest do
|
||||
end
|
||||
|
||||
test "counts multiple blanks" do
|
||||
ast = quote do: assert(___ == ___)
|
||||
ast = quote do: assert ___ == ___
|
||||
|
||||
assert Blanks.count(ast) == 2
|
||||
end
|
||||
|
@@ -39,7 +39,7 @@ defmodule FailureTests do
|
||||
|
||||
test "only offending lines are displayed for errors" do
|
||||
[koan] = SingleArity.all_koans()
|
||||
error = apply(SingleArity, koan, []) |> Tuple.to_list |> List.last |> error
|
||||
error = apply(SingleArity, koan, []) |> Tuple.to_list() |> List.last() |> error
|
||||
|
||||
assert Failure.format_failure(error) == """
|
||||
Assertion failed in some_file.ex:42\nmatch?(:foo, ___)
|
||||
|
@@ -8,7 +8,7 @@ defmodule ExecuteTest do
|
||||
test "stops at the first failing koan" do
|
||||
{:failed, %{file: file, line: line}, SampleKoan, _name} = Execute.run_module(SampleKoan)
|
||||
assert file == 'test/support/sample_koan.ex'
|
||||
assert line == 8
|
||||
assert line == 9
|
||||
end
|
||||
|
||||
test "can access intro" do
|
||||
|
@@ -1,18 +1,17 @@
|
||||
defmodule ComprehensionsTests do
|
||||
use ExUnit.Case
|
||||
import TestHarness
|
||||
|
||||
test "Comprehensions" do
|
||||
answers = [
|
||||
[1, 4, 9, 16],
|
||||
[1, 4, 9, 16],
|
||||
["Hello World", "Apple Pie"],
|
||||
["little dogs", "little cats", "big dogs", "big cats"],
|
||||
[4, 5, 6],
|
||||
%{"Pecan" => "Pecan Pie", "Pumpkin" => "Pumpkin Pie"}
|
||||
]
|
||||
|
||||
test_all(Comprehensions, answers)
|
||||
end
|
||||
|
||||
end
|
||||
defmodule ComprehensionsTests do
|
||||
use ExUnit.Case
|
||||
import TestHarness
|
||||
|
||||
test "Comprehensions" do
|
||||
answers = [
|
||||
[1, 4, 9, 16],
|
||||
[1, 4, 9, 16],
|
||||
["Hello World", "Apple Pie"],
|
||||
["little dogs", "little cats", "big dogs", "big cats"],
|
||||
[4, 5, 6],
|
||||
%{"Pecan" => "Pecan Pie", "Pumpkin" => "Pumpkin Pie"}
|
||||
]
|
||||
|
||||
test_all(Comprehensions, answers)
|
||||
end
|
||||
end
|
||||
|
@@ -1,4 +1,5 @@
|
||||
defmodule PassingKoan do
|
||||
@moduledoc false
|
||||
use Koans
|
||||
|
||||
@intro "something"
|
||||
|
@@ -1,4 +1,5 @@
|
||||
defmodule SampleKoan do
|
||||
@moduledoc false
|
||||
use Koans
|
||||
|
||||
@intro """
|
||||
|
@@ -1,4 +1,5 @@
|
||||
defmodule SingleArity do
|
||||
@moduledoc false
|
||||
use Koans
|
||||
|
||||
@intro """
|
||||
|
@@ -1,4 +1,5 @@
|
||||
timeout = 1000 # ms
|
||||
# ms
|
||||
timeout = 1000
|
||||
ExUnit.start(timeout: timeout)
|
||||
|
||||
defmodule TestHarness do
|
||||
|
Reference in New Issue
Block a user