Skip to content

Commit 61bb6c1

Browse files
author
José Valim
committed
Avoid race conditions on capture_err reuse
1 parent f27df20 commit 61bb6c1

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

lib/elixir/test/elixir/kernel/warning_test.exs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,16 @@ defmodule Kernel.WarningTest do
373373
purge Sample
374374
end
375375

376+
test "duplicate map keys" do
377+
assert capture_err(fn ->
378+
defmodule DuplicateKeys do
379+
assert %{a: :b, a: :c} == %{a: :c}
380+
assert %{1 => 2, 1 => 3} == %{1 => 3}
381+
assert %{:a => :b, a: :c} == %{a: :c}
382+
end
383+
end) =~ "key :a will be overridden in map"
384+
end
385+
376386
test "unused guard" do
377387
assert capture_err(fn ->
378388
Code.eval_string """

lib/elixir/test/elixir/map_test.exs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,6 @@ defmodule MapTest do
8686
assert %{1 => 2, a: :b,} == %{1 => 2, a: :b}
8787
end
8888

89-
test "maps with duplicate keys" do
90-
ExUnit.CaptureIO.capture_io :stderr, fn ->
91-
defmodule DuplicateKeys do
92-
assert %{a: :b, a: :c} == %{a: :c}
93-
assert %{1 => 2, 1 => 3} == %{1 => 3}
94-
assert %{:a => :b, a: :c} == %{a: :c}
95-
end
96-
end
97-
end
98-
9989
test "update maps" do
10090
assert %{@sample | a: 3} == %{a: 3, b: 2}
10191

0 commit comments

Comments
 (0)