0

EUNIT モジュールを使用し、「eunit/include/eunit.hrl」を含めます。引数 func/0 を指定して spawn/1 を呼び出し、テスト関数で新しいプロセスを生成し、新しいプロセスで io:format/1 を呼び出します。引数 func/0 は、次のような再帰関数です。

func() -> 
A = 2,
io:format("#######~p~n", [A]),
timer:sleep(1000),
func().

それで

10> bt:test().
All 2 tests passed.
ok
11>
=ERROR REPORT==== 19-Jun-2013::19:50:54 ===
Error in process <0.122.0> with exit value: {terminated,[{io,format,[<0.121.0>,"
#######~p~n",[2]],[]},{bt,func,0,[{file,"bt.erl"},{line,6}]}]}

何が問題で、どうすればよいですか?

4

2 に答える 2

0

fun() の書き方は、無限再帰です。基本的には次のとおりです。

fun() ->
  fun(). 

それは決して戻らず (実行し続けます)、おそらく EUNIT による終了の理由です。

于 2013-06-19T12:45:51.903 に答える