casing 0.1.3.0 → 0.1.4.0
raw patch · 3 files changed
+22/−17 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- casing.cabal +1/−1
- src/Text/Casing.hs +15/−14
- tests/Spec.hs +6/−2
casing.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: casing-version: 0.1.3.0+version: 0.1.4.0 synopsis: Convert between various source code casing conventions description: Converts between camelCase, PascalCase, kebab-case, and three flavors of snake_case.
src/Text/Casing.hs view
@@ -61,20 +61,21 @@ go (x:[]) = [x:[]] go xxs@(x:xs) | isUpper x =- case xs of- "" ->- [[x]]- (y:_) ->- if isUpper y then- [x]:go xs- else- let cur = x:takeWhile (not . isUpper) xs- rem = dropWhile (not . isUpper) xs- in - if null rem then- [cur]- else- cur:go rem+ let lhs = takeWhile isUpper xxs+ rhs = dropWhile isUpper xxs+ in+ if null rhs then+ [lhs]+ else+ let curLen = length lhs - 1+ cur = take curLen lhs+ rec = go rhs+ nxt = drop curLen lhs ++ concat (take 1 rec)+ rem = drop 1 rec+ curL = if null cur then [] else [cur]+ nxtL = if null nxt then [] else [nxt]+ in curL ++ nxtL ++ rem+ | otherwise = let cur = takeWhile (not . isUpper) xxs rem = dropWhile (not . isUpper) xxs
tests/Spec.hs view
@@ -41,8 +41,12 @@ (fromHumps "HelloAWorld") , testCase "multi letter abbrev split" $ do assertEqual ""- (Identifier ["Hello", "X", "M", "L", "World"])+ (Identifier ["Hello", "XML", "World"]) (fromHumps "HelloXMLWorld")+ , testCase "multi letter acronym at the end" $ do+ assertEqual ""+ (Identifier ["Hello", "XML"])+ (fromHumps "HelloXML") , testCase "single letter upper" $ do assertEqual "" (Identifier ["A"])@@ -141,7 +145,7 @@ (fromAny "HelloAWorld") , testCase "multi letter abbrev split" $ do assertEqual ""- (Identifier ["Hello", "X", "M", "L", "World"])+ (Identifier ["Hello", "XML", "World"]) (fromAny "HelloXMLWorld") , testCase "single letter upper" $ do assertEqual ""