Atom becomes None when passed down through nested funs and not used in intermediate
KronicDeth opened this issue · 1 comments
KronicDeth commented
Source
Put all the source in a common directory, such as src
.
src/init.erl
-module(init).
-export([start/0]).
-import(erlang, [display/1]).
start() ->
test:each(fun
(AugendNumber) when is_number(AugendNumber) -> ignore;
(AugendTerm) -> test:each(fun
(AddendNumber) when is_number(AddendNumber) -> test:caught(fun () ->
display({augend, AugendTerm}),
display({addend, AddendNumber}),
AugendTerm + AddendNumber
end);
(_AddendTerm) -> ignore
end)
end).
src/test.erl
-module(test).
-export([atom/0, big_integer/0, binary/0, caught/1, each/1, float/0, function/0, list/0, map/0, nil/0, pid/0, reference/0, small_integer/0, tuple/0]).
-import(erlang, [display/1]).
-import(lumen, [is_big_integer/1, is_small_integer/1]).
caught(Fun) ->
try apply(Fun, []) of
Return ->
display({returned, Return})
catch
Class:Exception ->
display({caught, Class, Exception})
end.
each(Fun) ->
apply(Fun, [atom()]),
apply(Fun, [big_integer()]),
apply(Fun, [binary()]),
apply(Fun, [float()]),
apply(Fun, [function()]),
apply(Fun, [list()]),
apply(Fun, [map()]),
apply(Fun, [nil()]),
apply(Fun, [pid()]),
apply(Fun, [reference()]),
apply(Fun, [small_integer()]),
apply(Fun, [tuple()]).
%% Types
atom() ->
Atom = atom,
true = is_atom(Atom),
Atom.
big_integer() ->
test_big_integer:positive().
binary() ->
Binary = <<>>,
true = is_binary(Binary),
Binary.
float() ->
test_float:zero().
function() ->
Fun = fun () ->
ok
end,
true = is_function(Fun),
Fun.
list() ->
List = [hd | tl],
true = is_list(List),
List.
map() ->
Map = #{},
true = is_map(Map),
Map.
nil() ->
Nil = [],
true = is_list(Nil),
0 = length(Nil),
Nil.
pid() ->
Pid = self(),
true = is_pid(Pid),
Pid.
reference() ->
Reference = make_ref(),
true = is_reference(Reference),
Reference.
small_integer() ->
test_small_integer:zero().
tuple() ->
Tuple = {},
true = is_tuple(Tuple),
Tuple.
src/test_big_integer.erl
-module(test_big_integer).
-export([negative/0, positive/0]).
-import(lumen, [is_big_integer/1]).
negative() ->
Negative = -1 * positive(),
true = is_big_integer(Negative),
true = (Negative < 0),
Negative.
positive() ->
Positive = (1 bsl 64),
true = is_big_integer(Positive),
true = (Positive > 0),
Positive.
serc/test_float.erl
-module(test_float).
-export([negative/0, zero/0, positive/0]).
-import(lumen, [is_small_integer/1]).
negative() ->
Negative = -1.2,
true = is_float(Negative),
true = (Negative < 0.0),
Negative.
zero() ->
Zero = 0.0,
true = is_float(Zero),
Zero.
positive() ->
Positive = 3.4,
true = is_float(Positive),
true = (Positive > 0.0),
Positive.
src/test_small_integer.erl
-module(test_small_integer).
-export([negative/0, zero/0, positive/0]).
-import(lumen, [is_small_integer/1]).
negative() ->
Negative = -1,
true = is_small_integer(Negative),
true = (Negative < 0),
Negative.
zero() ->
Zero = 0,
true = is_small_integer(Zero),
Zero.
positive() ->
Positive = 1,
true = is_small_integer(Positive),
true = (Positive > 0),
Positive.
Output
Actual
{augend, NoneValue { backtrace: <disabled> }}
{addend, atom}
Expected
{augend, atom}
{addend, atom}
...
bcardarella commented
@bitwalker fixed, closing