Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Can format HashSets

  • Loading branch information...
commit 34722bf6cae11170c3fee87d1ae3ee1bcc7aea4b 1 parent 467ab35
@BjRo authored
Showing with 21 additions and 0 deletions.
  1. +11 −0 lib/ap/format.ex
  2. +10 −0 test/format_test.exs
View
11 lib/ap/format.ex
@@ -52,3 +52,14 @@ defimpl AP.Format, for: HashDict do
numbers: false)
end
end
+
+defimpl AP.Format, for: HashSet do
+ def format(data, options // []) do
+ AP.Format.Seq.format(
+ Set.to_list(data),
+ options,
+ start_token: "#HashSet <",
+ end_token: ">",
+ numbers: false)
+ end
+end
View
10 test/format_test.exs
@@ -93,4 +93,14 @@ defmodule AP.Format.Test do
>
"""
end
+
+ test "Can format HashSets" do
+ dict = HashSet.new(foo: "bar", baz: "fizz")
+ assert format(dict, color: false) == """
+ #HashSet <
+ baz: "fizz"
+ foo: "bar"
+ >
+ """
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.