-module(funTest).

-include("utComMisc.hrl").

-compile([export_all, nowarn_function, nowarn_unused_vars, nowarn_export_all]).

test2(A) ->
   Fun1 = fun(A1, A2, A3, A4, A5, Fun1) ->
      if A1 > 100 ->
         A1 + A2;
         true ->
            Fun1(A1, A2, A3, A4, A5, A2) end
   end,
   Fun1(A, A, A, A, A, Fun1).

test3(A) ->
   [O * 2 || O <- A],
   ok.

-define(types, [1, 1.1, [], [1], {1}, #{}, <<"123">>, self()]).

type1() ->
   [dataType(One) || One <-  ?types],
   ok.

dataType(Data) when is_list(Data) -> list_do;
dataType(Data) when is_integer(Data) -> integer_do;
dataType(Data) when is_binary(Data) -> binary_do;
dataType(Data) when is_function(Data) -> function_do;
dataType(Data) when is_tuple(Data) -> tuple_do;
dataType(Data) when is_atom(Data) -> atom_do;
dataType(Data) when is_float(Data) -> float_do;
dataType(Data) when is_number(Data) -> number_do;
dataType(Data) when is_pid(Data) -> pid_do;
dataType(Data) when is_port(Data) -> port_do;
dataType(_Data) -> not_know_do.

type2() ->
   [erts_internal:term_type(One) || One <-  ?types],
   ok.

dataType(nil, Data) when is_list(Data) -> list_do;
dataType(list, Data) when is_list(Data) -> list_do;
dataType(fixnum, Data) when is_integer(Data) -> integer_do;
dataType(bignum, Data) when is_integer(Data) -> integer_do;
dataType(refc_binary, Data) when is_binary(Data) -> binary_do;
dataType(heap_binary, Data) when is_binary(Data) -> binary_do;
dataType(sub_binary, Data) when is_binary(Data) -> binary_do;
dataType(tuple, Data) when is_tuple(Data) -> tuple_do;
dataType(atom, Data) when is_atom(Data) -> atom_do;
dataType(hfloat, Data) when is_float(Data) -> float_do;
dataType(pid, Data) when is_pid(Data) -> pid_do;
dataType(pid, Data) when is_pid(Data) -> pid_do;
dataType(external_pid, Data) when is_port(Data) -> port_do;
dataType(_, _Data) -> not_know_do.

type3() ->
   [dataType(eTermType:termType(One), One) || One <-  ?types],
   ok.

ok(0) ->
   ok;
ok(N) ->
   ok(N - 1).

test(A) ->
   ?IIF(lists:keyfind(a, 1, A), false, none, {_, V}, V).




