diff options
author | Stavros Aronis <[email protected]> | 2011-10-28 16:54:29 +0200 |
---|---|---|
committer | Stavros Aronis <[email protected]> | 2011-11-18 15:06:39 +0100 |
commit | d101155c5dc115a51725b52e500c9a981845f2da (patch) | |
tree | c433d52c42da87a03a1aba58bc9b23c1a51bd19f /lib/dialyzer/test/behaviour_SUITE_data/src/sample_behaviour/sample_callback_correct_2.erl | |
parent | 7fde343786329e7465a53c1d2f36e9436343e387 (diff) | |
download | otp-d101155c5dc115a51725b52e500c9a981845f2da.tar.gz otp-d101155c5dc115a51725b52e500c9a981845f2da.tar.bz2 otp-d101155c5dc115a51725b52e500c9a981845f2da.zip |
Behaviour callback discrepancy detection for Dialyzer
Diffstat (limited to 'lib/dialyzer/test/behaviour_SUITE_data/src/sample_behaviour/sample_callback_correct_2.erl')
-rw-r--r-- | lib/dialyzer/test/behaviour_SUITE_data/src/sample_behaviour/sample_callback_correct_2.erl | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/dialyzer/test/behaviour_SUITE_data/src/sample_behaviour/sample_callback_correct_2.erl b/lib/dialyzer/test/behaviour_SUITE_data/src/sample_behaviour/sample_callback_correct_2.erl new file mode 100644 index 0000000000..148cea6843 --- /dev/null +++ b/lib/dialyzer/test/behaviour_SUITE_data/src/sample_behaviour/sample_callback_correct_2.erl @@ -0,0 +1,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() -> foo. % This is a valid return. +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'. |