Merge pull request #61 from edennis/term-to-pid-add-binary-support

Add binary support to recon_lib:term_to_pid/1
diff --git a/src/recon_lib.erl b/src/recon_lib.erl
index 8bae1db..f62b6dc 100644
--- a/src/recon_lib.erl
+++ b/src/recon_lib.erl
@@ -150,6 +150,7 @@
 term_to_pid(Pid) when is_pid(Pid) -> Pid;
 term_to_pid(Name) when is_atom(Name) -> whereis(Name);
 term_to_pid(List = "<0."++_) -> list_to_pid(List);
+term_to_pid(Binary = <<"<0.", _/binary>>) -> list_to_pid(binary_to_list(Binary));
 term_to_pid({global, Name}) -> global:whereis_name(Name);
 term_to_pid({via, Module, Name}) -> Module:whereis_name(Name);
 term_to_pid({X,Y,Z}) when is_integer(X), is_integer(Y), is_integer(Z) ->
diff --git a/test/recon_lib_SUITE.erl b/test/recon_lib_SUITE.erl
index 5c022c8..b42e38e 100644
--- a/test/recon_lib_SUITE.erl
+++ b/test/recon_lib_SUITE.erl
@@ -2,7 +2,7 @@
 -include_lib("common_test/include/ct.hrl").
 -compile(export_all).
 
-all() -> [scheduler_usage_diff, sublist_top_n].
+all() -> [scheduler_usage_diff, sublist_top_n, term_to_pid].
 
 scheduler_usage_diff(_Config) ->
     {Active0, Total0} = {1000, 2000},
@@ -27,3 +27,21 @@
         Sub = (catch recon_lib:sublist_top_n_attrs(L, N))
      end || N <- lists:seq(0, length(L)+1)],
     ok.
+
+term_to_pid(_Config) ->
+    Pid = self(),
+    Pid = recon_lib:term_to_pid(Pid),
+    List = pid_to_list(Pid),
+    Pid = recon_lib:term_to_pid(List),
+    Binary = list_to_binary(List),
+    Pid = recon_lib:term_to_pid(Binary),
+    Name = foo,
+    register(Name, Pid),
+    Pid = recon_lib:term_to_pid(Name),
+    yes = global:register_name(Name, Pid),
+    Pid = recon_lib:term_to_pid({global, Name}),
+    Sublist = lists:sublist(List, 2, length(List)-2),
+    Ints = [ element(1, string:to_integer(T)) || T <- string:tokens(Sublist, ".")],
+    Triple = list_to_tuple(Ints),
+    Pid = recon_lib:term_to_pid(Triple),
+    ok.