lytlang/test/lytlang_test.exs
2019-11-19 22:24:17 -06:00

25 lines
495 B
Elixir

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