mirror of
https://github.com/typeable/inflections-hs.git
synced 2024-09-11 06:05:33 +03:00
Allow Word to contain digits (#42)
This commit is contained in:
parent
f3cdc38874
commit
185c506788
@ -51,6 +51,6 @@ parser acronyms = many (acronym acronyms <|> word) <* eof
|
|||||||
word :: Parser Word
|
word :: Parser Word
|
||||||
word = do
|
word = do
|
||||||
firstChar <- upperChar <|> lowerChar
|
firstChar <- upperChar <|> lowerChar
|
||||||
restChars <- many lowerChar
|
restChars <- many $ lowerChar <|> digitChar
|
||||||
return . Word . T.pack $ firstChar : restChars
|
return . Word . T.pack $ firstChar : restChars
|
||||||
{-# INLINE word #-}
|
{-# INLINE word #-}
|
||||||
|
@ -7,9 +7,11 @@ import Text.Inflections (toUnderscore, toDashed, toCamelCased)
|
|||||||
|
|
||||||
spec :: Spec
|
spec :: Spec
|
||||||
spec = do
|
spec = do
|
||||||
describe "toUnderscore" $
|
describe "toUnderscore" $ do
|
||||||
it "converts camel case to snake case" $
|
it "converts camel case to snake case" $
|
||||||
toUnderscore "camelCasedText" `shouldReturn` "camel_cased_text"
|
toUnderscore "camelCasedText" `shouldReturn` "camel_cased_text"
|
||||||
|
it "converts camel case to snake case with numbers" $
|
||||||
|
toUnderscore "ipv4Address" `shouldReturn` "ipv4_address"
|
||||||
describe "toDashed" $
|
describe "toDashed" $
|
||||||
it "converts camel case to dashed" $
|
it "converts camel case to dashed" $
|
||||||
toDashed "camelCasedText" `shouldReturn` "camel-cased-text"
|
toDashed "camelCasedText" `shouldReturn` "camel-cased-text"
|
||||||
|
Loading…
Reference in New Issue
Block a user