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/d1 | |
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/d1')
-rw-r--r-- | lib/tools/test/cover_SUITE_data/d1/e.erl | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/lib/tools/test/cover_SUITE_data/d1/e.erl b/lib/tools/test/cover_SUITE_data/d1/e.erl new file mode 100644 index 0000000000..b4041d48e6 --- /dev/null +++ b/lib/tools/test/cover_SUITE_data/d1/e.erl @@ -0,0 +1,127 @@ +-module(e). +-behaviour(gen_server). + +%% External exports +-export([start_link/0]). +-export([hello/0]). + +%% gen_server callbacks +-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, + code_change/3]). + +-record(state, {}). + +%%%---------------------------------------------------------------------- +%%% API +%%%---------------------------------------------------------------------- +start_link() -> + gen_server:start_link({local, myserver}, myserver, [], []). + +hello() -> + gen_server:call(myserver, hello). + +%%%---------------------------------------------------------------------- +%%% Callback functions from gen_server +%%%---------------------------------------------------------------------- + +%%---------------------------------------------------------------------- +%% Func: init/1 +%% Returns: {ok, State} | +%% {ok, State, Timeout} | +%% ignore | +%% {stop, Reason} +%%---------------------------------------------------------------------- +init([]) -> + {ok, #state{}}. + +%%---------------------------------------------------------------------- +%% Func: handle_call/3 +%% Returns: {reply, Reply, State} | +%% {reply, Reply, State, Timeout} | +%% {noreply, State} | +%% {noreply, State, Timeout} | +%% {stop, Reason, Reply, State} | (terminate/2 is called) +%% {stop, Reason, State} (terminate/2 is called) +%%---------------------------------------------------------------------- +handle_call(Request, From, State) -> + Reply = case Request of + char -> + $B; + integer -> + 17; + float -> + 32.76; + string -> + "hi there"; + atom -> + hello; + block -> + begin + a, + b + end; + binary -> + <<1, 2, 3>> + end, + {reply, Reply, State}. + +%%---------------------------------------------------------------------- +%% Func: handle_cast/2 +%% Returns: {noreply, State} | +%% {noreply, State, Timeout} | +%% {stop, Reason, State} (terminate/2 is called) +%%---------------------------------------------------------------------- +handle_cast(Msg, State) when atom(Msg) -> + {noreply, State}; +handle_cast(Msg, State) when binary(Msg) -> + {noreply, State}; +handle_cast(Msg, State) when not is_tuple(Msg), not is_list(Msg) -> + {noreply, State}; +handle_cast(Msg, State) when float(Msg) -> + {noreply, State}; +handle_cast(Msg, State) when function(Msg) -> + {noreply, State}; +handle_cast(Msg, State) when integer(Msg) -> + {noreply, State}; +handle_cast(Msg, State) when list(Msg) -> + {noreply, State}; +handle_cast(Msg, State) when number(Msg) -> + {noreply, State}; +handle_cast(Msg, State) when pid(Msg) -> + {noreply, State}; +handle_cast(Msg, State) when port(Msg) -> + {noreply, State}; +handle_cast(Msg, State) when reference(Msg) -> + {noreply, State}; +handle_cast(Msg, State) when tuple(Msg) -> + {noreply, State}. + +%%---------------------------------------------------------------------- +%% Func: handle_info/2 +%% Returns: {noreply, State} | +%% {noreply, State, Timeout} | +%% {stop, Reason, State} (terminate/2 is called) +%%---------------------------------------------------------------------- +handle_info(Info, State) -> + {noreply, State}. + +%%---------------------------------------------------------------------- +%% Func: terminate/2 +%% Purpose: Shutdown the server +%% Returns: any (ignored by gen_server) +%%---------------------------------------------------------------------- +terminate(Reason, State) -> + ok. + +%%---------------------------------------------------------------------- +%% Func: code_change/3 +%% Purpose: Convert process state when code is changed +%% Returns: {ok, NewState} +%%---------------------------------------------------------------------- +code_change(OldVsn, State, Extra) -> + {ok, State}. + +%%%---------------------------------------------------------------------- +%%% Internal functions +%%%---------------------------------------------------------------------- + |