Skip to content

Commit 5e1b7d9

Browse files
author
José Valim
committed
Fix expansion_test
Signed-off-by: José Valim <[email protected]>
1 parent 38baa72 commit 5e1b7d9

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

lib/elixir/test/elixir/kernel/expansion_test.exs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ defmodule Kernel.ExpansionTest do
153153
end
154154

155155
test "locals: in guards" do
156-
assert expand(quote(do: fn pid when :erlang.==(pid, self) -> pid end)) ==
156+
assert expand_and_clean(quote(do: fn pid when :erlang.==(pid, self) -> pid end), [:import, :context]) ==
157157
quote(do: fn pid when :erlang.==(pid, :erlang.self()) -> pid end)
158158
end
159159

@@ -337,22 +337,22 @@ defmodule Kernel.ExpansionTest do
337337
## Cond
338338

339339
test "cond: expands each clause" do
340-
assert expand_and_clean(quote do: (cond do x = 1 -> x; _ -> x end)) ==
340+
assert expand(quote do: (cond do x = 1 -> x; _ -> x end)) ==
341341
quote do: (cond do x = 1 -> x; _ -> x() end)
342342
end
343343

344344
test "cond: does not share lexical scope between clauses" do
345-
assert expand_and_clean(quote do: (cond do 1 -> import List; 2 -> flatten([1, 2, 3]) end)) ==
345+
assert expand(quote do: (cond do 1 -> import List; 2 -> flatten([1, 2, 3]) end)) ==
346346
quote do: (cond do 1 -> import :"Elixir.List", []; 2 -> flatten([1, 2, 3]) end)
347347
end
348348

349349
test "cond: does not leaks vars on head" do
350-
assert expand_and_clean(quote do: (cond do x = 1 -> x; y = 2 -> y end; :erlang.+(x, y))) ==
350+
assert expand(quote do: (cond do x = 1 -> x; y = 2 -> y end; :erlang.+(x, y))) ==
351351
quote do: (cond do x = 1 -> x; y = 2 -> y end; :erlang.+(x(), y()))
352352
end
353353

354354
test "cond: leaks vars" do
355-
assert expand_and_clean(quote do: (cond do 1 -> x = 1; 2 -> y = 2 end; :erlang.+(x, y))) ==
355+
assert expand(quote do: (cond do 1 -> x = 1; 2 -> y = 2 end; :erlang.+(x, y))) ==
356356
quote do: (cond do 1 -> x = 1; 2 -> y = 2 end; :erlang.+(x, y))
357357
end
358358

@@ -365,27 +365,27 @@ defmodule Kernel.ExpansionTest do
365365
## Case
366366

367367
test "case: expands each clause" do
368-
assert expand_and_clean(quote do: (case w do x -> x; _ -> x end)) ==
368+
assert expand(quote do: (case w do x -> x; _ -> x end)) ==
369369
quote do: (case w() do x -> x; _ -> x() end)
370370
end
371371

372372
test "case: does not share lexical scope between clauses" do
373-
assert expand_and_clean(quote do: (case w do 1 -> import List; 2 -> flatten([1, 2, 3]) end)) ==
373+
assert expand(quote do: (case w do 1 -> import List; 2 -> flatten([1, 2, 3]) end)) ==
374374
quote do: (case w() do 1 -> import :"Elixir.List", []; 2 -> flatten([1, 2, 3]) end)
375375
end
376376

377377
test "case: expands guards" do
378-
assert expand_and_clean(quote do: (case w do x when x when __ENV__.context -> true end)) ==
378+
assert expand(quote do: (case w do x when x when __ENV__.context -> true end)) ==
379379
quote do: (case w() do x when x when :guard -> true end)
380380
end
381381

382382
test "case: does not leaks vars on head" do
383-
assert expand_and_clean(quote do: (case w do x -> x; y -> y end; :erlang.+(x, y))) ==
383+
assert expand(quote do: (case w do x -> x; y -> y end; :erlang.+(x, y))) ==
384384
quote do: (case w() do x -> x; y -> y end; :erlang.+(x(), y()))
385385
end
386386

387387
test "case: leaks vars" do
388-
assert expand_and_clean(quote do: (case w do x -> x = x; y -> y = y end; :erlang.+(x, y))) ==
388+
assert expand(quote do: (case w do x -> x = x; y -> y = y end; :erlang.+(x, y))) ==
389389
quote do: (case w() do x -> x = x; y -> y = y end; :erlang.+(x, y))
390390
end
391391

@@ -398,32 +398,32 @@ defmodule Kernel.ExpansionTest do
398398
## Receive
399399

400400
test "receive: expands each clause" do
401-
assert expand_and_clean(quote do: (receive do x -> x; _ -> x end)) ==
401+
assert expand(quote do: (receive do x -> x; _ -> x end)) ==
402402
quote do: (receive do x -> x; _ -> x() end)
403403
end
404404

405405
test "receive: does not share lexical scope between clauses" do
406-
assert expand_and_clean(quote do: (receive do 1 -> import List; 2 -> flatten([1, 2, 3]) end)) ==
406+
assert expand(quote do: (receive do 1 -> import List; 2 -> flatten([1, 2, 3]) end)) ==
407407
quote do: (receive do 1 -> import :"Elixir.List", []; 2 -> flatten([1, 2, 3]) end)
408408
end
409409

410410
test "receive: expands guards" do
411-
assert expand_and_clean(quote do: (receive do x when x when __ENV__.context -> true end)) ==
411+
assert expand(quote do: (receive do x when x when __ENV__.context -> true end)) ==
412412
quote do: (receive do x when x when :guard -> true end)
413413
end
414414

415415
test "receive: does not leaks clause vars" do
416-
assert expand_and_clean(quote do: (receive do x -> x; y -> y end; :erlang.+(x, y))) ==
416+
assert expand(quote do: (receive do x -> x; y -> y end; :erlang.+(x, y))) ==
417417
quote do: (receive do x -> x; y -> y end; :erlang.+(x(), y()))
418418
end
419419

420420
test "receive: leaks vars" do
421-
assert expand_and_clean(quote do: (receive do x -> x = x; y -> y = y end; :erlang.+(x, y))) ==
421+
assert expand(quote do: (receive do x -> x = x; y -> y = y end; :erlang.+(x, y))) ==
422422
quote do: (receive do x -> x = x; y -> y = y end; :erlang.+(x, y))
423423
end
424424

425425
test "receive: leaks vars on after" do
426-
assert expand_and_clean(quote do: (receive do x -> x = x after y -> y; w = y end; :erlang.+(x, w))) ==
426+
assert expand(quote do: (receive do x -> x = x after y -> y; w = y end; :erlang.+(x, w))) ==
427427
quote do: (receive do x -> x = x after y() -> y(); w = y() end; :erlang.+(x, w))
428428
end
429429

@@ -540,8 +540,8 @@ defmodule Kernel.ExpansionTest do
540540
13
541541
end
542542

543-
defp expand_and_clean(expr) do
544-
cleaner = &Keyword.drop(&1, [:export])
543+
defp expand_and_clean(expr, vars) do
544+
cleaner = &Keyword.drop(&1, vars)
545545
expr
546546
|> expand_env(__ENV__)
547547
|> elem(0)

0 commit comments

Comments
 (0)