Add argument to koan to allow it to be tested

This commit is contained in:
Felipe Sere
2016-03-09 23:31:27 +00:00
parent a212f674e0
commit fdb87b529f
5 changed files with 83 additions and 2 deletions

35
test/ast_mangler_test.exs Normal file
View File

@@ -0,0 +1,35 @@
defmodule ASTManglerTest do
use ExUnit.Case, async: true
test "simple replacement" do
ast = quote do: 1 + :__
mangled = ASTMangler.expand(ast, 37)
assert {:+, [context: ASTManglerTest, import: Kernel], [1, 37]} == mangled
end
def complex_example do
[head | tail] = [1,2,3,4]
assert head == 1
assert tail == [2,3,4]
end
def foo(answer) do
if answer == :yes do
:bar
else
:batz
end
end
test "something" do
n = 1
end
test "complex example" do
ast = [do: {:assert, [line: 5], [{:==, [line: 5], [true, :__]}]}]
assert [do: {:assert, [line: 5], [{:==, [line: 5], [true, true]}]}] == ASTMangler.expand(ast, true)
end
end

9
test/power_test.exs Normal file
View File

@@ -0,0 +1,9 @@
defmodule PowerTest do
use ExUnit.Case
test "something" do
[first | _] = Equalities.all_koans
assert :passed == Runner.test_single_koan(Equalities, first, true)
end
end