Skip to content
This repository has been archived by the owner on Oct 14, 2020. It is now read-only.

Add Erlang support #478

Merged
merged 2 commits into from
Aug 5, 2017
Merged

Add Erlang support #478

merged 2 commits into from
Aug 5, 2017

Conversation

kazk
Copy link
Member

@kazk kazk commented Jul 28, 2017

Erlang/OTP 20.0, test integration with EUnit. Uses rebar3, no packages are installed for now.

-module(fib_tests).
-include_lib("eunit/include/eunit.hrl").

fib(0) -> 1;
fib(1) -> 1;
fib(N) when N > 1 -> fib(N-1) + fib(N-2).

fib_test_() ->
  {"Fib",
    [{"works for some inputs",
      [?_assertEqual(1, fib(0)),
       ?_assertEqual(1, fib(1)),
       ?_assertEqual(2, fib(2)),
       ?_assertEqual(3, fib(3)),
       ?_assertEqual(5, fib(4)),
       ?_assertEqual(8, fib(5))]},
     {"fib(31)", ?_assertEqual(2178309, fib(31))},
     {"fib(-1) errors", ?_assertException(error, function_clause, fib(-1))}]}.
<DESCRIBE::>Fib

<DESCRIBE::>works for some inputs
<IT::>Unnamed Test
<PASSED::>Test Passed
<COMPLETEDIN::>0
<IT::>Unnamed Test
<PASSED::>Test Passed
<COMPLETEDIN::>0
<IT::>Unnamed Test
<PASSED::>Test Passed
<COMPLETEDIN::>0
<IT::>Unnamed Test
<PASSED::>Test Passed
<COMPLETEDIN::>0
<IT::>Unnamed Test
<PASSED::>Test Passed
<COMPLETEDIN::>0
<IT::>Unnamed Test
<PASSED::>Test Passed
<COMPLETEDIN::>0
<COMPLETEDIN::>18

<IT::>fib(31)
<PASSED::>Test Passed
<COMPLETEDIN::>126

<IT::>fib(-1) errors
<PASSED::>Test Passed
<COMPLETEDIN::>0

<COMPLETEDIN::>150

image

Note that tests without desc attribute (derived from annotations like "fib(31)", called titles in EUnit terms) are named "Unnamed Test".
This is because:

  • Generating a name from source (module, function, arity) and id (list of integers) attributes can result in unexpected names
  • Generating a name from the "parent" group is difficult because some macros produces groups without desc

Also note that groups without desc are ignored in the output because it's hard to differentiate from groups generated by some macros.


Closes #474
Closes #46

kazk added 2 commits July 28, 2017 13:03
Elixir is locked to 1.2.4 for existing contents.
Making Elixir independent allows us to add newer versions of Erlang.
Erlang/OTP 20.0, test integration with EUnit

Note that tests without `desc` are named "Unnamed Test".
This is because:

- Generating a name from `source` and `id` can result in unexpected
  names
- Generating a name from the "parent" group is difficult because some
  macros produces groups without `desc`

Also note that groups without `desc` are ignored in the output because
it's hard to differentiate from groups generated by some macros.
@jhoffner jhoffner merged commit ddd645c into codewars:master Aug 5, 2017
@kazk kazk deleted the feature/erlang-otp20 branch August 5, 2017 01:11
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants