add string case behaviour description and tests

This commit is contained in:
Martin Janiczek
2020-04-24 14:43:03 +02:00
parent afbd1f29d7
commit bf2facf9a5
2 changed files with 12 additions and 1 deletions

View File

@@ -55,12 +55,15 @@ import Dict.Any exposing (AnyDict)
{-| Rules are a dictionary with various plural forms of words in your given
language.
Elsewhere you can supply a function giving the default case (in English
Elsewhere you can supply a function giving the default pluralization (in English
that's adding a `-s` suffix), but here in `Rules` you'll have to supply the
"exceptions" (like words that add an `-es` suffix instead).
For an example see `fromList`.
Note `Rules` don't do anything about case at all! If they contain `"query"` but
you then try to `pluralize 5 "Query"`, the `query` rule _won't_ get used!
-}
type Rules
= Rules (Dict String (AnyDict Int Cardinal String))

View File

@@ -43,6 +43,14 @@ fromFloatInt =
\int string ->
PluralRules.fromInt config PluralRules.empty int string
|> Expect.equal (PluralRules.fromFloat config PluralRules.empty (toFloat int) string)
, test "doesn't do anything about case" <|
\() ->
PluralRules.fromInt config rulesWithQuery 2 "Query"
|> Expect.equal "Query"
, test "connects if the case is the same" <|
\() ->
PluralRules.fromInt config rulesWithQuery 2 "query"
|> Expect.equal "queries"
]