Skip to content

Commit 7210ab2

Browse files
kelvinstjosevalim
authored andcommitted
Keeping underscore between digits on Macro.camelize/1 (#10843)
Closes #10839
1 parent 174b771 commit 7210ab2

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

lib/elixir/lib/macro.ex

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1737,6 +1737,9 @@ defmodule Macro do
17371737
defp do_camelize(<<?_, h, t::binary>>) when h >= ?a and h <= ?z,
17381738
do: <<to_upper_char(h)>> <> do_camelize(t)
17391739

1740+
defp do_camelize(<<p, ?_, h, t::binary>>) when p >= ?0 and p <= ?9 and h >= ?0 and h <= ?9,
1741+
do: <<p, ?_, h>> <> do_camelize(t)
1742+
17401743
defp do_camelize(<<?_, h, t::binary>>) when h >= ?0 and h <= ?9, do: <<h>> <> do_camelize(t)
17411744
defp do_camelize(<<?_>>), do: <<>>
17421745
defp do_camelize(<<?/, t::binary>>), do: <<?.>> <> camelize(t)

lib/elixir/test/elixir/macro_test.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,6 +1036,7 @@ defmodule MacroTest do
10361036
assert Macro.camelize("foo__bar") == "FooBar"
10371037
assert Macro.camelize("foo/bar") == "Foo.Bar"
10381038
assert Macro.camelize("Foo.Bar") == "Foo.Bar"
1039+
assert Macro.camelize("foo1_0") == "Foo1_0"
10391040
assert Macro.camelize("FOO_BAR") == "FOO_BAR"
10401041
assert Macro.camelize("FOO.BAR") == "FOO.BAR"
10411042
assert Macro.camelize("") == ""

0 commit comments

Comments
 (0)