summaryrefslogtreecommitdiff
path: root/src/Main.hs
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2022-06-09 21:56:59 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2022-06-09 21:56:59 +0200
commit00da3541b7bf1b01de543db8283e9fd88634a903 (patch)
treef36e6f9931c055706b2228322ffce0b7e00108f8 /src/Main.hs
parent62251c102c57d4c12da6923dc0ea5747cfb3ef0c (diff)
Guard command
Diffstat (limited to 'src/Main.hs')
-rw-r--r--src/Main.hs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/Main.hs b/src/Main.hs
index 5e1e7b2..efab611 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -296,6 +296,13 @@ expect (SourceLine sline) p re vars = do
outLine OutputMatchFail (Just $ procName p) $ T.pack "expect failed on " `T.append` sline
throwError ()
+testStepGuard :: SourceLine -> Expr Bool -> TestRun ()
+testStepGuard (SourceLine sline) expr = do
+ x <- eval expr
+ when (not x) $ do
+ outLine OutputMatchFail Nothing $ T.pack "guard failed on " `T.append` sline
+ throwError ()
+
allM :: Monad m => [a] -> (a -> m Bool) -> m Bool
allM (x:xs) p = p x >>= \case True -> allM xs p; False -> return False
allM [] _ = return True
@@ -340,6 +347,9 @@ runTest out opts test = do
regex <- eval expr
expect line p regex captures
+ Guard line expr -> do
+ testStepGuard line expr
+
Wait -> do
outPrompt $ T.pack "Waiting..."
void $ liftIO $ getLine