File tree Expand file tree Collapse file tree 2 files changed +24
-8
lines changed
Expand file tree Collapse file tree 2 files changed +24
-8
lines changed Original file line number Diff line number Diff line change @@ -100,7 +100,7 @@ defimpl Inspect, for: Atom do
100100 valid_ref_identifier? ( binary ) ->
101101 "Elixir." <> rest = binary
102102 rest
103- atom in [ :{} , :<<>> ] ->
103+ atom in [ :{} , :<<>> , :... ] ->
104104 ":" <> binary
105105 atom in Macro . binary_ops or atom in Macro . unary_ops ->
106106 ":" <> binary
@@ -127,16 +127,21 @@ defimpl Inspect, for: Atom do
127127 # Detect if atom
128128
129129 defp valid_atom_identifier? ( << h , t :: binary >> ) when h in ?a .. ?z or h in ?A .. ?Z or h == ?_ do
130- case valid_identifier? ( t ) do
131- << >> -> true
132- << ?? >> -> true
133- << ?! >> -> true
134- _ -> false
135- end
130+ valid_atom_piece? ( t )
136131 end
137132
138133 defp valid_atom_identifier? ( _ ) , do: false
139134
135+ defp valid_atom_piece? ( t ) do
136+ case valid_identifier? ( t ) do
137+ << >> -> true
138+ << ?? >> -> true
139+ << ?! >> -> true
140+ << ?@ , t :: binary >> -> valid_atom_piece? ( t )
141+ _ -> false
142+ end
143+ end
144+
140145 defp valid_identifier? ( << h , t :: binary >> )
141146 when h in ?a .. ?z
142147 when h in ?A .. ?Z
Original file line number Diff line number Diff line change @@ -37,11 +37,22 @@ defmodule Inspect.AtomTest do
3737 end
3838
3939 test :op do
40- assert inspect ( :@ ) == ":@ "
40+ assert inspect ( :+ ) == ":+ "
4141 assert inspect ( :&&& ) == ":&&&"
4242 assert inspect ( :~~~ ) == ":~~~"
4343 end
4444
45+ test :... do
46+ assert inspect ( :... ) == ":..."
47+ end
48+
49+ test :@ do
50+ assert inspect ( :@ ) == ":@"
51+ assert inspect ( :foo@bar ) == ":foo@bar"
52+ assert inspect ( :foo@bar@ ) == ":foo@bar@"
53+ assert inspect ( :foo@bar@baz ) == ":foo@bar@baz"
54+ end
55+
4556 test :container do
4657 assert inspect ( :<<>> ) == ":<<>>"
4758 assert inspect ( :{} ) == ":{}"
You can’t perform that action at this time.
0 commit comments