summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@plataformatec.com.br>2018-12-11 19:21:42 +0100
committerJosé Valim <jose.valim@plataformatec.com.br>2018-12-11 19:50:22 +0100
commit55ead12b0a69504fc1ef8fdc3a3d4b7a0a015dd7 (patch)
tree6ae53b8cd4a6f82dedfa25abaf92ad515d3435d5
parent95934e56c4930d9bde8bc3d0c998e1c7c823b8e9 (diff)
downloadelixir-55ead12b0a69504fc1ef8fdc3a3d4b7a0a015dd7.tar.gz
Move record warning to warning test file
-rw-r--r--lib/elixir/test/elixir/kernel/warning_test.exs15
-rw-r--r--lib/elixir/test/elixir/record_test.exs13
2 files changed, 15 insertions, 13 deletions
diff --git a/lib/elixir/test/elixir/kernel/warning_test.exs b/lib/elixir/test/elixir/kernel/warning_test.exs
index 1df6c3ccd..3aad3a483 100644
--- a/lib/elixir/test/elixir/kernel/warning_test.exs
+++ b/lib/elixir/test/elixir/kernel/warning_test.exs
@@ -1674,6 +1674,21 @@ defmodule Kernel.WarningTest do
assert message =~ "\"else\" shouldn't be used as the only clause in \"try\""
end
+ test "warns on bad record update input" do
+ assert capture_err(fn ->
+ defmodule Sample do
+ require Record
+ Record.defrecord(:user, __MODULE__, name: "john", age: 25)
+
+ def fun do
+ user(user(), _: :_, name: "meg")
+ end
+ end
+ end) =~ "updating a record with a default (:_) is equivalent to creating a new record"
+ after
+ purge([Sample])
+ end
+
defp purge(list) when is_list(list) do
Enum.each(list, &purge/1)
end
diff --git a/lib/elixir/test/elixir/record_test.exs b/lib/elixir/test/elixir/record_test.exs
index ad2439782..0ab806d01 100644
--- a/lib/elixir/test/elixir/record_test.exs
+++ b/lib/elixir/test/elixir/record_test.exs
@@ -129,19 +129,6 @@ defmodule RecordTest do
refute match?(user(_: "other"), user())
end
- test "warns when updating a record with default value" do
- captured =
- capture_io(:stderr, fn ->
- expanded = Macro.expand(quote(do: user(user(), _: :_, name: "meg")), __ENV__)
- {record, _} = Code.eval_quoted(expanded)
-
- assert user(record, :name) == "meg"
- assert user(record, :age) == :_
- end)
-
- assert captured =~ "updating a record with a default"
- end
-
Record.defrecord(
:defaults,
struct: ~D[2016-01-01],