Skip to content

Commit

Permalink
Can format function & minor corrections to pids
Browse files Browse the repository at this point in the history
  • Loading branch information
BjRo committed Jan 19, 2014
1 parent d6ee627 commit 0bb0fda
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
8 changes: 7 additions & 1 deletion lib/ap/format.ex
Expand Up @@ -32,6 +32,12 @@ end


defimpl AP.Format, for: PID do defimpl AP.Format, for: PID do
def format(data, options // []) 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
end end
9 changes: 6 additions & 3 deletions test/format_test.exs
Expand Up @@ -76,8 +76,11 @@ defmodule AP.Format.Test do
end end


test "Can format pid" do test "Can format pid" do
assert format(self, color: false) == """ assert format(self, color: false) =~ %r(#PID<0.\d\d.0>\n)
#PID<0.71.0> 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
end end

0 comments on commit 0bb0fda

Please sign in to comment.