diff options
author | Björn Gustavsson <[email protected]> | 2010-01-19 11:34:56 +0000 |
---|---|---|
committer | Erlang/OTP <[email protected]> | 2010-01-19 13:01:29 +0100 |
commit | 74d7b1b942c6f1d984e263f6675a9423197a3215 (patch) | |
tree | 4644ffbb46b3f166507ffa8739e5ecbfccd4aba7 /lib/tools/test/cover_SUITE_data/a.erl | |
parent | 81f4b1f7f453e1242d7f81ef2347230a9ff3fb0f (diff) | |
download | otp-74d7b1b942c6f1d984e263f6675a9423197a3215.tar.gz otp-74d7b1b942c6f1d984e263f6675a9423197a3215.tar.bz2 otp-74d7b1b942c6f1d984e263f6675a9423197a3215.zip |
Add test suite for the tools application
Diffstat (limited to 'lib/tools/test/cover_SUITE_data/a.erl')
-rw-r--r-- | lib/tools/test/cover_SUITE_data/a.erl | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/lib/tools/test/cover_SUITE_data/a.erl b/lib/tools/test/cover_SUITE_data/a.erl new file mode 100644 index 0000000000..31119821cd --- /dev/null +++ b/lib/tools/test/cover_SUITE_data/a.erl @@ -0,0 +1,55 @@ +-module(a). +-export([start/1, stop/1]). +-export([pong/1]). +-export([loop/3,exit_kalle/0]). + +%% start(N) -> pid() +%% N = integer() +start(N) -> + Pong = b:start(), + spawn(?MODULE, loop, [self(), N, Pong]), + receive + done -> + {exit,kalle} = trycatch(fun ?MODULE:exit_kalle/0), + {throw,kalle} = trycatch(fun() -> throw(kalle) end), + done + end. + +%% stop(Ping) -> stop +%% Ping = pid() +stop(Ping) -> + Ping ! stop. + +%% pong(Ping) -> pong +%% Ping = pid() +pong(Ping) -> + Ping ! pong. + +%%--Internal functions------------------------------------------------ + +loop(Starter, N, Pong) when N>0 -> + Pong ! {ping, self()}, + receive + pong -> + loop(Starter, N-1, Pong); + stop -> + done + end; +loop(Starter, 0, Pong) -> + Pong ! stop, + Starter ! done. + + +trycatch(Fun) -> + try Fun() + catch + Throw -> + {throw,Throw}; + exit:Reason -> + {exit,Reason} + after + cleanup + end. + +exit_kalle() -> + exit(kalle). |