Skip to content

Commit

Permalink
Add protocol implementation for References
Browse files Browse the repository at this point in the history
  • Loading branch information
BjRo committed Jun 22, 2015
1 parent 1286665 commit 7737eb2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/apex/format.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ defprotocol Apex.Format do
def format(data, options \\ [])
end

defimpl Apex.Format, for: Reference do
import Apex.Format.Utils

def format(data, options \\ []) do
colorize(inspect(data), data, options) <> new_line
end
end

defimpl Apex.Format, for: BitString do
import Apex.Format.Utils

Expand Down
5 changes: 5 additions & 0 deletions test/format_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ defmodule Apex.Format.Test do
use ExUnit.Case
import Apex.Format

test "Can format references" do
reference = make_ref
assert format(reference, color: false) =~ ~r/#Reference<\d\.\d\.\d\.\d+>/
end

test "Can format a list of strings" do
assert format(~w(a b c d), color: false) == """
[
Expand Down

0 comments on commit 7737eb2

Please sign in to comment.