@@ -11,7 +11,7 @@ module Tests.Properties
11import Control.Applicative ((<$>), (<*>))
11import Control.Applicative ((<$>), (<*>))
12import Control.Arrow ((***), second)
12import Control.Arrow ((***), second)
13import Data.Bits ((.&.))
13import Data.Bits ((.&.))
14−import Data.Char (chr, isDigit, isHexDigit, isLower, isSpace, isUpper, ord)
14+import Data.Char (chr, isDigit, isHexDigit, isLower, isSpace, isLetter, isUpper, ord)
15import Data.Int (Int8, Int16, Int32, Int64)
15import Data.Int (Int8, Int16, Int32, Int64)
16import Data.Monoid (Monoid(..))
16import Data.Monoid (Monoid(..))
17import Data.String (IsString(fromString))
17import Data.String (IsString(fromString))
@@ -23,6 +23,7 @@ import Data.Text.Internal.Search (indices)
23import Data.Text.Lazy.Read as TL
23import Data.Text.Lazy.Read as TL
24import Data.Text.Read as T
24import Data.Text.Read as T
25import Data.Word (Word, Word8, Word16, Word32, Word64)
25import Data.Word (Word, Word8, Word16, Word32, Word64)
26+import Data.Maybe (mapMaybe)
26import Numeric (showEFloat, showFFloat, showGFloat, showHex)
27import Numeric (showEFloat, showFFloat, showGFloat, showHex)
27import Prelude hiding (replicate)
28import Prelude hiding (replicate)
28import Test.Framework (Test, testGroup)
29import Test.Framework (Test, testGroup)
@@ -328,6 +329,8 @@ tl_toUpper_upper t = p (TL.toUpper t) >= p t
328 where p = TL.length . TL.filter isUpper
329 where p = TL.length . TL.filter isUpper
329t_toTitle_title t = all (<= 1) (caps t)
330t_toTitle_title t = all (<= 1) (caps t)
330 where caps = fmap (T.length . T.filter isUpper) . T.words . T.toTitle
331 where caps = fmap (T.length . T.filter isUpper) . T.words . T.toTitle
332+t_toTitle_1stNotLower = all id . (notLow . T.toTitle)
333+ where notLow = mapMaybe (fmap (not . isLower) . (T.find isLetter)) . T.words
332justifyLeft k c xs = xs ++ L.replicate (k - length xs) c
335justifyLeft k c xs = xs ++ L.replicate (k - length xs) c
333justifyRight m n xs = L.replicate (m - length xs) n ++ xs
336justifyRight m n xs = L.replicate (m - length xs) n ++ xs
@@ -1033,7 +1036,8 @@ tests =
1033 testProperty "t_toUpper_length" t_toUpper_length,
1036 testProperty "t_toUpper_length" t_toUpper_length,
1034 testProperty "t_toUpper_upper" t_toUpper_upper,
1037 testProperty "t_toUpper_upper" t_toUpper_upper,
1035 testProperty "tl_toUpper_upper" tl_toUpper_upper,
1038 testProperty "tl_toUpper_upper" tl_toUpper_upper,
1036− testProperty "t_toTitle_title" t_toTitle_title
1039+ testProperty "t_toTitle_title" t_toTitle_title,
1040+ testProperty "t_toTitle_1stNotLower" t_toTitle_1stNotLower
1039 testGroup "justification" [
1043 testGroup "justification" [