Permalink
Browse files

* command.erl

  Added list port parse clause

* command.hrl
  Added new type in typespec for type field for the #port{} record

* command_tests.erl
  New test for listing ports
  • Loading branch information...
1 parent 4a801c6 commit 3075618aa71d27697b48d32b97eb8fa1daecd93e Gianfranco Alongi committed Mar 9, 2012
Showing with 11 additions and 2 deletions.
  1. +5 −1 Two/Solution/src/command.erl
  2. +1 −1 Two/Solution/src/command.hrl
  3. +5 −0 Two/Solution/test/command_tests.erl
View
6 Two/Solution/src/command.erl
@@ -27,7 +27,11 @@ parse("open "++Rest) ->
parse("close "++Rest) ->
#port{type = close,
- arguments = [{port,list_to_integer(Rest)}]}.
+ arguments = [{port,list_to_integer(Rest)}]};
+
+parse("list port") ->
+ #port{type = list}.
+
View
2 Two/Solution/src/command.hrl
@@ -2,6 +2,6 @@
arguments :: [{atom(),string()}]
}).
--record(port,{type :: open | close,
+-record(port,{type :: open | close | list,
arguments :: [{atom(),string() | non_neg_integer()}]
}).
View
5 Two/Solution/test/command_tests.erl
@@ -36,5 +36,10 @@ close_test() ->
?assertMatch(#port{type = close,
arguments = [{port,1234}]},
command:parse(Command)).
+
+list_port_test() ->
+ Command = "list port",
+ ?assertMatch(#port{type = list},
+ command:parse(Command)).

0 comments on commit 3075618

Please sign in to comment.