on master help sign in
Test-driven Unicode education: fixed a fun test bug
commite825889df7307989f0f002aade3ab183aeb93935 authorBryan O'Sullivan <bos@serpentine.com> dateSat 20 May 2017, 22:09 (9 years ago) parentd5c10e6
1 file changed+4−1
tests/Tests/Properties.hs+4−1
tests/Tests/Properties.hs+4−1
@@ -38,6 +38,7 @@ import qualified Control.Exception as Exception
3838import qualified Data.Bits as Bits (shiftL, shiftR)
3939import qualified Data.ByteString as B
4040import qualified Data.ByteString.Lazy as BL
41+import qualified Data.Char as C
4142import qualified Data.List as L
4243import qualified Data.Text as T
4344import qualified Data.Text.Encoding as E
@@ -327,8 +328,10 @@ t_toUpper_upper t = p (T.toUpper t) >= p t
327328 where p = T.length . T.filter isUpper
328329tl_toUpper_upper t = p (TL.toUpper t) >= p t
329330 where p = TL.length . TL.filter isUpper
330−t_toTitle_title t = all (<= 1) (caps t)
331+t_toTitle_title t = all (<= 1) (caps w)
331332 where caps = fmap (T.length . T.filter isUpper) . T.words . T.toTitle
333+ -- TIL: there exist uppercase-only letters
334+ w = T.filter (\c -> if C.isUpper c then C.toLower c /= c else True) t
332335t_toTitle_1stNotLower = and . notLow . T.toTitle . T.filter stable
333336 where notLow = mapMaybe (fmap (not . isLower) . (T.find isLetter)) . T.words
334337 -- Surprise! The Spanish/Portuguese ordinal indicators changed