diff options
Diffstat (limited to 'learn-you-some-erlang/tests/multiproc_tests.erl')
-rw-r--r-- | learn-you-some-erlang/tests/multiproc_tests.erl | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/learn-you-some-erlang/tests/multiproc_tests.erl b/learn-you-some-erlang/tests/multiproc_tests.erl new file mode 100644 index 0000000..1020324 --- /dev/null +++ b/learn-you-some-erlang/tests/multiproc_tests.erl @@ -0,0 +1,28 @@ +-module(multiproc_tests). +-include_lib("eunit/include/eunit.hrl"). + +%% sleep's implementation is copy/pasted from the timer module. +%% not much to test to be safe. +sleep_test_() -> + [?_assertEqual(ok, multiproc:sleep(10))]. + +flush_test_() -> + {spawn, + [fun() -> + self() ! a, + self() ! b, + ok = multiproc:flush(), + self() ! c, + [?assertEqual(receive M -> M end, c)] + end]}. + +priority_test_() -> + {spawn, + [fun() -> + self() ! {15, high}, + self() ! {7, low}, + self() ! {1, low}, + self() ! {17, high}, + [?assertEqual([high, high, low, low], + multiproc:important())] + end]}. |