Skip to content

Instantly share code, notes, and snippets.

@julienXX
Created May 20, 2013 10:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save julienXX/5611536 to your computer and use it in GitHub Desktop.
Save julienXX/5611536 to your computer and use it in GitHub Desktop.
-include_lib("eunit/include/eunit.hrl").
-module(simple_server).
-export([start/0]).
basic_test_() ->
{"Test quit message",
fun() ->
simple_server:start(),
?assertEqual("Quit command received. Closing down server", simple_server ! "quit")
end
}.
start() ->
register(simple_server, spawn( fun() -> loop() end)).
loop() ->
receive
"quit" -> io:format("Quit command received. Closing down server");
"list" -> io:format("List command received. Listing rooms"),
loop();
Msg -> io:format("Received message: ~p~n", [Msg]),
loop()
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment