Allow Word to contain digits (#42)

This commit is contained in:
Dmitry Bushev 2016-12-16 18:03:14 +03:00 committed by Mark Karpov
parent f3cdc38874
commit 185c506788
2 changed files with 4 additions and 2 deletions

View File

@ -51,6 +51,6 @@ parser acronyms = many (acronym acronyms <|> word) <* eof
word :: Parser Word
word = do
firstChar <- upperChar <|> lowerChar
restChars <- many lowerChar
restChars <- many $ lowerChar <|> digitChar
return . Word . T.pack $ firstChar : restChars
{-# INLINE word #-}

View File

@ -7,9 +7,11 @@ import Text.Inflections (toUnderscore, toDashed, toCamelCased)
spec :: Spec
spec = do
describe "toUnderscore" $
describe "toUnderscore" $ do
it "converts camel case to snake case" $
toUnderscore "camelCasedText" `shouldReturn` "camel_cased_text"
it "converts camel case to snake case with numbers" $
toUnderscore "ipv4Address" `shouldReturn` "ipv4_address"
describe "toDashed" $
it "converts camel case to dashed" $
toDashed "camelCasedText" `shouldReturn` "camel-cased-text"