From 00da3541b7bf1b01de543db8283e9fd88634a903 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Thu, 9 Jun 2022 21:56:59 +0200 Subject: Guard command --- src/Main.hs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/Main.hs') 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 -- cgit v1.2.3