public
Created

EUnit eats my stack trace !!!

  • Download Gist
fib.erl
Erlang
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
-module(fib).
-export([fib/1]).
-include_lib("eunit/include/eunit.hrl").
 
%% this call a undef function in erlang module
fib(a) -> erlang:lists_to_atom("a");
 
fib(0) -> 1;
fib(1) -> 1;
fib(N) when N > 1 -> fib(N-1) + fib(N-2).
 
fib_test_() ->
[?_assert(fib(0) =:= 1),
?_assert(fib(1) =:= 1),
?_assert(fib(2) =:= 2),
?_assert(fib(3) =:= 3),
?_assert(fib(4) =:= 5),
?_assert(fib(5) =:= 8),
?_assertException(error, function_clause, fib(-1)),
?_assert(fib(31) =:= 2178309)
].
 
%% a error test
fib_other_test_() ->
[?_assert(fib(a) =:= "a")].
 
 
%% I'm trying this code in erlang shell.
 
> c(fib).
> {ok, fib}.
> eunit:test(fib).
fib:22: fib_other_test_...*failed*
::undef
 
====================================
Failed: 1. Skipped: 0. Passed: 8.
error
 
%%

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.