We were only asserting that some code raised an error (ArgumentError),
but we weren't asserting on the message, thus making the test's context
hard to grasp. I added the error message in the assertion and reworded
the test name a bit.
Prior to this change it is possible to send any two-pair tuple to
`GenServer.reply/2` and it will happily return `:ok`, catching any
errors. This leads to some hard to track-down bugs if you pass
it the wrong term.
This is not supported as of today because of bugs regarding defoverride
and macros, but we decided to not support overriding private macros at
all so let's raise a nice error message.
For the record, supporting overridable private macros would be very
annoying since we rely on function names and the such for implementing
overridable stuff, and for private macros we just generate functions on
the fly.
* Callback-related tests use beam AST to find callbacks
* Fix invalid function call warning on OTP 19
* Skip dialyzer-related tests on OTP 19
* Fix IEx h helper for OTP 19
* Improve IEx h helper test for multi-arity callbacks
This test was using an arcane dance to assert that some code would raise
an exception (with try/rescue, flunk, and so on) and using
:elixir.eval/2 as well; these remains of ancient times have been
replaced with Code.eval_string/1 and assert_raise/3 for more modern
Elixir code.
Before this patch, we could announce a struct too early,
only when __struct__/0 was defined (and not __struct__/1)
leading to deadlocks in the compiler. We fixed the bug and
made struct announcements to avoid future bugs.
Closes#4844
Under Windows (7 Pro, 64 bit) the Kernel.DialyzerTest fails:
1) Kernel.DialyzerTest: failure on setup_all callback, tests invalidated
** (ErlangError) erlang error: {:dialyzer_error, 'The HOME environment variable needs to be set so that Dialyzer knows where to find the default PLT'}
stacktrace:
dialyzer.erl:173: :dialyzer.run/1
lib/elixir/test/elixir/kernel/dialyzer_test.exs:21: Kernel.DialyzerTest.__ex_unit_setup_all_0/1
lib/elixir/test/elixir/kernel/dialyzer_test.exs:3: Kernel.DialyzerTest.__ex_unit__/2
Actually this is an erlang error: dialyzer expects the environment variable HOME set.
But Windows does not have this environment variable available.
(It has HOMEDRIVE and HOMEPATH.)
This commit makes the DialyzerTest pass by setting the HOME environment variable (when necessary).
Using System.user_home to set the HOME env var works because System.user_home uses `:elixir_config.get(:home)`.
`elixir_config` gets the value of `:home` from `init:get_argument(home)` (see file `lib\elixir\src\elixir.erl`)
And - finally - erlang honors these environment variables when computing `home`
(see https://github.com/erlang/otp/blob/maint/erts/etc/common/erlexec.c#L1548-L1549).
Erlang sometimes uses `os:getenv("HOME")` and sometimes `init:get_argument(home)` to get the home directory of the user.
* SigilsTest fails for newline under Windows
1) test sigil S (Kernel.SigilsTest)
lib/elixir/test/elixir/kernel/sigils_test.exs:18
Assertion with == failed
code: ~S"foo\\\r\nbar" == "foo\\\nbar"
lhs: "foo\\\r\nbar"
rhs: "foo\\\nbar"
stacktrace:
lib/elixir/test/elixir/kernel/sigils_test.exs:32: (test)
[Newlines](https://en.wikipedia.org/wiki/Newline).
[Github](https://help.github.com/articles/dealing-with-line-endings/#platform-windows)
recommends setting `core.autocrlf true` on Windows for cross-platform projects.
[Git documentation](https://git-scm.com/book/tr/v2/Customizing-Git-Git-Configuration#Formatting-and-Whitespace)
also recommends this setting on Windows.
Using this setting let the SigilsTest fail because the sigil contains a newline which is `\r\n` under Windows and not `\n`.
Use os dependent tests for newline.
* Remove unnecessary new lines