lytlang/test/lytlang_test.exs
Daniel Flanagan 06f1e3195f WIP
2019-11-15 11:19:38 -06:00

22 lines
438 B
Elixir

defmodule LytlangTest do
use ExUnit.Case
doctest Lytlang
test "arithmetic" do
[
{"2 + 3 + 8", 13},
{"2 * 3 + 8", 14},
{"2 + 3 * 8", 26},
{"(2 + 3) * 8", 40},
{"2 * (3 + 8)", 22},
{"2 + (3 * 8)", 26},
{"8 - 3", 5},
{"8 / 4", 2.0},
{"a = 8\na + 9", 17},
{"2 + 3", 5}
]
|> Enum.map(fn {string, val} ->
assert Lytlang.eval(string) == val
end)
end
end