Verified Commit 60f0f675 authored by Camil Staps's avatar Camil Staps 🚀

Use strict maybe type

parent 77b91cd4
Pipeline #44578 passed with stage
in 55 seconds
definition module Testing.JUnitExport
from StdFile import class <<<
from StdMaybe import :: Maybe
from System.FilePath import :: FilePath
from Testing.Util import :: RunResult
......@@ -29,7 +28,7 @@ from Testing.Util import :: RunResult
, juc_name :: !String
, juc_classname :: !String
, juc_time :: !Int // in milliseconds
, juc_failure :: !Maybe String
, juc_failure :: ! ?String
}
resultsToJUnitExport :: ![RunResult] -> JUnitExport
......
......@@ -42,9 +42,9 @@ where
, juc_classname = fromMaybe "unknown module" $ (\l -> l.moduleName) =<< event.EndEvent.location
, juc_time = 0 // TODO
, juc_failure = case event.event of
Failed Nothing -> Just "unknown reason"
Failed (Just r) -> Just (toString r)
_ -> Nothing
Failed Nothing -> ?Just "unknown reason"
Failed (Just r) -> ?Just (toString r)
_ -> ?None
}
instance toString FailReason
......
definition module Testing.Util
from StdFile import class <<<
from StdMaybe import :: Maybe
from Data.GenDiff import :: Diff, generic gDiff
from Data.Maybe import :: Maybe
from Testing.Options import :: TestRun
from Testing.TestEvents import :: EndEvent, :: EndEventType, :: Expression
from Text.GenJSON import :: JSONNode, generic JSONEncode, generic JSONDecode
......@@ -18,7 +18,7 @@ derive JSONEncode RunResult
derive JSONDecode RunResult
instance <<< RunResult
readResults :: !*File -> *(!Maybe [RunResult], !*File)
readResults :: !*File -> *(! ?[RunResult], !*File)
mergeResults :: ![RunResult] -> [RunResult]
......
......@@ -18,13 +18,13 @@ derive JSONDecode RunResult, TestRun, EndEventType
instance <<< RunResult where (<<<) f rr = f <<< toJSON rr <<< "\n"
readResults :: !*File -> *(!Maybe [RunResult], !*File)
readResults :: !*File -> *(! ?[RunResult], !*File)
readResults f
# (e,f) = fend f
| e = (Just [], f)
# (l,f) = freadline f
# rr = fromJSON $ fromString l
| isNothing rr = (Nothing, f)
| isNothing rr = (?None, f)
# (rrs,f) = readResults f
= ((\rrs -> [fromJust rr:rrs]) <$> rrs, f)
......@@ -43,7 +43,7 @@ where
merge _ Skipped = Skipped
merge Passed Passed = Passed
derive gDiff GenConsAssoc, Maybe, JSONNode
derive gDiff GenConsAssoc, ?, JSONNode
derive gPrint Expression, JSONNode
gDiff{|Expression|} x y = case (x,y) of
......
......@@ -16,7 +16,6 @@ import Data.Functor
import Data.GenDiff
import Data.GenEq
import Data.List
import Data.Maybe
import Data.Tuple
import System.CommandLine
import System.FilePath
......@@ -50,13 +49,13 @@ derive gEq MessageType; instance == MessageType where (==) a b = a === b
{ test_options :: !TestOptions
, strategy :: !Strategy
, output_format :: !OutputFormat
, output_junit_file :: !Maybe FilePath
, output_junit_file :: ! ?FilePath
, hide :: ![MessageType]
, stop_on_first_failure :: !Bool
}
derive gDefault MessageType, Options, OutputFormat, Strategy
gDefault{|Maybe|} _ = Nothing
gDefault{| ? |} _ = ?None
optionDescription :: Option Options
optionDescription = WithHelp True $ Options
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment