aboutsummaryrefslogtreecommitdiffstats
path: root/lib/dialyzer/test/indent_SUITE_data/src/sample_behaviour/sample_callback_correct_2.erl
blob: c218174e5813148375d4ab54b121aa35c04226c8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
-module(sample_callback_correct_2).

-behaviour(sample_behaviour).

-export([
	 sample_callback_1/0,
	 sample_callback_2/0,
	 sample_callback_3/0,
	 sample_callback_4/1,
	 sample_callback_5/1,
	 sample_callback_6/3,
	 common_infrastructure/1
	]).

sample_callback_1() -> 42.       % This is a valid return.
sample_callback_2() -> halt().   % Crashes are also allowed.
sample_callback_3() -> {ok, 17}. % This is a valid return.
sample_callback_4(Input) ->
    case Input of
	1 -> common_infrastructure(Input); % This is 'correct' input for
	_ -> ok                            % common_infrastructure.
    end.
sample_callback_5(Input) ->
    case get(Input) of % This is valid handling of a more generic input
	true  -> ok;   % This is a valid return.
	false -> fail  % This is a valid return.
    end.
sample_callback_6(OldNr, NewNr, Reason) ->
    Diff = NewNr - OldNr,                         % This is valid handling of the input
    Msg = string:join(["Reason: ", Reason], ","), % This is valid handling of the input
    case Diff > 0 of
	true -> put(mine, {NewNr, Msg}),
		{ok, NewNr};                 % This is a valid return.
	false -> fail                        % This is a valid return.
    end.

common_infrastructure( 1) ->   'ok';
common_infrastructure(42) -> 'fail'.