check whether data is OK
This commit is contained in:
parent
7f3973890d
commit
b52819f67e
@ -82,6 +82,7 @@ data GEvalException = NoExpectedFile FilePath
|
||||
| TooFewLines
|
||||
| TooManyLines
|
||||
| EmptyOutput
|
||||
| UnexpectedData String
|
||||
deriving (Eq)
|
||||
|
||||
instance Exception GEvalException
|
||||
@ -97,6 +98,7 @@ instance Show GEvalException where
|
||||
show TooFewLines = "Too few lines in the output file"
|
||||
show TooManyLines = "Too many lines in the output file"
|
||||
show EmptyOutput = "The output file is empty"
|
||||
show (UnexpectedData message) = "Unexpected data [" ++ message ++ "]"
|
||||
|
||||
somethingWrongWithFilesMessage :: String -> FilePath -> String
|
||||
somethingWrongWithFilesMessage msg filePath = Prelude.concat
|
||||
@ -200,3 +202,4 @@ itemError (exp, out) = (exp-out)**2
|
||||
|
||||
getValue :: Either String (Double, Text) -> Double
|
||||
getValue (Right (x, _)) = x
|
||||
getValue (Left s) = throw $ UnexpectedData s
|
||||
|
@ -40,6 +40,8 @@ main = hspec $ do
|
||||
runGEvalTest "error-too-many-lines" `shouldThrow` (== TooManyLines)
|
||||
it "empty output is handled" $ do
|
||||
runGEvalTest "empty-output" `shouldThrow` (== EmptyOutput)
|
||||
it "unexpected data is handled" $
|
||||
runGEvalTest "unexpected-data" `shouldThrow` (== UnexpectedData "input does not start with a digit")
|
||||
|
||||
extractVal :: (Either (ParserResult GEvalOptions) (Maybe MetricValue)) -> IO MetricValue
|
||||
extractVal (Right (Just val)) = return val
|
||||
|
@ -0,0 +1,4 @@
|
||||
2.0
|
||||
1.1
|
||||
xyz
|
||||
2.1
|
|
1
test/unexpected-data/unexpected-data/config.txt
Normal file
1
test/unexpected-data/unexpected-data/config.txt
Normal file
@ -0,0 +1 @@
|
||||
--metric MSE
|
4
test/unexpected-data/unexpected-data/test-A/expected.tsv
Normal file
4
test/unexpected-data/unexpected-data/test-A/expected.tsv
Normal file
@ -0,0 +1,4 @@
|
||||
2.0
|
||||
-3.0
|
||||
1.0
|
||||
2.5
|
|
4
test/unexpected-data/unexpected-data/test-A/in.tsv
Normal file
4
test/unexpected-data/unexpected-data/test-A/in.tsv
Normal file
@ -0,0 +1,4 @@
|
||||
bla 2
|
||||
bar 3
|
||||
bla 3
|
||||
bar 3
|
|
Loading…
Reference in New Issue
Block a user