Skip to content

Commit 9a52f2a

Browse files
author
José Valim
committed
Format string.ex and improve upcase coverage
1 parent 1828888 commit 9a52f2a

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

lib/elixir/lib/string.ex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -641,8 +641,8 @@ defmodule String do
641641

642642
def upcase(string, :ascii) when is_binary(string) do
643643
for <<x <- string>>,
644-
do: if(x >= ?a and x <= ?z, do: <<x - 32>>, else: <<x>>),
645-
into: ""
644+
do: if(x >= ?a and x <= ?z, do: <<x - 32>>, else: <<x>>),
645+
into: ""
646646
end
647647

648648
def upcase(string, mode) when mode in @conditional_mappings do
@@ -693,8 +693,8 @@ defmodule String do
693693

694694
def downcase(string, :ascii) when is_binary(string) do
695695
for <<x <- string>>,
696-
do: if(x >= ?A and x <= ?Z, do: <<x + 32>>, else: <<x>>),
697-
into: ""
696+
do: if(x >= ?A and x <= ?Z, do: <<x + 32>>, else: <<x>>),
697+
into: ""
698698
end
699699

700700
def downcase(string, mode) when mode in @conditional_mappings do

lib/elixir/test/elixir/string_test.exs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ defmodule StringTest do
149149
assert String.upcase("áüÈß") == "ÁÜÈSS"
150150
end
151151

152+
test "upcase/1 with ascii" do
153+
assert String.upcase("olá", :ascii) == "OLá"
154+
end
155+
152156
test "downcase/1" do
153157
assert String.downcase("123 ABcD 456 EfG HIJ ( %$#) KL MNOP @ QRST = -_ UVWXYZ") ==
154158
"123 abcd 456 efg hij ( %$#) kl mnop @ qrst = -_ uvwxyz"

0 commit comments

Comments
 (0)