param can take an empty value

This commit is contained in:
Filip Graliński 2018-07-10 12:10:02 +02:00
parent ab635f2594
commit 9f5882719b
2 changed files with 7 additions and 2 deletions

View File

@ -36,5 +36,5 @@ parseParam :: Parser (Text, Text)
parseParam = do parseParam = do
param <- many1 $ satisfy (\c -> c /= '=' && c /= ',') param <- many1 $ satisfy (\c -> c /= '=' && c /= ',')
"=" "="
val <- many1 $ notChar ',' val <- Data.Attoparsec.Text.takeWhile (/= ',')
pure $ (strip $ pack param, strip $ pack val) pure $ (strip $ pack param, strip val)

View File

@ -333,6 +333,11 @@ main = hspec $ do
OutputFileParsed "out" (Data.Map.Strict.fromList [("nb_epochs", "12"), OutputFileParsed "out" (Data.Map.Strict.fromList [("nb_epochs", "12"),
("foo", "off"), ("foo", "off"),
("bar-baz", "10")]) ("bar-baz", "10")])
it "empty val" $ do
parseParamsFromFilePath "out-nb_epochs=1,foo=,bar-baz=8.tsv" `shouldBe`
OutputFileParsed "out" (Data.Map.Strict.fromList [("nb_epochs", "1"),
("foo", ""),
("bar-baz", "8")])