You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: test/gradient/elixir_expr_test.exs
+31Lines changed: 31 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -96,6 +96,37 @@ defmodule Gradient.ElixirExprTest do
96
96
assert"receive do {:hello, msg} -> msg after 1000 -> \"nothing happened\" end"==actual
97
97
end
98
98
99
+
test"call pipe"do
100
+
actual=
101
+
elixir_to_astdo
102
+
[1,2,3]
103
+
|>Enum.map(fnx->x+1end)
104
+
|>Enum.map(&(&1+1))
105
+
end
106
+
|>ElixirExpr.pp_expr()
107
+
108
+
assert"Enum.map(Enum.map([1, 2, 3], fn x -> x + 1 end), fn _ -> _ + 1 end)"==actual
109
+
end
110
+
111
+
test"with"do
112
+
actual=
113
+
elixir_to_astdo
114
+
map=%{a: 12,b: 0}
115
+
116
+
with{:ok,a}<-Map.fetch(map,:a),
117
+
{:ok,b}<-Map.fetch(map,:b)do
118
+
a+b
119
+
else
120
+
:error->
121
+
0
122
+
end
123
+
end
124
+
|>ElixirExpr.pp_expr()
125
+
126
+
assert"map = %{a: 12, b: 0}; case :maps.find(:a, map) do {:ok, a} -> case :maps.find(:b, map) do {:ok, b} -> a + b; _gen -> case _gen do :error -> 0; _gen -> raise {:with_clause, _gen} end end; _gen -> case _gen do :error -> 0; _gen -> raise {:with_clause, _gen} end end"==
0 commit comments