From e825889df7307989f0f002aade3ab183aeb93935 Mon Sep 17 00:00:00 2001 From: Bryan O'Sullivan <bos@serpentine.com> Date: Sat, 20 May 2017 22:09:39 -0700 Subject: [PATCH] Test-driven Unicode education: fixed a fun test bug --- tests/Tests/Properties.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/Tests/Properties.hs b/tests/Tests/Properties.hs index 8bc6f75f..1f00037b 100644 --- a/tests/Tests/Properties.hs +++ b/tests/Tests/Properties.hs @@ -38,6 +38,7 @@ import qualified Control.Exception as Exception import qualified Data.Bits as Bits (shiftL, shiftR) import qualified Data.ByteString as B import qualified Data.ByteString.Lazy as BL +import qualified Data.Char as C import qualified Data.List as L import qualified Data.Text as T import qualified Data.Text.Encoding as E @@ -327,8 +328,10 @@ t_toUpper_upper t = p (T.toUpper t) >= p t where p = T.length . T.filter isUpper tl_toUpper_upper t = p (TL.toUpper t) >= p t where p = TL.length . TL.filter isUpper -t_toTitle_title t = all (<= 1) (caps t) +t_toTitle_title t = all (<= 1) (caps w) where caps = fmap (T.length . T.filter isUpper) . T.words . T.toTitle + -- TIL: there exist uppercase-only letters + w = T.filter (\c -> if C.isUpper c then C.toLower c /= c else True) t t_toTitle_1stNotLower = and . notLow . T.toTitle . T.filter stable where notLow = mapMaybe (fmap (not . isLower) . (T.find isLetter)) . T.words -- Surprise! The Spanish/Portuguese ordinal indicators changed -- GitLab