Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/elixir/lib/inspect.ex
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ defimpl Inspect, for: List do
cond do
:io_lib.printable_list(thing) ->
<< ?', String.escape(:unicode.characters_to_binary(thing), ?') :: binary, ?' >>
keyword?(thing) ->
keyword?(thing) && !opts.raw ->
surround_many("[", thing, "]", opts.limit, keyword(&1, opts))
true ->
surround_many("[", thing, "]", opts.limit, Kernel.inspect(&1, opts))
Expand Down
6 changes: 6 additions & 0 deletions lib/elixir/test/elixir/inspect_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@ defmodule Inspect.ListTest do
"[foo: [1, 2, 3, :bar],\n bazzz: :bat]"
end

test :keyword_with_raw do
assert inspect([a: 1], raw: true) == "[{:a, 1}]"
assert inspect([a: 1, b: 2], raw: true) == "[{:a, 1}, {:b, 2}]"
assert inspect([a: 1, a: 2, b: 2], raw: true) == "[{:a, 1}, {:a, 2}, {:b, 2}]"
end

test :non_keyword do
assert inspect([{ Regex, 1 }]) == "[{Regex, 1}]"
end
Expand Down