Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

* command.erl

  Changed port open parse to return port record

* command.hrl
  Changed open record to port record for port related commands

* command_tests.erl
  Changed the open test to expect a port record
  • Loading branch information...
commit 327cbd82f9d1c49576805e1a854bdd70a03c0cf8 1 parent d26c276
Gianfranco Alongi authored
View
7 Two/Solution/src/command.erl
@@ -2,7 +2,7 @@
-export([parse/1]).
-include("command.hrl").
--spec(parse(string()) -> {error,empty_command} | #binding{}).
+-spec(parse(string()) -> {error,empty_command} | #binding{} | #port{}).
parse("") ->
{error,empty_command};
@@ -21,8 +21,9 @@ parse("unbind "++Type) ->
parse("open "++Rest) ->
[Port,Type] = string:tokens(Rest," "),
- #open{port = list_to_integer(Port),
- type = Type}.
+ #port{type = open,
+ arguments = [{port,list_to_integer(Port)},
+ {type,Type}]}.
View
4 Two/Solution/src/command.hrl
@@ -2,6 +2,6 @@
arguments :: [{atom(),string()}]
}).
--record(open,{port :: non_neg_integer(),
- type :: string()
+-record(port,{type :: open,
+ arguments :: [{atom(),string() | non_neg_integer()}]
}).
View
5 Two/Solution/test/command_tests.erl
@@ -25,8 +25,9 @@ unbind_test() ->
open_test() ->
Command = "open 1234 testtype",
- ?assertMatch(#open{port = 1234,
- type = "testtype"},
+ ?assertMatch(#port{type = open,
+ arguments = [{port,1234},
+ {type,"testtype"}]},
command:parse(Command)).
Please sign in to comment.
Something went wrong with that request. Please try again.