diff options
author | Zandra <[email protected]> | 2016-01-27 11:44:59 +0100 |
---|---|---|
committer | Zandra <[email protected]> | 2016-01-27 11:44:59 +0100 |
commit | f0b7d4797b13a90b4dcee40468a5675a73feb1d4 (patch) | |
tree | 44e2832bbe7e7a0c1deaa6bd8685d3d03713a2b2 /lib/hipe/test/basic_SUITE_data/basic_receive.erl | |
parent | 6b6828e51300e318b8a3a572b6a5d78ca3756d79 (diff) | |
parent | 9722388b2fcec9b7f7e5680335e1bd6392ef11fc (diff) | |
download | otp-f0b7d4797b13a90b4dcee40468a5675a73feb1d4.tar.gz otp-f0b7d4797b13a90b4dcee40468a5675a73feb1d4.tar.bz2 otp-f0b7d4797b13a90b4dcee40468a5675a73feb1d4.zip |
Merge branch 'maint'
Diffstat (limited to 'lib/hipe/test/basic_SUITE_data/basic_receive.erl')
-rw-r--r-- | lib/hipe/test/basic_SUITE_data/basic_receive.erl | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/lib/hipe/test/basic_SUITE_data/basic_receive.erl b/lib/hipe/test/basic_SUITE_data/basic_receive.erl new file mode 100644 index 0000000000..5f865d7b7a --- /dev/null +++ b/lib/hipe/test/basic_SUITE_data/basic_receive.erl @@ -0,0 +1,56 @@ +%%% -*- erlang-indent-level: 2 -*- +%%%------------------------------------------------------------------- +%%% Author: Kostis Sagonas +%%% +%%% Contains code examples that test correct handling of receives. +%%%------------------------------------------------------------------- +-module(basic_receive). + +-export([test/0]). + +test() -> + ok = test_wait_timeout(), + ok = test_double_timeout(), + ok = test_reschedule(), + ok. + +%%-------------------------------------------------------------------- + +test_wait_timeout() -> + receive after 42 -> ok end. + +%%-------------------------------------------------------------------- + +test_double_timeout() -> + self() ! foo, + self() ! another_foo, + receive + non_existent -> weird + after 0 -> timeout + end, + receive + foo -> ok + after 1000 -> timeout + end. + +%%-------------------------------------------------------------------- +%% Check that RESCHEDULE returns from BIFs work. + +test_reschedule() -> + erts_debug:set_internal_state(available_internal_state, true), + First = self(), + Second = spawn(fun() -> doit(First) end), + receive + Second -> ok + end, + receive + after 42 -> ok + end, + erts_debug:set_internal_state(hipe_test_reschedule_resume, Second), + ok. + +doit(First) -> + First ! self(), + erts_debug:set_internal_state(hipe_test_reschedule_suspend, 1). + +%%-------------------------------------------------------------------- |