Permalink
Browse files

Can format function & minor corrections to pids

  • Loading branch information...
1 parent d6ee627 commit 0bb0fdad3e1f0303a68cdbd0bc702ffcd837905c @BjRo committed Jan 19, 2014
Showing with 13 additions and 4 deletions.
  1. +7 −1 lib/ap/format.ex
  2. +6 −3 test/format_test.exs
View
@@ -32,6 +32,12 @@ end
defimpl AP.Format, for: PID do
def format(data, options // []) do
- "#PID#{:erlang.pid_to_list(data)}" <> AP.Format.Utils.new_line
+ inspect(data) <> AP.Format.Utils.new_line
+ end
+end
+
+defimpl AP.Format, for: Function do
+ def format(data, options // []) do
+ inspect(data) <> AP.Format.Utils.new_line
end
end
@@ -76,8 +76,11 @@ defmodule AP.Format.Test do
end
test "Can format pid" do
- assert format(self, color: false) == """
- #PID<0.71.0>
- """
+ assert format(self, color: false) =~ %r(#PID<0.\d\d.0>\n)
+ end
+
+ test "Can format function" do
+ f = fn(a) -> "#{a}" end
+ assert format(f, color: false) =~ %r(#Function<0.\d+ in AP.Format.Test.test Can format function/1>\n)
end
end

0 comments on commit 0bb0fda

Please sign in to comment.